原文链接:http://www.iyunv.com/thread-282896-1-1.html
1. 环境
CentOS版本:CentOS release 6.5 (Final)
Apache版本:Apache/2.2.15
2. 安装Apache/MysqL/PHP/snmp和其他的依赖包
通过yum安装
[root@zabbix-2~]# yum�Cyinstall MysqLMysqL-serverMysqL-develhttpdtreegcccc gcc-c++autoconfPHPPHP-MysqLhttpd-manualmod_sslmod_perlmod_auth_MysqLPHP-gdPHP-xmlPHP-mbstringPHP-ldapPHP-pearPHP-xmlrpcPHP-bcmathMysqL-connector-odbcMysqL-devellibdbi-dbd-MysqLnet-snmpnet-snmp-develnet-snmp-utilsnet-snmp-libscurl-devel
启动MysqLd/httpd/snmpd,并设置开机启动:
[root@zabbix-2~]#serviceMysqLdstart [root@zabbix-2~]#chkconfigMysqLdon [root@zabbix-2~]#servicehttpdstart [root@zabbix-2~]#chkconfighttpdon [root@zabbix-2~]#servicesnmpdstart [root@zabbix-2~]#chkconfigsnmpdon
[root@zabbix-2~]#sed-i"s@;date.timezone=@date.timezone=Asia/Shanghai@g"/etc/PHP.ini [root@zabbix-2~]#sed-i"s@max_execution_time=30@max_execution_time=300@g"/etc/PHP.ini [root@zabbix-2~]#sed-i"s@post_max_size=8M@post_max_size=32M@g"/etc/PHP.ini [root@zabbix-2~]#sed-i"s@max_input_time=60@max_input_time=300@g"/etc/PHP.ini [root@zabbix-2~]#sed-i"s@memory_limit=128M@memory_limit=128M@g"/etc/PHP.ini [root@zabbix-2~]#sed-i"s@;mbstring.func_overload=0@ambstring.func_overload=2@g"/etc/PHP.ini
修改httpd参数:
[root@zabbix-2~]#echo"ServerNamelocalhost:80">>/etc/httpd/conf/httpd.conf [root@zabbix-2~]#servicehttpdrestart
3.iptables放行端口80/3306/10050/10051
[root@zabbix-2~]#iptables-IINPUT-ptcp--dport80-jACCEPT [root@zabbix-2~]#iptables-IINPUT-ptcp--dport3306-jACCEPT [root@zabbix-2~]#iptables-IINPUT-ptcp--dport10050-jACCEPT [root@zabbix-2~]#iptables-IINPUT-ptcp--dport10051-jACCEPT
查看端口放行情况:
[root@zabbix-2~]#iptables-L-n ChainINPUT(policyACCEPT) targetprotoptsourcedestination ACCEPTall--0.0.0.0/00.0.0.0/0stateRELATED,ESTABLISHED ACCEPTicmp--0.0.0.0/00.0.0.0/0 ACCEPTall--0.0.0.0/00.0.0.0/0 ACCEPTtcp--0.0.0.0/00.0.0.0/0stateNEWtcpdpt:22 REJECTall--0.0.0.0/00.0.0.0/0reject-withicmp-host-prohibited ACCEPTtcp--0.0.0.0/00.0.0.0/0tcpdpt:80 ACCEPTtcp--0.0.0.0/00.0.0.0/0tcpdpt:3306 ACCEPTtcp--0.0.0.0/00.0.0.0/0tcpdpt:10050 ACCEPTtcp--0.0.0.0/00.0.0.0/0tcpdpt:10051 ChainFORWARD(policyACCEPT) targetprotoptsourcedestination REJECTall--0.0.0.0/00.0.0.0/0reject-withicmp-host-prohibited ChainOUTPUT(policyACCEPT) targetprotoptsourcedestination
保存iptables配置:
[root@zabbix-2~]#serviceiptablessave
重启iptables:
[root@zabbix-2~]#serviceiptablesrestart
[root@zabbix-2~]#groupadd-g201zabbix [root@zabbix-2~]#useradd-gzabbix-u201-s/sbin/nologinzabbix
5. 后台编译安装zabbix
下载zabbix-2.4.8.tar.gz包:
[root@zabbix-2~]#wgethttps://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.4.8/zabbix-2.4.8.tar.gz [root@zabbix-2~]#tar-zxvfzabbix-2.4.8.tar.gz [root@zabbix-2~]#cdzabbix-2.4.8
检查编译安装zabbix的环境:
[root@zabbix-2zabbix-2.4.8]#./configure--prefix=/usr/local/zabbix--enable-server--enable-proxy--enable-agent--with-MysqL=/usr/bin/MysqL_config--with-net-snmp--with-libcurl
如果有出现no的字样,说明确少相关的包,请通过yum安装。
编译安装zabbix:
[root@zabbix-2zabbix-2.4.8]#make&&makeinstall
6. 配置MysqL
进入MysqL:
[root@zabbix-2zabbix-2.4.8]#MysqL�Curoot
新建数据库zabbix:
MysqL>createdatabasezabbixdefaultcharsetutf8;
MysqL>grantallonzabbix.*tozabbix@localhostidentifiedby'zabbix'; MysqL>usezabbix;
导入schema.sql、images.sql、data.sql3个sql文件到zabbix数据库中:
MysqL>source/root/zabbix-2.4.8/database/MysqL/schema.sql; MysqL>source/root/zabbix-2.4.8/database/MysqL/images.sql; MysqL>source/root/zabbix-2.4.8/database/MysqL/data.sql;
查看导入的table是否存在zabbix数据库中:
MysqL>showtables; +-----------------------+ |Tables_in_zabbix| +-----------------------+ |acknowledges|| |httpstep| |httpstepitem|| |usrgrp| |valuemaps| +-----------------------+ 104rowsinset(0.00sec) MysqL>
7. 配置软连接和启动文件
[root@zabbix-2database]#mkdir/var/log/zabbix [root@zabbix-2database]#chownzabbix.zabbix/var/log/zabbix [root@zabbix-2database]#ln-s/usr/local/zabbix/etc//etc/zabbix [root@zabbix-2database]#ln-s/usr/local/zabbix/bin/*/usr/bin/ [root@zabbix-2database]#ln-s/usr/local/zabbix/sbin/*/usr/sbin/
复制目录/root/zabbix-2.4.8/misc/init.d/fedora/core/下所有以zabbix_开头的文件到目录/etc/init.d下:
[root@zabbix-2database]#cp/root/zabbix-2.4.8/misc/init.d/fedora/core/zabbix_*/etc/init.d
修改/etc/init.d/下所有以zabbix_开头的文件的权限:
[root@zabbix-2database]#chmod755/etc/init.d/zabbix_*
修改/etc/init.d目录下的zabbix_server和zabbix_agentd启动文件:
[root@zabbix-2database]#sed-i"s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g"/etc/init.d/zabbix_server [root@zabbix-2database]#sed-i"s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g"/etc/init.d/zabbix_agentd
修改/etc/zabbix/zabbix_server.conf:
[root@zabbix-2database]#sed-i"s@DBUser=root@DBUser=zabbix@g"/etc/zabbix/zabbix_server.conf [root@zabbix-2database]#sed-i"s@#DBPassword=@DBPassword=zabbix@g"/etc/zabbix/zabbix_server.conf [root@zabbix-2database]#sed-i"s@#DBPassword=@DBPassword=zabbix@g"/etc/zabbix/zabbix_server.conf
修改/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server的IP地址,即10.0.0.10
[root@zabbix-2database]#sed-i"s@Server=127.0.0.1@Server=127.0.0.1,10.0.0.10@g"/etc/zabbix/zabbix_agentd.conf [root@zabbix-2database]#sed-i"s@ServerActive=127.0.0.1@ServerActive=$IP:10051@g"/etc/zabbix/zabbix_agentd.conf [root@zabbix-2database]#sed-i"s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g"/etc/zabbix/zabbix_agentd.conf [root@zabbix-2database]#sed-i"s@^#UnsafeUserParameters=0@UnsafeUserParameters=1\n@g"/etc/zabbix/zabbix_agentd.conf
复制zabbix站点的文件到/var/www/html目录下:
[root@zabbix-2database]#cp-r/root/zabbix-2.4.8/frontends/PHP//var/www/html/zabbix/ [root@zabbix-2database]#chown-Rapache.apache/var/www/html/zabbix/
启动zabbix_server/zabbix_agentd,并设置开机启动:
[root@zabbix-2database]#servicezabbix_serverstart [root@zabbix-2database]#servicezabbix_agentdstart [root@zabbix-2database]#chkconfigzabbix_serveron [root@zabbix-2database]#chkconfigzabbix_agentdon
8. Web页面安装配置zabbix
在浏览器的url处输入 10.0.0.10/zabbix进行配置
相关的配置如下:
Databasetype:MysqL Databasehost:localhost Databaseport:3306 Databasename:zabbix User:zabbix Password:zabbix
填写完毕点击下面的Test connection按钮,正常情况下会提示OK
默认用户名:admin 密码:zabbix
通过账号登入后,出现错误:Zabbix server is not running:the information displayed may not becurrent。
处理此问题的方法:
关闭selinux
修改/etc/selinux/config文件中的SELINUX=””为disabled,然后重启。如果不想重启系统,则可以使用命令setenforce 0
原文链接:https://www.f2er.com/centos/376887.html