51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Centos6.9编译安装zabbix3.2

安装前的准备及环境介绍

1、当前使用vm12安装Centos6.9系统,当前软件版本php5.4,mysql5.6

2、关闭selinux,关闭iptables,设置系统时间(或自行设置iptables)

service iptables stop
setenforce 0
/usr/sbin/ntpdate ntp1.aliyun.com

3、当前已安装好lnmp环境,使用的lnmp一键包1.4版本安装(https://lnmp.org/)

zabbix3.2安装过程:

1、创建zabbix数据库
mysql -uroot -p mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '321123';

|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 | mysql -uroot -p mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '321123'; |

2、创建zabbix用户
groupadd zabbix -g 201 useradd -M -r -g zabbix -u 201 -s /bin/false zabbix

|-----|----------------------------------------------------------------------------| | 1 2 | groupadd zabbix -g 201 useradd -M -r -g zabbix -u 201 -s /bin/false zabbix |

PS:在root下运行zabbix,zabbix会主动使用zabbix用户来运行,如果系统没有zabbix用户,需要创建

3、下载zabbix3.2源码包
cd /usr/local/src wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz tar zxf zabbix-3.2.7.tar.gz

|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 | cd /usr/local/src wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz tar zxf zabbix-3.2.7.tar.gz |

4、导入zabbix数据
cd /usr/local/src/zabbix-3.2.7/database/mysql/

|---|------------------------------------------------| | 1 | cd /usr/local/src/zabbix-3.2.7/database/mysql/ |


mysql -uzabbix -p321123 zabbix < schema.sql mysql -uzabbix -p321123 zabbix < images.sql mysql -uzabbix -p321123 zabbix < data.sql

|-------|--------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 | mysql -uzabbix -p321123 zabbix < schema.sql mysql -uzabbix -p321123 zabbix < images.sql mysql -uzabbix -p321123 zabbix < data.sql |

5、安装依赖
yum -y install net-snmp-devel libssh2 libssh2-devel curl-devel

|---|----------------------------------------------------------------| | 1 | yum -y install net-snmp-devel libssh2 libssh2-devel curl-devel |

6、编译安装
cd /usr/local/src/zabbix-3.2.7

|---|--------------------------------| | 1 | cd /usr/local/src/zabbix-3.2.7 |


./configure --prefix=/usr/local --sysconfdir=/etc/zabbix --enable-server --enable-agent --with-ssh2 --with-openssl --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 | ./configure --prefix=/usr/local --sysconfdir=/etc/zabbix --enable-server --enable-agent --with-ssh2 --with-openssl --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 |


make install

|---|--------------| | 1 | make install |


PS:安装时可能也会缺少其他依赖,根据报错自行安装,编译时我这里指定了mysql_config的路径,可以find / -name "mysql_config*"来查找

7、修改zabbix配置文件

默认zabbix日志在/tmp下,建议更改,我这里更改到了/var/log/zabbix下
mkdir /var/log/zabbix chown -R zabbix.zabbix /var/log/zabbix/ vim /etc/zabbix/zabbix_server.conf

|-------|--------------------------------------------------------------------------------------------------| | 1 2 3 | mkdir /var/log/zabbix chown -R zabbix.zabbix /var/log/zabbix/ vim /etc/zabbix/zabbix_server.conf |


DBName=zabbix DBUser=zabbix DBPassword=321123 LogFile=/var/log/zabbix/zabbix_server.log

|---------|-----------------------------------------------------------------------------------------| | 1 2 3 4 | DBName=zabbix DBUser=zabbix DBPassword=321123 LogFile=/var/log/zabbix/zabbix_server.log |


vim /etc/zabbix/zabbix_agentd.conf

|---|------------------------------------| | 1 | vim /etc/zabbix/zabbix_agentd.conf |


LogFile=/var/log/zabbix/zabbix_agentd.log

|---|-------------------------------------------| | 1 | LogFile=/var/log/zabbix/zabbix_agentd.log |

8、设置启动脚本
cp /usr/local/src/zabbix-3.2.7/misc/init.d/fedora/core5/* /etc/init.d/

|---|-------------------------------------------------------------------------| | 1 | cp /usr/local/src/zabbix-3.2.7/misc/init.d/fedora/core5/* /etc/init.d/ |


chkconfig --add /etc/init.d/zabbix_server chkconfig --add /etc/init.d/zabbix_agentd chkconfig zabbix_server on chkconfig zabbix_agentd on

|---------|-------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 | chkconfig --add /etc/init.d/zabbix_server chkconfig --add /etc/init.d/zabbix_agentd chkconfig zabbix_server on chkconfig zabbix_agentd on |

9、启动服务
/etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start

|-----|-----------------------------------------------------------------| | 1 2 | /etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start |

10、设置zabbix web页面
mkdir -p /data/zabbix cp -a /usr/local/src/zabbix-3.2.7/frontends/php/* /data/zabbix/

|-----|----------------------------------------------------------------------------------------| | 1 2 | mkdir -p /data/zabbix cp -a /usr/local/src/zabbix-3.2.7/frontends/php/* /data/zabbix/ |

注意:我这里用的是lnmp一键包,使用lnmp一键包自带命令,添加一个vhost,域名使用zabbix.whsir.com
lnmp vhost add

|---|----------------| | 1 | lnmp vhost add |


本地hosts刚才设置的域名zabbix.whsir.com访问

http://zabbix.whsir.com/zabbix



这里看到有个条件不满足,需要再设置下php
vim /usr/local/php/etc/php.ini

|---|--------------------------------| | 1 | vim /usr/local/php/etc/php.ini |


将max_input_time = 60改成max_input_time = 300

|---|--------------------------------------------| | 1 | 将max_input_time = 60改成max_input_time = 300 |

保存退出,重启php
/etc/init.d/php-fpm restart

|---|-----------------------------| | 1 | /etc/init.d/php-fpm restart |

再次刷新页面就好了


设置数据库连接


这里默认即可,继续下一步



最后Finish



登录帐号默认为Admin,密码zabbix

11、设置中文

当前zabbix版本已经支持中文了


在Administration-Users-Admin设置


设置Chinese(zh_CN),设置好后Update,刷新页面就是中文的了



赞(0)
未经允许不得转载:工具盒子 » Centos6.9编译安装zabbix3.2