Linux 安装Zabbix监控工具(2)

5、安装几个需要的软件包

[root@localhost zabbix-2.2.0]# yum install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath -y

6、查看php的所有的modules,看是否包括了安装zabbix所需要的bcmath ,mbstring ,sockets, gd ,gd PNG support ,gd JPEG support ,gd FreeType support ,libxml,xmlwriter, xmlreader ,ctype , session ,gettext这些模块

[root@localhost zabbix-2.2.0]# php -m ###查看已经支持的php模块

[PHP Modules]
bz2
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
hash
iconv
json
ldap
libxml
mbstring
MySQL
mysqli
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
SQLite
sqlite3
standard
tokenizer

xml
xmlreader
xmlwriter
zip
zlib

我的php模块还少几个,所以我打补丁补全

安装gettext 模块

[root@localhost ~]# cd /usr/src/php-5.3.27/ext/gettext/

[root@localhost gettext]# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

[root@localhost gettext]# ./configure --with-php-config=/usr/local/bin/php-config

[root@localhost gettext]# make

[root@localhost gettext]# make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

[root@localhost gettext]# ls modules/
gettext.so

修改php的配置文件php.ini,添加扩展模块

[root@localhost local]# vi /usr/local/lib/php.ini

extension=gettext.so ###增加 这一行

bcmath模块安装

[root@localhost bcmath]# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

[root@localhost bcmath]# ./configure --with-php-config=/usr/local/bin/php-config

[root@localhost bcmath]# make

[root@localhost bcmath]# make install

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

[root@localhost bcmath]# ls modules/
bcmath.so

修改php的配置文件php.ini,添加扩展模块

[root@localhost local]# vi /usr/local/lib/php.ini

extension= bcmath.so ###增加 这一行

sockets模块安装

[root@localhost ext]# cd sockets/

[root@localhost sockets]# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

[root@localhost sockets]# ./configure --with-php-config=/usr/local/bin/php-config

[root@localhost sockets]# make

[root@localhost sockets]# make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files: /usr/local/include/php/

[root@localhost sockets]# ls modules/
sockets.so

修改php的配置文件php.ini,添加扩展模块

[root@localhost local]# vi /usr/local/lib/php.ini

extension=sockets.so ###增加 这一行

扩展安装完成后重启apache

[root@localhost sockets]# /etc/init.d/apache restart

查看php模块发现目前已经出现了三个模块

7、安装、配置zabbix

[root@localhost ~]# cd /usr/src/zabbix-2.2.0/

[root@localhost zabbix-2.2.0]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl

[root@localhost ~]# make

[root@localhost ~]# make install

修改/etc/services,添加下面几行

zabbix-agent 10050/tcp #zabbix agent
zabbix-agent 10050/udp #zabbix agent
zabbix-trapper 10051/tcp #zabbix trapper
zabbix-trapper 10051/udp #zabbix trapper
修改zabbix的配置文件

[root@localhost zabbix-2.2.0]# vi /usr/local/zabbix/etc/zabbix_server.conf

[root@localhost zabbix-2.2.0]# cat /usr/local/zabbix/etc/zabbix_server.conf | grep -v ^# | grep -v ^$
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

DBSocket=/var/run/mysqld/mysql5.socket

做几个软连接

[root@localhost ~]# ln -s /usr/local/zabbix/bin/* /usr/bin/
[root@localhost ~]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/

[root@localhost ~]# cd /usr/src/zabbix-2.2.0/

[root@localhost ~]# cp /usr/src/zabbix-2.2.0/misc/init.d/Fedora/core/* /etc/init.d/

 

[root@localhost ~]# vi /etc/init.d/zabbix_server

BASEDIR=/usr/local/zabbix ##########修改这行

[root@localhost ~]# vi /etc/init.d/zabbix_agentd

BASEDIR=/usr/local/zabbix ##########修改这行

 

[root@localhost frontends]# cp /usr/src/zabbix-2.2.0/frontends /var/www/zabbix/ -r

[root@localhost frontends]# chown daemon.daemon /var/www/ -R

[root@localhost frontends]# chown 777 /var/www/zabbix/conf

 

8、新建虚拟主机

[root@localhost ~]# cd /usr/local/apache2/conf/extra/
[root@localhost extra]# vi httpd-vhosts.conf

Linux 安装Zabbix监控工具


修改apache的主配置文件,开启8008端口

[root@localhost conf]# vi /usr/local/apache2/conf/httpd.conf

#Listen 12.34.56.78:80
Listen 80
Listen 8008

然后重启apache的服务

[root@localhost ~]# /etc/init.d/apache restart

[root@localhost conf]# lsof -i:8008
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 1814 root 8w IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2887 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2888 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2889 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2890 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2891 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2892 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)

 

9、启动zabbix服务

[root@localhost lib]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd: [ OK ]

[root@localhost lib]# /etc/init.d/zabbix_server start
Starting zabbix_server: /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[FAILED]

解决方法

[root@localhost ~]# locate libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18.0.0
/usr/src/mysql-5.6.10/libmysql/libmysqlclient.so.18
/usr/src/mysql-5.6.10/libmysql/libmysqlclient.so.18.0.0

[root@localhost ~]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf

[root@localhost ~]# ldconfig

[root@localhost lib]# /etc/init.d/zabbix_server start
Starting zabbix_server: [ OK ]

[root@localhost lib]# /etc/init.d/snmpd restart
Stopping snmpd: [FAILED]
Starting snmpd: [ OK ]

[root@localhost ~]# /etc/init.d/mysql5 restart
Shutting down MySQL.. [ OK ]
Starting MySQL... [ OK ]

[root@localhost ~]# /etc/init.d/apache restart

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/b7bc1883be73594279eb74a41238b6b6.html