安裝zabbix2.2.3


系統版本:CentOS 6.3_x86_64

zabbix版本:zabbix-2.2.3

zabbix服務端IP:172.16.10.72

 

1.yum安裝LAMP環境

# yum -y install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstringphp-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel ja va-devel

2.配置LAMP使用環境

編輯/etc/php.ini文件,修改以下內容

date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M
mbstring.func_overload = 2

啟動httpd、mysqld服務

# chkconfig mysqld on
# chkconfig httpd on 
# service mysqld start
# service httpd start

3.下載並安裝zabbix服務端

下載頁面:http://www.zabbix.com/download.php

# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz

創建zabbix用戶

# groupadd zabbix
# useradd zabbix -g zabbix

安裝zabbix

# tar xf zabbix-2.2.3.tar.gz
# cd zabbix-2.2.3
# ./configure --prefix=/usr --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java

報錯如下:
checking for SSH2 support... no
configure: error: SSH2 library not found

解決辦法:
yum -y install libssh2-devel

上面一個報錯解決了,繼續./configure,又出現如下錯誤:
checking for LDAP support... no
configure: error: Invalid LDAP directory - unable to find ldap.h

解決辦法:
yum -y install openldap openldap-devel

# make
# make install

4.添加zabbix 到系統服務文件

# vi /etc/services(在rhel/centos系列中,下面的服務參數可以不用添加,默認已經有了)
zabbix-agent    10050/tcp               # Zabbix Agent
zabbix-agent    10050/udp               # Zabbix Agent
zabbix-trapper  10051/tcp               # Zabbix Trapper
zabbix-trapper  10051/udp               # Zabbix Trapper

5.導入zabbix數據庫

[root@zabbix zabbix-2.2.3]# mysqladmin -uroot password 'abc123,' 
[root@zabbix zabbix-2.2.3]# mysqladmin -uroot password 'abc123,'   
[root@zabbix zabbix-2.2.3]# mysql -uroot -p
mysql> create database zabbix character set utf8;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> flush privileges;

測試下連接是否正常

[root@zabbix zabbix-2.2.3]# mysql -uzabbix -pzabbix zabbix
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

導入數據庫文件

[root@zabbix zabbix-2.2.3]# mysql -uzabbix -pzabbix zabbix < ./database/mysql/schema.sql
[root@zabbix zabbix-2.2.3]# mysql -uzabbix -pzabbix zabbix < ./database/mysql/images.sql
[root@zabbix zabbix-2.2.3]# mysql -uzabbix -pzabbix zabbix < ./database/mysql/data.sql

6.創建zabbix日志目錄

# mkdir /var/log/zabbix
# chown zabbix.zabbix /var/log/zabbix

7.設置zabbix啟動腳本

[root@zabbix zabbix-2.2.3]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
[root@zabbix zabbix-2.2.3]# chmod 755 /etc/init.d/zabbix_*
[root@zabbix zabbix-2.2.3]# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#" /etc/init.d/zabbix_server
[root@zabbix zabbix-2.2.3]# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#" /etc/init.d/zabbix_agentd

8.編輯/etc/zabbix/zabbix_server.conf文件,修改以下參數

LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
StartPollers=160 (測試環境默認值即可)
StartTrappers=20 (測試環境默認值即可)
StartPingers=100 (測試環境默認值即可)
StartDiscoverers=120 (測試環境默認值即可)
MaxHousekeeperDelete=5000 (測試環境默認值即可)
CacheSize=1024M (測試環境默認值即可)
StartDBSyncers=16 (測試環境默認值即可)
HistoryCacheSize=1024M (測試環境默認值即可)
TrendCacheSize=1024M (測試環境默認值即可)
HistoryTextCacheSize=512M (測試環境默認值即可)
AlertScriptsPath=/etc/zabbix/alertscripts
LogSlowQueries=1000

修改完成后可通過以下命令進行查看:
grep -Ev "(#|^$)" /etc/zabbix/zabbix_server.conf

9.編輯/etc/zabbix/zabbix_agentd.conf文件,修改以下參數

LogFile=/var/log/zabbix/zabbix_agentd.log
EnableRemoteCommands=0
Server=127.0.0.1,172.16.10.72  #zabbix服務端IP
StartAgents=8
ServerActive=172.16.10.72:10051
Hostname=Zabbix server
Timeout=30
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1

修改完成后可通過以下命令進行查看:
grep -Ev "(#|^$)" /etc/zabbix/zabbix_agentd.conf

10.拷貝zabbix網頁文件到apache目錄

[root@zabbix zabbix-2.2.3]# cp -r ./frontends/php/ /var/www/html/zabbix
[root@zabbix zabbix-2.2.3]# chown -R apache.apache /var/www/html/zabbix

11.開啟zabbix服務

root@zabbix zabbix-2.2.3]# chkconfig zabbix_server on
[root@zabbix zabbix-2.2.3]# chkconfig zabbix_agentd on
[root@zabbix zabbix-2.2.3]# service zabbix_server start
Starting zabbix_server:                                    [  OK  ]
[root@zabbix zabbix-2.2.3]# service zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]

#查看zabbix服務是否啟動
[root@zabbix zabbix-2.2.3]# netstat -antpl|grep zabbix
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      22542/zabbix_agentd 
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      22473/zabbix_server 
tcp        0      0 :::10050                    :::*                        LISTEN      22542/zabbix_agentd 
tcp        0      0 :::10051                    :::*                        LISTEN      22473/zabbix_server

12.通過web頁面配置zabbix

# service iptables stop #暫時關閉防火牆

打開瀏覽器,訪問:http://172.16.10.72/zabbix,不出意外,會看到如下頁面

點擊next,進入下一步

到此web頁面配置完畢,已經到了登陸界面,zabbix的默認登陸賬號是admin,密碼是zabbix

登錄后發現一個報錯:zabbbix server is not  running:the information displayed may not be current

經過排查,發現是selinux惹的禍

解決辦法:關閉selinux

setenforce 0

再刷新頁面看看,已經正常

zabbix 2.2.3安裝到此結束。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM