1 zabbix3.2.4 安装

一. 搭建zabbix服务

Zabbix 3.0对PHP的要求最低为5.4,而CentOS6默认为5.3.3,完全不满足要求,故需要利用第三方源,将PHP升级到5.4以上,注意,不支持PHP7。如下是zabbix服务端搭建过程
 
环境:centos6.5  
zabbix-server: 192.168.9.28
 
1.安装php
[root@localhost ~]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
[root@localhost ~]# yum -y install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
[root@localhost ~]# cp /etc/php.ini /etc/php.ini.org
[root@localhost ~]# vim /etc/php.ini
889 date.timezone = Asia/Shanghai
663 post_max_size = 32M
375 max_execution_time = 300
385 max_input_time = 300
705 always_populate_raw_post_data = -1
 
2.安装mysql:详见本博客地址:http://www.cnblogs.com/lzcys8868/p/7788292.html
创建zabbix用户,设置密码,授权zabbix用户,如下:

mysql> create database zabbix character set utf8;

Query OK, 1 row affected (0.02 sec)

mysql>  grant all on zabbix.* to zabbix@localhost identified by 'zabbix';

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.03 sec)

 

[root@localhost mysql]# mysql -uzabbix -p
Enter password: 输入zabbix

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
| zabbix             |
+--------------------+
3 rows in set (0.00 sec)

 

 

3.安装zabbix

 [root@localhost ~]# yum - y install httpd libxml2-devel net-snmp-devel libcurl-devel

[root@localhost mysqldb]# groupadd -g 201 zabbix
[root@localhost mysqldb]# useradd -g zabbix -u 201 -m zabbix

[root@localhost mysqldb]# cd /root/soft
[root@localhost soft]# ls
zabbix-3.2.4.tar.gz

[root@localhost soft]# tar xf zabbix-3.2.4.tar.gz -C /usr/src/

[root@localhost soft]# cd /usr/src/zabbix-3.2.4/
[root@localhost zabbix-3.2.4]# mysql -uzabbix -pzabbix zabbix < ./database/mysql/schema.sql

[[root@localhost zabbix-3.2.4]# mysql -uzabbix -pzabbix zabbix < ./database/mysql/
images.sql

[root@localhost zabbix-3.2.4]# mysql -uzabbix -pzabbix zabbix < ./database/mysql/
data.sql

[root@localhost zabbix-3.2.4]# yum -y install gcc gcc-c++ make

[root@localhost zabbix-3.2.4]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2

[root@localhost zabbix-3.2.4]# make && make install

注:编译 zabbix 如果报下面错误,就做以下操作 configure: error: Not found mysqlclient library

[root@localhost zabbix-3.2.4]#find / -name libmysqlclient*
[root@localhost zabbix-3.2.4]#
ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so
[root@localhost zabbix-3.2.4]#
ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient_r.so)


4. 配置zabbix

[root@localhost zabbix-3.2.4]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.org
[root@localhost zabbix-3.2.4]# vim /etc/zabbix/zabbix_server.conf

77 DBHost=192.168.9.28   //数据库ip地址

85 DBName=zabbix

102 DBUser=zabbix

298 ListenIP=127.0.0.1,192.168.9.28   //zabbix_server地址

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

[root@localhost zabbix-3.2.4]# cp -r /usr/src/zabbix-3.2.4/misc/init.d/fedora/core/zabbix_* /etc/init.d/

[root@localhost zabbix-3.2.4]# chmod +x /etc/init.d/zabbix_*

[root@localhost zabbix-3.2.4]# sed -i "s@BASEDIR/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
 
 
5.创建zabbix_agentd 服务
Agent的作用就是获得host数据,然后将收集到的数据发送给server,或者sever主动来拿数据
[root@localhost zabbix]# pwd
/etc/zabbix
[root@localhost zabbix]# cp zabbix_agentd.conf zabbix_agentd.conf.origin
[root@localhost zabbix]# vim zabbix_agentd.conf
123 ServerActive=192.168.9.28:10051  //服务器端IP ,端口固定
21 LogFile=/var/log/zabbix/zabbix_agentd.log
82 Server=127.0.0.1,192.168.9.28   //服务端IP地址
228  UnsafeUserParameters=1   //自定义脚本功能,1为开启,默认0为关闭
216  Include=/etc/zabbix/zabbix_agentd.conf.d/  //自定义的agent配置文件存放路径
[root@localhost zabbix]# vim /etc/init.d/zabbix_agentd
 21         # Zabbix-Directory
 22         BASEDIR=/usr/local/zabbix
[root@localhost zabbix]# /etc/init.d/zabbix_agentd start
[root@localhost frontends]# netstat -lnpt | grep zabbix_*
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      20806/zabbix_agentd
 
 
 
6.部署PHP 页面文档
[root@localhost zabbix-3.2.4]# pwd
/usr/src/zabbix-3.2.4
[root@localhost zabbix-3.2.4]# mkdir -pv /var/www/html/zabbix
[root@localhost zabbix-3.2.4]# cp -rf frontends/php/ /var/www/html/zabbix
[root@localhost zabbix-3.2.4]# chown -R apache.apache /var/www/html/zabbix/
[root@localhost zabbix-3.2.4]#  /etc/init.d/httpd start
 
 
 
7.配置web页面
[root@localhost zabbix-3.2.4]# vim /etc/httpd/conf/httpd.conf
 276 ServerName 127.0.0.1
 277 ServerName 192.168.9.28
293 DocumentRoot "/var/www/html"
[root@localhost zabbix-3.2.4]# mkdir -p /var/www/html/zabbix
[root@localhost zabbix-3.2.4]# chown -R apache.apache /var/www/html/zabbix

[root@localhost zabbix-3.2.4]# chkconfig zabbix_server on

[root@localhost ~]# service zabbix_server start

 

8.浏览器访问zabbix,并按照提示安装

http://192.168.9.28/zabbix

输入用户名密码  Admin/zabbix

 

 至此,zabbix3.0 搭建完成

 
 
 
 
 
posted @ 2017-11-02 14:27  刘振川的博客  阅读(218)  评论(0编辑  收藏  举报