首页 > 代码库 > 基于CentOS 6.6搭建Zabbix2.4.x

基于CentOS 6.6搭建Zabbix2.4.x

基于CentOS 6.6搭建Zabbix2.4.x

  • 安装YUM源

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

  • 安装基础包

yum install -y gcc gcc-c++ autoconfhttpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perlmod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpcphp-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql libxml2-develnet-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel

三、配置时间及相关服务

ntpdate 202.120.2.101

date

hwclock –w

vim /etc/selinux/config

SELINUX=disabled

iptables –F

service iptables save

四、修改PHP配置

sed -i "s/;date.timezone=/date.timezone = Asia\/Shanghai/g" /etc/php.ini

sed -i "s#max_execution_time =30#max_execution_time = 300#g" /etc/php.ini

sed -i "s#post_max_size =8M#post_max_size = 32M#g" /etc/php.ini

sed -i "s#max_input_time = 60#max_input_time= 300#g" /etc/php.ini

sed -i "s#memory_limit =128M#memory_limit = 128M#g" /etc/php.ini

sed -i"/;mbstring.func_overload = 0/ambstring.func_overload = 2\n"/etc/php.ini  #注此项可能造成2.4web页面配置项PHP mbstring.func_overload检测不过,请勿修改!

顺便修改主机名

sed -i "s/#ServerNamewww.example.com:80/ServerName localhost:80/g" /etc/httpd/conf/httpd.conf

然后启动httpd、mysqld

chkconfig –level 345 mysqld on

chkconfig –level 345 httpd on

service httpd start

service mysqld start

五、下载、解压zabbix、fping

2.4源码包下载:wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.2/zabbix-2.4.2.tar.gz

tar zxvf zabbix-2.4.2.tar.gz

fping3.4下载:wget http://www.fping.org/dist/fping-3.4.tar.gz

2.2源码包下载:wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.7/zabbix-2.2.7.tar.gz

tar zxvf zabbix-2.2.7.tar.gz

六、添加用户

groupadd zabbix -g 201

useradd -g zabbix -u 201 -m zabbix

七、安装、配置zabbix、fping

cd /home/zabbix/zabbix-2.4.2

./configure --enable-server --enable-agent--with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openopmi --with-unixodbc--prefix=/usr/local/zabbix

make install

cd /home/zabbix

gunzip fping-3.4.tar.gz

tar xvf fping-3.4.tar

cd fping-3.4

./configure

make install

八、添加 zabbix到系统服务文件

echo "zabbix-agent 10050/tcp #ZabbixAgent" >> /etc/services

echo "zabbix-agent 10050/udp #ZabbixAgent" >> /etc/services

echo "zabbix-trapper 10051/tcp#Zabbix Trapper" >> /etc/services

echo "zabbix-trapper 10051/udp#Zabbix Trapper" >> /etc/services

验证

tail –n 4 /etc/services

九、导入数据

mysqladmin -uroot password‘mysql_pass‘;  #注意password 后面‘’ 中为自己填写密码

mysql -uroot -p (登陆数据库)  #密码为上面 ‘’ 中填写的密码

mysql>create database zabbixcharacter set utf8;

mysql>grant all privileges onzabbix.* to zabbix@localhost identified by ‘zabbix‘;

mysql>flush privileges;

mysql>quit;

mysql -uzabbix -pzabbix zabbix <./database/mysql/schema.sql

mysql -uzabbix -pzabbix zabbix <./database/mysql/images.sql

mysql -uzabbix -pzabbix zabbix <./database/mysql/data.sql

确保以上过程无误

创建链接

mkdir /var/log/zabbix

chown zabbix.zabbix /var/log/zabbix

ln -s /usr/local/zabbix/etc/etc/zabbix

ln -s /usr/local/zabbix/bin/*/usr/bin/

ln -s /usr/local/zabbix/sbin/*/usr/sbin/

十、拷贝 service启动脚本

cp misc/init.d/fedora/core/zabbix_*/etc/init.d/

chmod 755 /etc/init.d/zabbix_*

sed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g"/etc/init.d/zabbix_server

sed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g"/etc/init.d/zabbix_agentd

echo"/usr/local/zabbix/sbin/zabbix_server" >> /etc/rc.local

echo"/usr/local/zabbix/sbin/zabbix_agentd" >> /etc/rc.local

chkconfig zabbix_server on

chkconfig zabbix_agentd on

service zabbix_server start

service zabbix_agentd start

十一、配置 zabbix_server.conf 服务端文件

cat/usr/local/zabbix/etc/zabbix_server.conf | grep -v "^#" | grep -v"^$"

sed -i"s/DBUser\=root/DBUser\=zabbix/g" /usr/local/zabbix/etc/zabbix_server.conf

sed -i "/#DBPassword=/aDBPassword=zabbix\n" /usr/local/zabbix/etc/zabbix_server.conf

sed -i"s#tmp/zabbix_server.log#var/log/zabbix/zabbix_server.log#g" /usr/local/zabbix/etc/zabbix_server.conf

sed -i "s/\#FpingLocation\=\/usr\/sbin\/fping/FpingLocation\=\/usr\/local\/sbin\/fping/g"/usr/local/zabbix/etc/zabbix_server.conf

十二、配置 zabbix_agentd.conf 文件(监控 server本身,如对

其他服务器进行监控,配置文件相同)

注意:zabbix_agentd.conf 是客户端的配置文件,这里配置的目的是对自身进行监控

修改4 处

vim/usr/local/zabbix/etc/zabbix_agent.conf

Server=127.0.0.1 此处添加服务端的ip,如服务器不为本机,则需要填写远zabbix_server的ip 地址

ServerActive=127.0.0.1 此处修改为服务端的ip

/tmp/zabbix_agentd.log 修改日志路径

cat /usr/local/zabbix/etc/zabbix_agent.conf| grep -v "^#" | grep -v "^$"

UnsafeUserParameters=0 默认是不启用自定义脚本功能的,要自定义key,需开启,设置为1

Include=/etc/zabbix/zabbix_agentd.conf.d/自定义的agentd配置文件可以写在这个目录下面

十三、拷贝网页文件到 apache 目录

cp -r/home/zabbix/zabbix-2.4.2/frontends/php/ /var/www/html/zabbix

chown -R apache.apache/var/www/html/zabbix

十四、通过web 页面配置zabbix

在浏览器输入http://.x.x.x.x/zabbix  即可看到zabbix 2.4 配置页面 

PS:

这里可能有配置项PHP mbstring.func_overload检测不过的问题,请把/etc/php.ini中的mbstring.func_overload = 2项注释掉后重启httpd服务,然后再检测一下

数据库ip 为localhost

端口为3306

数据库名zabbix

用户为zabbix

密码为zabbix

点击test connection,如果没有问题则会提示OK,否则,需要检查数据库授权是否正确Host 本机的ipName 本机的ip

如果此处提示文件zabbix.conf.php 无法创建, 则是apache 目录无法写入,/var/www/html/zabbix 的文件权限不为apche.apache

输入以下命令解决

chown -R apache.apache/var/www/html/zabbix

默认用户名为admin,密码为zabbix

登陆后,第一件事请务必修改登录密码

如果出现Zabbix server is not running,请检查selinux及防火墙是否关闭!

zabbix 设置中文语言

默认zabbix取消的中文的支持,需开启后才能使用

vim /var/www/html/zabbix/include/locales.inc.php

‘zh_CN‘ => array(‘name‘ =>_(‘Chinese (zh_CN)‘),        ‘display‘=> false),

False 改为 true,保存刷新前端页面即可

本文出自 “zabbix” 博客,请务必保留此出处http://radeon.blog.51cto.com/9256579/1580799

基于CentOS 6.6搭建Zabbix2.4.x