OS:Centos6.064位、内核:2.6.32-71.el6.x86_64
zabbix 2.0.2版本与1.8.3版本安装过程略有不同,下面为实施步骤:
服务端:192.168.1.13
客户端:192.168.1.19
1、安装LAMP环境及依赖包
[root@localhost~]# yum install mysql-server mysql-devel libcurl-devel net-snmp-devel phpphp-gd php-xml php-mysql php-mbstring php-bcmath httpd
2、添加用户
1. [root@localhost ~]# groupadd zabbix
2. [root@localhost ~]# useradd zabbix -g zabbix
3、创建数据库,添加用户授权
3. [root@localhost ~]# /etc/rc.d/init.d/mysqldstart
4. [root@localhost ~]# mysql -e "createdatabase zabbix default character set utf8;"
5. [root@localhost ~]# mysql -e "grant allprivileges on zabbix.* to zabbix@localhostidentified by '111111';"
4、导入数据库(zabbix/database/mysql)注意先后顺序
6. [root@localhost zabbix-2.0.2]#mysql -uzabbix -p'111111' zabbix < database/mysql/schema.sql
7. [root@localhost zabbix-2.0.2]#mysql -uzabbix -p'111111' zabbix < database/mysql/images.sql
8. [root@localhost zabbix-2.0.2]#mysql -uzabbix -p'111111' zabbix < database/mysql/data.sql
5、编译安装zabbix
9. [root@localhost ~]# cd /usr/local/src/
10. [root@localhost src]# tar zxf zabbix-2.0.2.tar.gz
11. [root@localhost src]# cd zabbix-2.0.2
12. [root@localhost zabbix-2.0.2]#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent –enable-proxy--with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
13. [root@localhost zabbix-2.0.2]#make install
14. 说明:--with-mysql=/usr/local/mysql/bin/mysql_config不写完成,安装时会报mysql libarary not found
6、更改配置文件中数据库相关的用户名密码
#vim /usr/local/zabbix/etc/zabbix_server.conf
修改以下三项:
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
注:DBPassword 默认是被注释掉的
# vim /etc/zabbix/zabbix_agentd.conf
Hostname=station3.example.com
ServerActive=192.168.1.3:20051
拷贝相应WEB程序到相关WEB目录下
#mkdir–p /var/www/html/zabbix
#cp–r /install/zabbix-2.0.3/frontends/php/*/var/www/html/zabbix/
#chown–R zabbix.zabbix /var/www/html/zabbix
拷贝、修改配置文件
15. [root@localhost zabbix-2.0.3]#cp /install/zabbix-2.0.3/misc/init.d/fedora/core/zabbix_server /etc/init.d/
16. [root@localhost zabbix-2.0.3]#cp /install/zabbix-2.0.3/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
2.14修改启动脚本
# vim /etc/init.d/zabbix_server
BASEDIR="/usr/local/zabbix" 修改zabbix_server实际位置
# service zabbix_server start
Starting Zabbix Server: [ OK ]
# vim /etc/init.d/zabbix_agentd
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"
# service zabbix_agentd start
Starting Zabbix Agent: [ OK ]
[root@station3 ~]# chkconfig zabbix_server on
[root@station3 ~]# chkconfig zabbix_agentd on
17. 把mysql的lib库文件添加到系统动态库配置文件中,方便系统可以找到mysql的lib库
[root@rhelsbin]# echo "/usr/local/mysql/lib/mysql/" >> /etc/ld.so.conf
[root@rhel sbin]# ldconfig (立即生效)
7、添加服务端口(2.0.3版本已经自动添加了)
[root@localhost~]# vim /etc/services 追加如下内容:
18. zabbix-agent 10050/tcp Zabbix Agent
19. zabbix-agent 10050/udp Zabbix Agent
20. zabbix-trapper 10051/tcp Zabbix Trapper
21. zabbix-trapper 10051/udp Zabbix Trapper
或者如下方式填写
[root] cat>>/etc/services<<EOF
>zabbix-agent10050/tcp Zabbix Agent
>zabbix-agent10050/udp Zabbix Agent
>zabbix-trapper10051/tcp Zabbix Trapper
>zabbix-trapper10051/udp Zabbix Trapper
>EOF
8、修改调整php.ini参数使zabbix更好的工作
1. [root@localhost ~]#sed -i 's/^\(.*\)date.timezone=.*$/date.timezone = Asia\/Shanghai/g' /etc/php.ini
2. [root@localhost ~]#sed -i 's/^\(.*\)post_max_size=.*$/post_max_size = 32M/g'/etc/php.ini
3. [root@localhost ~]#sed -i 's/^\(.*\)max_execution_time=.*$/max_execution_time = 300/g' /etc/php.ini
4. [root@localhost ~]#sed -i 's/^\(.*\)max_input_time=.*$/max_input_time = 300/g' /etc/php.ini
5. [root@localhost ~]#sed -i 's/^\(.*\);mbstring.func_overload=.*$/mbstring.func_overload = 2/g' /etc/php.ini
6.
或者vi php.ini
7. max_execution_time = 300
8. max_input_time = 300
9. post_max_size = 16M
10. date.timezone = Asia/Shanghai
9、启动服务
[root@localhost ~]# /etc/init.d/zabbix_serverstart
[root@localhost ~]# /etc/init.d/zabbix_agentdstart
[root@localhost ~]# /etc/init.d/httpd start
添加开机启动服务
chkconfig --add zabbix_server
chkconfig --level 35 zabbix_server on
chkconfig --add zabbix_agentd
chkconfig --level 35 zabbix_agentd on
10、WEB配置服务http://192.168.128.11/zabbix
(1)首页
以下截图是在安装2.0.1版本的截图,2.0.2版本完全一致。
说明:Databasetype显示NO,表示php模块安装不完整,不支持mysql数据库,故需要安装mysql模块
(4)主机IP,端口
(6) 配置Fail,点击Download configuration file将zabbix.conf.php保存到本地,再上传至服务器/var/www/html/zabbix/conf目录,然后Retry
(7)刷新后配置正确,点击Finsh完成
备注:出现上图错误,重新导入三个数据库schema.sql/images.sql/data.sql文件即可。
(10)更换语言更换中文后图像出现乱码解决方法:上传windows中文字体到服务器替换原字体。
[root@localhost ~]#cd /var/www/html/zabbix/fonts
[root@localhost ~]#mv DejaVuSans.ttf DejaVuSans.ttf_bak #备份原字体
[root@localhost ~]#mv msyh.ttf DejaVuSans.ttf #雅黑字体
11、客户端(linux)安装,这次新版本采用源码安装
[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd zabbix -gzabbix
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar zxf zabbix-2.0.2.tar.gz
[root@localhost src]# cd zabbix-2.0.2
[root@localhost zabbix-2.0.2]#./configure --prefix=/usr/local/zabbix--enable-agent
[root@localhost zabbix-2.0.2]# makeinstall
[root@localhost zabbix-2.0.2]#cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@localhost zabbix-2.0.2]#sed-i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g'/etc/init.d/zabbix_agentd
[root@localhost zabbix-2.0.2]#vi /usr/local/zabbix/etc/zabbix_agentd.conf
Server=192.168.1.13
Hostname=Zabbix-client
[root@localhost zabbix-2.0.2]#/etc/init.d/zabbix_agentd start
[root@localhost zabbix-2.0.2]#tail -f /tmp/zabbix_agentd.log
[root@localhost zabbix-2.0.2]#netstat–tunlp | grep zabbix
在命令行输入/usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k agent.hostname。如果输出Zabbix server,证明zabbix服务器端跟客户端可以正常通信*
问题:添加主机报错
Compilation failed: this version of PCRE is not compiled withPCRE_UTF8 support at offset 0
解决:修改报错文件
11、客户端(windows)安装:
从官网下载windows agent客户端zabbix_agents_2.0.0.win.zip。解压到c:\zabbix目录下。
创建zabbix_agentd.conf文件,并在文件中写入如下内容:
LogFile=c:\zabbix\zabbix_agentd.log
Server=192.168.1.211 (zabbix服务器IP地址)
Hostname=192.168.1.168(客户主机名或IP地址)
在命令行执行:
zabbix_agentd.exe –c c:\zabbix\zabbix_agentd.conf –i (安装zabbix_agent端)
zabbix_agentd.exe –c c:\zabbix\zabbix_agentd.conf –s (启动zabbix_agent端)