disl 发表于 2019-1-26 08:41:20

centos6.4环境下搭建zabbix2.0.6

俺现在正在使用的nagios+cacti组合,没有考虑上zabbix,但领导要求搞搞zabbix,没办法盛情难却。只有先搞了。只是把环境搞起来了。具体使用没怎么研究。测试了添加主机各一台linux和windows,由于使用的云主机。linux还算正常,但是zabbix有个发现规则,找出了很多网卡,禁用又很麻烦。哎,废话不多说了,先搞出来再说。


一 服务端配置
1.配置前先关闭iptables和SELINUX,避免安装过程中报错。

1
2
3
4
5
6
7
8
9
# cat /etc/redhat-release
CentOS release 6.4 (Final)
# service iptables stop
iptables: Flushing firewall rules:
iptables: Setting chains to policy ACCEPT: filter
iptables: Unloading modules:
# chkconfig iptables off
# getenforce
Disabled



2.安装LAMP环境
1
# yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear



3.下载zabbix-2.0.6.tar.gz
1
root@zabbix ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz/download



4.安装zabbix所需的组件(server,agent)
1
# yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI



5.创建用户账号(server,agent)
1
# usermod -s /sbin/nologin zabbix



6.创建zabbix数据库并导入zabbix数据库(server)
1
2
3
4
5
6
7
8
9
10
#tar zxf zabbix-2.0.6.tar.gz
#mysqladmin -u root password 123456
mysql> mysql -p123456
mysql> create database zabbix;
mysql> grant all on zabbix.* to zabbix@localhost identified by '123456';
mysql> usezabbix;
mysql> source /root/zabbix-2.0.6/database/mysql/schema.sql
mysql> source /root/zabbix-2.0.6/database/mysql/images.sql
mysql> source /root/zabbix-2.0.6/database/mysql/data.sql
mysql> exit



7.编译安装,如果是客户端安装选择--enable-agent就行了。
1
2
3
4
5
6
7
8
9
10
11
12
cd/root/zabbix-2.0.6
# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
报错: checking formain in-lmysqlclient... no
configure: error: Not found mysqlclient library
解决:# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/mysql/libmysqlclient.so
***********************************************************
*            Now run 'make install'*
*                                                         *
*            Thank you forusing Zabbix!                  *
*                                  *
***********************************************************
makeinstall



8.编辑配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# grep -vE '(^#|" "|^)' /usr/local/etc/zabbix_server.conf >> /usr/local/etc/zabbix_server.conf.bak
# cp zabbix_server.conf.bak zabbix_server.conf
# grep -vE '(^#|" "|^$)' zabbix_agentd.conf >> zabbix_agentd.conf.bak
# cp zabbix_agentd.conf.bak zabbix_agentd.conf
cp: overwrite `zabbix_agentd.conf'? y
# more zabbix_server.conf #服务端的配置
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
# more zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
UnsafeUserParameters=1
# touch /var/log/zabbix_server.log
# touch /var/log/zabbix_agentd.log
# chmod 777 /var/log/zabbix_*



9.启动服务(server,agent)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# cp misc/init.d/tru64/zabbix_server /etc/init.d/
# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
# chmod +x /etc/init.d/zabbix_*
在文件头部#!/bin/bash下面分别添加两行
#!/bin/sh
#chkconfig: 35 95 95
#description:zabbix Agent server
添加服务
# chkconfig --add zabbix_server
# chkconfig --add zabbix_agentd
设置服务器开机自动启动
# chkconfig zabbix_server on
# chkconfig zabbix_agentd on
# /etc/init.d/zabbix_server start
Zabbix server started.
# /etc/init.d/zabbix_agentd start
Zabbix agent started.
# ps -ef |grep zabbix
zabbix    1803   10 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180518030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180618030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180718030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180818030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1814   10 08:21 ?      00:00:00 /usr/local/sbin/zabbix_server
root      204320060 08:23 pts/000:00:00 grepzabbix
# netstat -lantp |grep 10050
tcp      0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1803/zabbix_agentd
# netstat -lantp |grep 10051
tcp      0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      2308/zabbix_server



10.安装zabbix web界面(server)
复制php文件,zabbix的终端程序是用php写的,因此需要一个支持php脚本解析的web服务器。然后将frontends/php下面的php文件拷贝到web服务器html文件目录下面。
1
2
3
4
# cp -r frontends/php /var/www/html/zabbix
# /etc/init.d/httpd restart #启动apache服务
Stopping httpd:
Starting httpd:



11.安装图示
http://img1.运维网.com/attachment/201308/145452736.png
1
2
3
4
5
6
7
8
# vi /etc/php.ini

; Defines the default timezone used by the datefunctions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Shanghai
# /etc/init.d/httpd restart
Stopping httpd:
Starting httpd:



http://img1.运维网.com/attachment/201308/145459936.png
http://img1.运维网.com/attachment/201308/151252941.png
报错:根据提示修改/etc/php.ini文件里的参数
1
2
3
4
# yum install -y php-bcmath
# /etc/init.d/httpd restart
Stopping httpd:
Starting httpd:



http://img1.运维网.com/attachment/201308/145503878.png
http://img1.运维网.com/attachment/201308/145507661.png
http://img1.运维网.com/attachment/201308/145510623.png
http://img1.运维网.com/attachment/201308/145513137.png
http://img1.运维网.com/attachment/201308/145516441.png
http://img1.运维网.com/attachment/201308/145518891.png
搞定。。下面是改成中文,虽然翻译的不是很好,看着亲切啊。
http://img1.运维网.com/attachment/201308/145521152.png


二.WINDOWS客户端安装
1.官网上下载windows客户端zabbix

www.zabbix.com

2.拷贝到windows服务器上

解压后,如果是64位系统,则把\bin\win64\下面的三个文件拷贝到c:\zabbix目录下。如果是32位则同理
3.在c:\zabbix目录下新建zabbix_agentd.conf文件,添加以下内容
LogFile=c:\zabbix\zabbix_agentd.log #日志文件
Server=172.16.21.119 #服务端的IP
ListenIP=10.6.1.126 #客户端IP
Hostname=61 #客户端主机名
4.安装zabbix客户端

http://img1.运维网.com/attachment/201308/152320420.png
5.启动zabbix客户端
http://img1.运维网.com/attachment/201308/152322809.png
6.查看端口是否监听
http://img1.运维网.com/attachment/201308/152324240.png


三.服务端测试
1
2
# zabbix_get-s 10.6.1.126 -k agent.ping
1






测试OK

  




页: [1]
查看完整版本: centos6.4环境下搭建zabbix2.0.6