以下内容来自于http://www.iyunv.com/thread-62087-1-1.html
补充一点,按照原文安装万之后zabbix页面会提示
zabbix server is not running: the information displayed may not be current
解决方法(参考自http://fengzhige.blog.51cto.com/3691377/1034485)是:
setsebool -P httpd_can_network_connect on
一.部署环境
系统:CentOS 6.4x64 最小化安装
Server:192.168.3.28
Client:192.168.3.29
二.基础软件包安装
在server安装基础软件包,这里的环境使用yum安装,如果使用源码安装也是可以的。
[[email protected] ~]# yum -y install wget vim tree gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp net-snmp-devel curl-devel
启动httpd、mysql并设置成开机自动启动
[[email protected] ~]# service httpd start [[email protected]-server ~]# service mysqld start [[email protected]-server ~]# chkconfig httpd on [[email protected]-server ~]# chkconfig mysqld on
在iptables中放行80,10050,10051端口。
[[email protected] ~]# iptables -I INPUT -p tcp -m multiport --destination-port 80,10050:10051 -j ACCEPT #查看防火墙结果 [[email protected]-server ~]# iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 80,10050:10051 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination #保存iptables规则 [[email protected]-server ~]# service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
三.配置PHP参数
zabbix的运行需要特定的php参数支持,修改如下
[[email protected] ~]# sed -i "[email protected];date.timezone [email protected] = Asia/[email protected]" /etc/php.ini [[email protected]-server ~]# sed -i "[email protected]_execution_time = [email protected]_execution_time = [email protected]" /etc/php.ini [[email protected]-server ~]# sed -i "[email protected]_max_size = [email protected]_max_size = [email protected]" /etc/php.ini [[email protected]-server ~]# sed -i "[email protected]_input_time = [email protected]_input_time = [email protected]" /etc/php.ini [[email protected]-server ~]# sed -i "[email protected]_limit = [email protected]_limit = [email protected]" /etc/php.ini [[email protected]-server ~]# sed -i "[email protected];mbstring.func_overload = [email protected]_overload = [email protected]" /etc/php.ini
修改httpd的FQDN错误,重启httpd服务
[[email protected] ~]# echo "ServerName localhost:80" >>/etc/httpd/conf/httpd.conf [[email protected]-server ~]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
四.下载zabbix-2.4.5.tar.gz
[[email protected] ~]# wget http://jaist.dl.sourceforge.net/ ... zabbix-2.4.5.tar.gz
五.添加zabbix用户和组
[[email protected] ~]# groupadd -g 201 zabbix [[email protected]-server ~]# useradd -g zabbix -u 201 -s /sbin/nologin zabbix
六.安装zabbix-server端
[[email protected] ~]# tar xf zabbix-2.4.5.tar.gz [[email protected]-server ~]# cd zabbix-2.4.5 [[email protected]-server zabbix-2.4.5]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl [[email protected]-server zabbix-2.4.5]# make && make install #创建zabbix数据库以及相关表 [[email protected]-server zabbix-2.4.5]# mysql -e "create database zabbix default charset utf8;" [[email protected]-server zabbix-2.4.5]# mysql -e "grant all on zabbix.* to [email protected] identified by ‘zabbix‘;" [[email protected]-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/schema.sql [[email protected]-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/images.sql [[email protected]-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/data.sql #配置软连接和启动文件信息 [[email protected]-server zabbix-2.4.5]# mkdir /var/log/zabbix [[email protected]-server zabbix-2.4.5]# chown zabbix.zabbix /var/log/zabbix [[email protected]-server zabbix-2.4.5]# ln -s /usr/local/zabbix/etc/ /etc/zabbix [[email protected]bix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/bin/* /usr/bin/ [[email protected] zabbix-2.4.5]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/ [[email protected] zabbix-2.4.5]# cp /root/zabbix-2.4.5/misc/init.d/fedora/core/zabbix_* /etc/init.d [[email protected] zabbix-2.4.5]# chmod 755 /etc/init.d/zabbix_* #修改/etc/init.d目录下的zabbix_server和zabbix_agentd启动文件 [[email protected] zabbix-2.4.5]# sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_server [[email protected] zabbix-2.4.5]# sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_agentd #修改/etc/zabbix/zabbix_server.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected][email protected][email protected]" /etc/zabbix/zabbix_server.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected]#[email protected][email protected]" /etc/zabbix/zabbix_server.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected]# [email protected][email protected]" /etc/zabbix/zabbix_server.conf #修改/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server的IP地址,即192.168.3.28 [[email protected] zabbix-2.4.5]# sed -i "[email protected][email protected]=127.0.0.1,[email protected]" /etc/zabbix/zabbix_agentd.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected][email protected]=$IP:[email protected]" /etc/zabbix/zabbix_agentd.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected]/[email protected]/log/zabbix/[email protected]" /etc/zabbix/zabbix_agentd.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected]^# [email protected]=1\[email protected]" /etc/zabbix/zabbix_agentd.conf #复制zabbix站点的文件到/var/www/html目录下 [[email protected] zabbix-2.4.5]# cp -r /root/zabbix-2.4.5/frontends/php/ /var/www/html/zabbix/ [[email protected] zabbix-2.4.5]# chown -R apache.apache /var/www/html/zabbix/ [[email protected] zabbix-2.4.5]# chkconfig zabbix_server on [[email protected] zabbix-2.4.5]# chkconfig zabbix_agentd on [[email protected] zabbix-2.4.5]# service zabbix_server start Starting zabbix_server: [ OK ] [[email protected] zabbix-2.4.5]# service zabbix_agentd start Starting zabbix_agentd: [ OK ]
七.通过web站点配置zabbix
以上步骤配置完后通过http://192.168.3.28/zabbix/setup.php网页端进行后续配置
1.安装界面
2.PHP配置检查界面,结果是OK表示正常,如果是fail状态,请修改相关的php配置参数,并重启httpd服务
>
3.这里的数据库相关信息,在上文中有配置,具体请查看上文
4.填写zabbix的server地址,我这里填写的是本机的IP地址192.168.3.28
5.最后配置结果预览
>
6.安装完成
八.访问zabbix的web管理界面
安装完成后,通过http://192.168.3.28/zabbix/index.php#就能直接访问web管理界面
默认用户名:admin,密码:zabbix
九.调整zabbix语言
十.zabbix语言设置成中文后,有乱码解决如下
1.从windows下控制面板->字体->选择一种中文字库例如“楷体”
2.将字体上传至/var/www/html/zabbix/fonts目录下
3.修改zabbix页面管理的中文字体设置
[[email protected] zabbix-2.4.5]# vim /var/www/html/zabbix/include/defines.inc.php #修改如下2行 define(‘ZBX_FONT_NAME‘, ‘simkai‘); define(‘ZBX_GRAPH_FONT_NAME‘, ‘simkai‘);
修改后的zabbix界面。
十一.修改完以上步骤后,zabbix界面的历史记录还是乱码,这是由于mysql的数据库字符集导致的,解决办法如下
1.备份zabbix数据库,并修改备份下来的数据文件
[[email protected] ~]# mysqldump zabbix >zabbix.sql [[email protected]-server ~]# sed -i ‘s/latin1/utf8/g‘ zabbix.sql
2.删除zabbix数据库
mysql> drop database zabbix; Query OK, 104 rows affected (0.42 sec)
3.关闭mysql数据库,设置默认字符集
[[email protected] ~]# service mysqld stop Stopping mysqld: [ OK ] #在mysql配置文件中添加字符集参数 [[email protected]-server ~]# vim /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock default-character-set = utf8 user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
4.启动mysql并恢复zabbix数据库
[[email protected] ~]# service mysqld start Starting mysqld: [ OK ] [[email protected]-server ~]# mysql mysql> create database zabbix; Query OK, 1 row affected (0.00 sec) mysql> show create database zabbix; +----------+-----------------------------------------------------------------+ | Database | Create Database | +----------+-----------------------------------------------------------------+ | zabbix | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 */ | +----------+-----------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | | zabbix | +--------------------+ 4 rows in set (0.00 sec) mysql> use zabbix; Database changed mysql> source zabbix.sql;
5.查看修改后的结果
十二.在client端192.168.3.29安装zabbix
安装基础软件包
[[email protected] ~]# yum install wget vim tree gcc gcc-c++ -y
安装zabbix_agentd
[[email protected] ~]# groupadd -g 201 zabbix [[email protected]-c1 ~]# useradd -g zabbix -u 201 -s /sbin/nologin zabbix [[email protected]-c1 ~]# tar xf zabbix-2.4.5.tar.gz [[email protected]-c1 ~]# cd zabbix-2.4.5 #开始编译安装zabbix客户端 [[email protected]-c1 zabbix-2.4.5]# ./configure --prefix=/usr/local/zabbix --enable-agent [[email protected]-c1 zabbix-2.4.5]# make && make install #创建zabbix的日志目录 [[email protected]-c1 zabbix-2.4.5]# mkdir /var/log/zabbix [[email protected]-c1 zabbix-2.4.5]# chown zabbix.zabbix /var/log/zabbix #复制zabbix_agentd启动文件到/etc/init.d目录下 [[email protected]-c1 zabbix-2.4.5]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ [[email protected]-c1 zabbix-2.4.5]# chmod 755 /etc/init.d/zabbix_agentd #在iptables中放行10050和10051端口 [[email protected]-c1 zabbix-2.4.5]# iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT [[email protected]-c1 zabbix-2.4.5]# service iptables save #保存iptables规则 iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] #查看iptables结果 [[email protected]-c1 zabbix-2.4.5]# iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 10050:10051 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination #修改启动文件和配置软连接 [[email protected]-c1 zabbix-2.4.5]# sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_agentd [[email protected]-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/etc/ /etc/zabbix [[email protected]-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/bin/* /usr/bin [[email protected] zabbix-2.4.5]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/ #/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server端的IP地址 [[email protected] zabbix-2.4.5]# sed -i "[email protected][email protected][email protected]" /etc/zabbix/zabbix_agentd.conf [iyun[email protected] zabbix-2.4.5]# sed -i "[email protected][email protected]=192.168.3.28:[email protected]" /etc/zabbix/zabbix_agentd.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected]/[email protected]/log/zabbix/[email protected]" /etc/zabbix/zabbix_agentd.conf [[email protected] zabbix-2.4.5]# sed -i "[email protected]^# [email protected]=1\[email protected]" /etc/zabbix/zabbix_agentd.conf #设置zabbix_agentd开机自动启动,并启动zabbix_agentd服务 [[email protected] zabbix-2.4.5]# chkconfig zabbix_agentd on [[email protected] zabbix-2.4.5]# service zabbix_agentd start Starting zabbix_agentd: [ OK ]