CentOS 6.5下源码编译安装Zabbix2.4.8

前端之家收集整理的这篇文章主要介绍了CentOS 6.5下源码编译安装Zabbix2.4.8前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

原文链接http://www.iyunv.com/thread-282896-1-1.html

1. 环境

CentOS版本:CentOS release 6.5 (Final)

Apache版本:Apache/2.2.15

MysqL版本:MysqL-server 5.1.73

PHP版本:PHP 5.3.3

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


修改PHP参数:

[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

4. 新建用户组和用户

[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;

zabbix数据库授权给zabbix用户

MysqL>grantallonzabbix.*tozabbix@localhostidentifiedby'zabbix';
MysqL>usezabbix;

导入schema.sqlimages.sqldata.sql3sql文件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_serverzabbix_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_serverIP地址,即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进行配置

wKioL1ld6hjgANwqAAKMZEHzgsg921.png-wh_50

wKiom1ld6legCBPMAAJUfzFds2k465.png-wh_50

相关的配置如下:

Databasetype:MysqL
Databasehost:localhost
Databaseport:3306
Databasename:zabbix
User:zabbix
Password:zabbix

填写完毕点击下面的Test connection按钮,正常情况下会提示OK

wKioL1ld6oSAvUIXAAIzAx_emJU356.png-wh_50

wKiom1ld6qegkRC6AAILIRcHEjo935.png-wh_50

wKiom1ld6ufAKJRKAAIP5cC2VPU209.png

wKiom1ld6w-TSPoSAAHCdCXmh4s110.png-wh_50

输入用户名和密码登录

默认用户名admin 密码:zabbix

wKioL1ld6zPAw8U8AAJOaxw0f4o521.png-wh_50

通过账号登入后,出现错误Zabbix server is not running:the information displayed may not becurrent

wKiom1ld63eRvl6sAAI9RgqmAWs664.png-wh_50


处理此问题的方法

关闭selinux

修改/etc/selinux/config文件中的SELINUX=””disabled,然后重启。如果不想重启系统,则可以使用命令setenforce 0

修改后刷新web页面显示正常。此时可以添加需要被监控的网络设备了!

wKiom1ld65XxXfcVAADsIUlzdZE255.png-wh_50

原文链接:https://www.f2er.com/centos/376887.html

猜你在找的CentOS相关文章