码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS 6.4x64安装部署zabbix-2.4.5

时间:2017-05-20 14:56:59      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:dir   重启   网页端   站点   test   roo   osb   删除   not   

以下内容来自于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安装,如果使用源码安装也是可以的。

[iyunv@zabbix-server ~]# 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并设置成开机自动启动

[iyunv@zabbix-server ~]# service httpd start
[iyunv@zabbix-server ~]# service mysqld start
[iyunv@zabbix-server ~]# chkconfig httpd on
[iyunv@zabbix-server ~]# chkconfig mysqld on

 在iptables中放行80,10050,10051端口。

[iyunv@zabbix-server ~]# iptables -I INPUT -p tcp -m multiport --destination-port 80,10050:10051 -j ACCEPT

#查看防火墙结果
[iyunv@zabbix-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规则
[iyunv@zabbix-server ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

三.配置PHP参数

    zabbix的运行需要特定的php参数支持,修改如下

    

[iyunv@zabbix-server ~]# sed -i "s@;date.timezone =@date.timezone = Asia/Shanghai@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@max_execution_time = 30@max_execution_time = 300@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@post_max_size = 8M@post_max_size = 32M@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@max_input_time = 60@max_input_time = 300@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@memory_limit = 128M@memory_limit = 128M@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@;mbstring.func_overload = 0@ambstring.func_overload = 2@g" /etc/php.ini

修改httpd的FQDN错误,重启httpd服务

[iyunv@zabbix-server ~]# echo "ServerName localhost:80" >>/etc/httpd/conf/httpd.conf
[iyunv@zabbix-server ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

四.下载zabbix-2.4.5.tar.gz

[iyunv@zabbix-server ~]# wget http://jaist.dl.sourceforge.net/ ... zabbix-2.4.5.tar.gz

五.添加zabbix用户和组

[iyunv@zabbix-server ~]# groupadd -g 201 zabbix
[iyunv@zabbix-server ~]# useradd -g zabbix -u 201 -s /sbin/nologin zabbix

六.安装zabbix-server端

[iyunv@zabbix-server ~]# tar xf zabbix-2.4.5.tar.gz
[iyunv@zabbix-server ~]# cd zabbix-2.4.5
[iyunv@zabbix-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
[iyunv@zabbix-server zabbix-2.4.5]# make && make install

#创建zabbix数据库以及相关表
[iyunv@zabbix-server zabbix-2.4.5]# mysql -e "create database zabbix default charset utf8;"
[iyunv@zabbix-server zabbix-2.4.5]# mysql -e "grant all on zabbix.* to zabbix@localhost identified by ‘zabbix‘;"
[iyunv@zabbix-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/schema.sql
[iyunv@zabbix-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/images.sql
[iyunv@zabbix-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/data.sql

#配置软连接和启动文件信息
[iyunv@zabbix-server zabbix-2.4.5]# mkdir /var/log/zabbix
[iyunv@zabbix-server zabbix-2.4.5]# chown zabbix.zabbix /var/log/zabbix
[iyunv@zabbix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/etc/ /etc/zabbix
[iyunv@zabbix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/bin/* /usr/bin/
[iyunv@zabbix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/ 
[iyunv@zabbix-server zabbix-2.4.5]# cp /root/zabbix-2.4.5/misc/init.d/fedora/core/zabbix_* /etc/init.d
[iyunv@zabbix-server zabbix-2.4.5]# chmod 755 /etc/init.d/zabbix_*

#修改/etc/init.d目录下的zabbix_server和zabbix_agentd启动文件
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd

#修改/etc/zabbix/zabbix_server.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@DBUser=root@DBUser=zabbix@g" /etc/zabbix/zabbix_server.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@#DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@# DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf

#修改/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server的IP地址,即192.168.3.28
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@Server=127.0.0.1@Server=127.0.0.1,192.168.3.28@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@ServerActive=127.0.0.1@ServerActive=$IP:10051@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@^# UnsafeUserParameters=0@UnsafeUserParameters=1\n@g" /etc/zabbix/zabbix_agentd.conf

#复制zabbix站点的文件到/var/www/html目录下
[iyunv@zabbix-server zabbix-2.4.5]# cp -r /root/zabbix-2.4.5/frontends/php/ /var/www/html/zabbix/
[iyunv@zabbix-server zabbix-2.4.5]# chown -R apache.apache /var/www/html/zabbix/

[iyunv@zabbix-server zabbix-2.4.5]# chkconfig zabbix_server on
[iyunv@zabbix-server zabbix-2.4.5]# chkconfig zabbix_agentd on
[iyunv@zabbix-server zabbix-2.4.5]# service zabbix_server start
Starting zabbix_server:                                    [  OK  ]
[iyunv@zabbix-server 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页面管理的中文字体设置

[iyunv@zabbix-server 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数据库,并修改备份下来的数据文件

[iyunv@zabbix-server ~]# mysqldump zabbix >zabbix.sql
[iyunv@zabbix-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数据库,设置默认字符集

[iyunv@zabbix-server ~]# service mysqld stop
Stopping mysqld:                                           [  OK  ]

#在mysql配置文件中添加字符集参数
[iyunv@zabbix-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数据库

[iyunv@zabbix-server ~]# service mysqld start
Starting mysqld:                                           [  OK  ]
[iyunv@zabbix-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

    安装基础软件包

[iyunv@zabbix-c1 ~]# yum install wget vim tree gcc gcc-c++ -y

安装zabbix_agentd

[iyunv@zabbix-c1 ~]# groupadd  -g  201  zabbix
[iyunv@zabbix-c1 ~]# useradd  -g  zabbix -u  201 -s /sbin/nologin zabbix 
[iyunv@zabbix-c1 ~]# tar xf zabbix-2.4.5.tar.gz 
[iyunv@zabbix-c1 ~]# cd zabbix-2.4.5

#开始编译安装zabbix客户端
[iyunv@zabbix-c1 zabbix-2.4.5]# ./configure --prefix=/usr/local/zabbix --enable-agent
[iyunv@zabbix-c1 zabbix-2.4.5]# make && make install

#创建zabbix的日志目录
[iyunv@zabbix-c1 zabbix-2.4.5]# mkdir /var/log/zabbix
[iyunv@zabbix-c1 zabbix-2.4.5]# chown zabbix.zabbix /var/log/zabbix

#复制zabbix_agentd启动文件到/etc/init.d目录下
[iyunv@zabbix-c1 zabbix-2.4.5]# cp misc/init.d/fedora/core/zabbix_agentd  /etc/init.d/
[iyunv@zabbix-c1 zabbix-2.4.5]# chmod 755 /etc/init.d/zabbix_agentd

#在iptables中放行10050和10051端口
[iyunv@zabbix-c1 zabbix-2.4.5]# iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT
[iyunv@zabbix-c1 zabbix-2.4.5]# service iptables save   #保存iptables规则
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

#查看iptables结果
[iyunv@zabbix-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 

#修改启动文件和配置软连接
[iyunv@zabbix-c1 zabbix-2.4.5]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd
[iyunv@zabbix-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/etc/ /etc/zabbix
[iyunv@zabbix-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/bin/*  /usr/bin
[iyunv@zabbix-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/sbin/*  /usr/sbin/

#/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server端的IP地址
[iyunv@zabbix-c1 zabbix-2.4.5]# sed -i "s@Server=127.0.0.1@Server=192.168.3.28@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-c1 zabbix-2.4.5]# sed -i "s@ServerActive=127.0.0.1@ServerActive=192.168.3.28:10051@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-c1 zabbix-2.4.5]# sed -i "s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g"  /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-c1 zabbix-2.4.5]# sed -i "s@^# UnsafeUserParameters=0@UnsafeUserParameters=1\n@g" /etc/zabbix/zabbix_agentd.conf

#设置zabbix_agentd开机自动启动,并启动zabbix_agentd服务
[iyunv@zabbix-c1 zabbix-2.4.5]# chkconfig zabbix_agentd on
[iyunv@zabbix-c1 zabbix-2.4.5]# service zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]

 

CentOS 6.4x64安装部署zabbix-2.4.5

标签:dir   重启   网页端   站点   test   roo   osb   删除   not   

原文地址:http://www.cnblogs.com/byron0918/p/6882113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!