一、zabbix安装环境
zabbix的安装配置是个较繁杂的过程,它是基于lamp或lnmp,只不过之前装的lamp架构可能无法满足zabbix的需求,比如某些php的扩展,所以我建议重装php。
1、查看linux的版本信息
[root@test1 tmp]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.5 (Santiago)
Release: 6.5
Codename: Santiago
2、mysql的版本信息
mysql> select version();
+------------+
| version() |
+------------+
| 5.5.35-log |
+------------+
1 row in set (0.00 sec)
3、PHP版本信息
[root@test1 tmp]# php -v
PHP 5.3.3 (cli) (built: Aug 19 2013 05:50:20)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
4、Apache版本信息
[root@test1 tmp]# /usr/local/apache2/bin/httpd -v
Server version: Apache/2.2.23 (Unix)
Server built: Dec 20 2014 09:51:23
二、zabbix 服务端的安装
1、下载zabbix的源码包并解压、本次安装版本为2.2.6
[root@localhost softs]# tar -zxvf zabbix-2.2.6.tar.gz
[root@localhost src]# cd zabbix-2.2.6/
2、建立相应的用户组与用户
[root@localhost zabbix-2.2.6]# groupadd -r zabbix
[root@localhost zabbix-2.2.6]# useradd -g zabbix -s /sbin/nologin zabbix
3、登录mysql ,创建zabbix用户并授权
[root@localhost zabbix-2.2.6]# mysql -u root -p******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4773
Server version: 5.6.10-debug-log Source distribution
…………
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix; ###新建zabbix数据库
Query OK, 1 row affected (0.01 sec)
mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix'; ###创建zabbix用户
Query OK, 0 rows affected (0.16 sec)
mysql> flush privileges; #刷新授权表及时生效
Query OK, 0 rows affected (0.00 sec)
4、导入zabbix自带的几个sql脚本
[root@localhost ~]# cd /home/zabbix/zabbix-2.2.6
[root@localhost zabbix-2.2.6]# cd database/
[root@localhost database]# ls
ibm_db2 Makefile.in oracle sqlite3
Makefile.am mysql postgresql
[root@localhost database]# cd mysql/
[root@localhost mysql]# ls
data.sql images.sql schema.sql
[root@localhost mysql]# mysql -u root -p123456 zabbix < schema.sql
[root@localhost mysql]# mysql -u root -p123456 zabbix < images.sql
[root@localhost mysql]# mysql -u root -p123456 zabbix < data.sql
5、安装几个需要的软件包
[root@localhost zabbix-2.2.6]# yum install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath php-mysql -y
6、查看php的所有的modules,看是否包括了安装zabbix所需要的bcmath ,mbstring ,sockets, gd ,gd PNG support ,gd JPEG support ,gd FreeType support ,libxml,xmlwriter, xmlreader ,ctype , session ,gettext这些模块
[root@localhost zabbix-2.2.6]# php -m ###查看已经支持的php模块
[root@test1 zabbix-2.2.6]# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
ldap
libxml
mbstring
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib
[Zend Modules]
注意:包必须安装全,否则最后配置zabbix时有问题
7、安装、配置zabbix
[root@localhost ~]# cd /home/zabbix/zabbix-2.2.6
[root@localhost zabbix-2.2.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl
[root@localhost zabbix-2.2.6]# make
[root@localhost zabbix-2.2.6]# make install
修改/etc/services,添加下面几行
zabbix-agent 10050/tcp #zabbix agent
zabbix-agent 10050/udp #zabbix agent
zabbix-trapper 10051/tcp #zabbix trapper
zabbix-trapper 10051/udp #zabbix trapper
修改zabbix的配置文件
[root@localhost zabbix-2.2.6]# vi /usr/local/zabbix/etc/zabbix_server.conf
[root@localhost zabbix-2.2.6]# cat /usr/local/zabbix/etc/zabbix_server.conf | grep -v ^# | grep -v ^$
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/run/mysqld/mysql5.socket
做几个软连接
[root@localhost ~]# ln -s /usr/local/zabbix/bin/* /usr/bin/
[root@localhost ~]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
[root@localhost ~]# cd /usr/src/zabbix-2.2.6/
[root@localhost ~]# cp /usr/src/zabbix-2.2.6/misc/init.d/fedora/core/* /etc/init.d/
[root@localhost ~]# vi /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix ##########修改这行
[root@localhost ~]# vi /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix ##########修改这行
[root@localhost frontends]# cp /home/zabbix/zabbix-2.2.6/frontends /var/www/zabbix/ -r
[root@localhost frontends]# chown zabbix.zabbix /var/zabbix/ -R
[root@localhost frontends]# chown 777 /var/www/zabbix/conf
8、新建虚拟主机
[root@localhost ~]# cd /usr/local/apache2/conf/extra/
[root@localhost extra]# vi httpd-vhosts.conf
修改apache的主配置文件,开启8008端口
[root@localhost conf]# vi /usr/local/apache2/conf/httpd.conf
#Listen 12.34.56.78:80
Listen 80
Listen 8008
然后重启apache的服务
[root@localhost ~]# /etc/init.d/apache restart
[root@localhost conf]# lsof -i:8008
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 1814 root 8w IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2887 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2888 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2889 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2890 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2891 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
httpd 2892 daemon 8u IPv6 107091 0t0 TCP *:8008 (LISTEN)
9、启动zabbix服务
[root@localhost lib]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd: [ OK ]
[root@localhost lib]# /etc/init.d/zabbix_server start
Starting zabbix_server: /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[FAILED]
解决方法
[root@localhost ~]# locate libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18.0.0
/usr/src/mysql-5.6.10/libmysql/libmysqlclient.so.18
/usr/src/mysql-5.6.10/libmysql/libmysqlclient.so.18.0.0
[root@localhost ~]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
[root@localhost ~]# ldconfig
[root@localhost lib]# /etc/init.d/zabbix_server start
Starting zabbix_server: [ OK ]
[root@localhost lib]# /etc/init.d/snmpd restart
Stopping snmpd: [FAILED]
Starting snmpd: [ OK ]
[root@localhost ~]# /etc/init.d/mysql5 restart
Shutting down MySQL.. [ OK ]
Starting MySQL... [ OK ]
[root@localhost ~]# /etc/init.d/apache restart
三、页面配置zabbix
1、打开浏览器访问页面http://127.0.0.1:8008
2、zabbix检查zabbix的php环境
可以看到php的配置有些问题,所以需要改php的配置文件
[root@localhost ~]# vi /usr/local/lib/php.ini
将对应的配置文件改成zabbix所需要的参数值
memory_limit = 128M
max_execution_time = 300
max_input_time = 300
date.timezone =Asia/Shanghai
重启apache服务
[root@localhost lib]# /etc/init.d/apache restart
3、然后再次刷新浏览器页面,重新查看php的环境,然后下一步
4、填写对应的数据库信息,然后next
5、zabbix的ip、端口以及主机名的设置
6、配置信息预览
7、安装
8、登录 默认用户名admin密码zabbix
9、登录的页面信息
10、发现有个错误
然后查证后是iptables的问题,所以建议先关闭iptables
四、linux zaibbix客户端的安装
1、下载客户端软件
[root@localhost soft]# wget http://www.zabbix.com/downloads/2.2.0/zabbix_agents_2.2.0.linux2_6.amd64.tar.gz
下载时候需要注意查看客户机的内核信息,从官网选择相应的软件包
2、客户端的相关设置
[root@localhost soft]# tar xf zabbix_agents_2.2.0.linux2_6.amd64.tar.gz ###解压
[root@localhost soft]# mkdir /etc/zabbix/
[root@localhost soft]# mv bin/zabbix_get /usr/bin/
[root@localhost soft]# mv bin/zabbix_sender /usr/bin/
[root@localhost soft]# mv sbin/zabbix_agent /usr/bin/
[root@localhost soft]# mv sbin/zabbix_agentd /usr/bin/
[root@localhost soft]# cd conf/
[root@localhost conf]# mv zabbix_agentd.conf /etc/zabbix/
3、修改zabbix_agentd.conf
Hostname=zabbix-client1 ###这里的hostname要与客户端的hostname一致,而且与监控主机中的名字一致!!
ServerActive=192.168.254.153 ####zabbix server的ip
Server=192.168.254.153####zabbix server的ip
[root@localhost zabbix-2.2.0]# groupadd -r zabbix
[root@localhost zabbix-2.2.0]# useradd -g zabbix -s /sbin/nologin zabbix
4、启动客户端进程
[root@localhost conf]# zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf ####指定配置文件启动
[root@localhost conf]# ps -ef | grep zabbix ####查看是否启动
zabbix 1474 1 0 17:20 ? 00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 1475 1474 0 17:20 ? 00:00:00 zabbix_agentd: collector [idle 1 sec]
zabbix 1476 1474 0 17:20 ? 00:00:00 zabbix_agentd: listener #1 [waiting for connection]
zabbix 1477 1474 0 17:20 ? 00:00:00 zabbix_agentd: listener #2 [waiting for connection]
zabbix 1478 1474 0 17:20 ? 00:00:00 zabbix_agentd: listener #3 [waiting for connection]
zabbix 1479 1474 0 17:20 ? 00:00:00 zabbix_agentd: active checks #1 [idle 1 sec]
root 1488 1374 0 17:28 pts/0 00:00:00 grep zabbix
[root@localhost tmp]# lsof -i:10050 #####查看开启侦听的端口
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
zabbix_ag 9106 zabbix 4u IPv4 277432 0t0 TCP *:zabbix-agent (LISTEN)
zabbix_ag 9107 zabbix 4u IPv4 277432 0t0 TCP *:zabbix-agent (LISTEN)
zabbix_ag 9108 zabbix 4u IPv4 277432 0t0 TCP *:zabbix-agent (LISTEN)
zabbix_ag 9109 zabbix 4u IPv4 277432 0t0 TCP *:zabbix-agent (LISTEN)
zabbix_ag 9110 zabbix 4u IPv4 277432 0t0 TCP *:zabbix-agent (LISTEN)
zabbix_ag 9111 zabbix 4u IPv4 277432 0t0 TCP *:zabbix-agent (LISTEN)
5、配置 server页面
Configuration -----> Hosts ------->Create host
From:http://blog.csdn.net/avilifans/article/details/16800307