一 服务端配置
1.配置前先关闭iptables和SELINUX,避免安装过程中报错。
[root@zabbix ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@zabbix ~]# service iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@zabbix ~]# chkconfig iptables off
[root@zabbix ~]# setenforce 0
[root@zabbix ~]# vim /etc/sysconfig/selinux
修改
SELIUNX=disabled
2.安装LAMP环境
[root@zabbix ~]# 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.2.2.tar.gz
[root@zabbix ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz
4.安装zabbix所需的组件(server,agent)
[root@zabbix ~]# yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
5.创建用户账号(server,agent)
[root@zabbix ~]# groupadd zabbix -g 201
[root@zabbix ~]# useradd -g zabbix -u 201 -m zabbix
6.创建zabbix数据库并导入zabbix数据库(server)
[root@zabbix ~]#tar zxf zabbix-2.2.2.tar.gz
[root@zabbix ~]#service mysqld start
[root@zabbix ~]#mysqladmin -u root password 123456
mysql> mysql -p123456
mysql> create database zabbix;
mysql> grant all on zabbix.* to zabbix@localhost identified by '123456';
mysql> use zabbix;
mysql> source /root/zabbix-2.2.2/database/mysql/schema.sql
mysql> source /root/zabbix-2.2.2/database/mysql/images.sql
mysql> source /root/zabbix-2.2.2/database/mysql/data.sql
mysql> exit
7.编译安装,如果是客户端安装选择--enable-agent就行了。
cd /root/zabbix-2.2.2
[root@zabbix zabbix-2.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
报错: checking for main in -lmysqlclient... no
configure: error: Not found mysqlclient library
解决:[root@zabbix zabbix-2.2.2]# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/mysql/libmysqlclient.so
报错: configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
解决:[root@zabbix zabbix-2.2.2]# yum install gcc
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
make install
8.编辑配置文件
[root@zabbix zabbix-2.2.2]# grep -vE '(^#|" "|^)' /usr/local/etc/zabbix_server.conf >> /usr/local/etc/zabbix_server.conf.bak
[root@zabbix zabbix-2.2.2]# cd /usr/local/etc
[root@zabbix etc]# cp zabbix_server.conf.bak zabbix_server.conf
#服务端的配置
[root@zabbix etc]# more zabbix_server.conf
#HOST可以写local,localhost,127.0.0.1,本例为了让不同的客户端可以访问,所以写本机IP地址
LogFile=/var/log/zabbix_server.log
DBHost=192.168.1.10
DBName=zabbix
DBUser=zabbix
DBPassword=123456
[root@zabbix etc]# more zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=192.168.1.10
UnsafeUserParameters=1
[root@zabbix etc]# touch /var/log/zabbix_server.log
[root@zabbix etc]# touch /var/log/zabbix_agentd.log
[root@zabbix etc]# chmod 777 /var/log/zabbix_*
cp /root/zabbix-2.2.2/misc/init.d/tru64/zabbix_server /etc/init.d/
cp /root/zabbix-2.2.2/misc/init.d/tru64/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_*
mkdir /var/www/html/zabbix
cp -a /root/zabbix-2.2.2/frontends/php/* /var/www/html/zabbix/
chown -R apache.apache /var/www/html/zabbix/
9.启动服务(server,agent)
[root@zabbix zabbix-2.2.2]# vim /etc/init.d/zabbix_server
[root@zabbix zabbix-2.2.2]# vim /etc/init.d/zabbix_agentd
在文件头部#!/bin/bash下面分别添加两行
#!/bin/sh
#chkconfig: 35 95 95
#description:zabbix Agent server
添加服务
[root@zabbix zabbix-2.2.2]# chkconfig --add zabbix_server
[root@zabbix zabbix-2.2.2]# chkconfig --add zabbix_agentd
设置服务器开机自动启动
[root@zabbix ~]# chkconfig zabbix_server on
[root@zabbix ~]# chkconfig zabbix_agentd on
[root@zabbix ~]# /etc/init.d/zabbix_server start
Zabbix server started.
#如果这里启动时提示libmysqlclient.so.18的错误,打开/usr/local/mysql/lib目录,将libmysqlclient.so.18软连接到/usr/lib64
#ln -s /usr/local/mysql/liblibmysqlclient.so.18 /usr/lib64/
[root@zabbix ~]# /etc/init.d/zabbix_agentd start
Zabbix agent started.
[root@zabbix ~]# ps -ef |grep zabbix
zabbix 1803 1 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1805 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1806 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1807 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1808 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1814 1 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_server
root 2043 2006 0 08:23 pts/0 00:00:00 grep zabbix
[root@zabbix ~]# netstat -lantp |grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1803/zabbix_agentd
[root@zabbix ~]# 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文件目录下面。
[root@zabbix zabbix-2.2.2]# cp -r /root/zabbix-2.2.2/frontends/php /var/www/html/zabbix
[root@zabbix html]# /etc/init.d/httpd restart #启动apache服务
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
11.浏览器栏输入127.0.0.1/zabbix
12.根据提示修改/etc/php.ini文件里的参数
[root@zabbix zabbix]# yum install -y php-bcmath
[root@zabbix zabbix]# vim /etc/php.ini
其中,时区修改为上海
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Shanghai
[root@zabbix zabbix]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
13.登陆时,用户名为admin,密码为zabbix
1.配置前先关闭iptables和SELINUX,避免安装过程中报错。
[root@zabbix ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@zabbix ~]# service iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@zabbix ~]# chkconfig iptables off
[root@zabbix ~]# setenforce 0
[root@zabbix ~]# vim /etc/sysconfig/selinux
修改
SELIUNX=disabled
2.安装LAMP环境
[root@zabbix ~]# 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.2.2.tar.gz
[root@zabbix ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz
4.安装zabbix所需的组件(server,agent)
[root@zabbix ~]# yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
5.创建用户账号(server,agent)
[root@zabbix ~]# groupadd zabbix -g 201
[root@zabbix ~]# useradd -g zabbix -u 201 -m zabbix
6.创建zabbix数据库并导入zabbix数据库(server)
[root@zabbix ~]#tar zxf zabbix-2.2.2.tar.gz
[root@zabbix ~]#service mysqld start
[root@zabbix ~]#mysqladmin -u root password 123456
mysql> mysql -p123456
mysql> create database zabbix;
mysql> grant all on zabbix.* to zabbix@localhost identified by '123456';
mysql> use zabbix;
mysql> source /root/zabbix-2.2.2/database/mysql/schema.sql
mysql> source /root/zabbix-2.2.2/database/mysql/images.sql
mysql> source /root/zabbix-2.2.2/database/mysql/data.sql
mysql> exit
7.编译安装,如果是客户端安装选择--enable-agent就行了。
cd /root/zabbix-2.2.2
[root@zabbix zabbix-2.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
报错: checking for main in -lmysqlclient... no
configure: error: Not found mysqlclient library
解决:[root@zabbix zabbix-2.2.2]# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/mysql/libmysqlclient.so
报错: configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
解决:[root@zabbix zabbix-2.2.2]# yum install gcc
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
make install
8.编辑配置文件
[root@zabbix zabbix-2.2.2]# grep -vE '(^#|" "|^)' /usr/local/etc/zabbix_server.conf >> /usr/local/etc/zabbix_server.conf.bak
[root@zabbix zabbix-2.2.2]# cd /usr/local/etc
[root@zabbix etc]# cp zabbix_server.conf.bak zabbix_server.conf
#服务端的配置
[root@zabbix etc]# more zabbix_server.conf
#HOST可以写local,localhost,127.0.0.1,本例为了让不同的客户端可以访问,所以写本机IP地址
LogFile=/var/log/zabbix_server.log
DBHost=192.168.1.10
DBName=zabbix
DBUser=zabbix
DBPassword=123456
[root@zabbix etc]# more zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=192.168.1.10
UnsafeUserParameters=1
[root@zabbix etc]# touch /var/log/zabbix_server.log
[root@zabbix etc]# touch /var/log/zabbix_agentd.log
[root@zabbix etc]# chmod 777 /var/log/zabbix_*
cp /root/zabbix-2.2.2/misc/init.d/tru64/zabbix_server /etc/init.d/
cp /root/zabbix-2.2.2/misc/init.d/tru64/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_*
mkdir /var/www/html/zabbix
cp -a /root/zabbix-2.2.2/frontends/php/* /var/www/html/zabbix/
chown -R apache.apache /var/www/html/zabbix/
9.启动服务(server,agent)
[root@zabbix zabbix-2.2.2]# vim /etc/init.d/zabbix_server
[root@zabbix zabbix-2.2.2]# vim /etc/init.d/zabbix_agentd
在文件头部#!/bin/bash下面分别添加两行
#!/bin/sh
#chkconfig: 35 95 95
#description:zabbix Agent server
添加服务
[root@zabbix zabbix-2.2.2]# chkconfig --add zabbix_server
[root@zabbix zabbix-2.2.2]# chkconfig --add zabbix_agentd
设置服务器开机自动启动
[root@zabbix ~]# chkconfig zabbix_server on
[root@zabbix ~]# chkconfig zabbix_agentd on
[root@zabbix ~]# /etc/init.d/zabbix_server start
Zabbix server started.
#如果这里启动时提示libmysqlclient.so.18的错误,打开/usr/local/mysql/lib目录,将libmysqlclient.so.18软连接到/usr/lib64
#ln -s /usr/local/mysql/liblibmysqlclient.so.18 /usr/lib64/
[root@zabbix ~]# /etc/init.d/zabbix_agentd start
Zabbix agent started.
[root@zabbix ~]# ps -ef |grep zabbix
zabbix 1803 1 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1805 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1806 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1807 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1808 1803 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_agentd
zabbix 1814 1 0 08:21 ? 00:00:00 /usr/local/sbin/zabbix_server
root 2043 2006 0 08:23 pts/0 00:00:00 grep zabbix
[root@zabbix ~]# netstat -lantp |grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1803/zabbix_agentd
[root@zabbix ~]# 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文件目录下面。
[root@zabbix zabbix-2.2.2]# cp -r /root/zabbix-2.2.2/frontends/php /var/www/html/zabbix
[root@zabbix html]# /etc/init.d/httpd restart #启动apache服务
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
11.浏览器栏输入127.0.0.1/zabbix
12.根据提示修改/etc/php.ini文件里的参数
[root@zabbix zabbix]# yum install -y php-bcmath
[root@zabbix zabbix]# vim /etc/php.ini
其中,时区修改为上海
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Shanghai
[root@zabbix zabbix]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
13.登陆时,用户名为admin,密码为zabbix