zabbix 服務(wù)器
安裝Mysql數(shù)據(jù)庫、Apache、PHP、PHP擴(kuò)展、curl組件
rpm -qa | grep epel-release && yum remove epel-release -y
yum install mysql* httpd* php* php-gd php-bcmath php-common php-xml php-mbstring curl curl-devel -y
安裝YUM源
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
安裝zabbix服務(wù)器專用依賴組件
yum install OpenIPMI* ipmitool* libssh2* fping* libcurl* iksemel* net-snmp* -y
關(guān)閉SELINUX
設(shè)置:SELINUX=disabled
sed -r -i '/^[ \t]*SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
重啟生效(不重啟mysql可能啟動失?。?/p>
配置:Apache、Mysql
配置:Apache
test -f /etc/httpd/conf/httpd.conf.bak || \cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
sed -r -i '/(^[ \t]*#|^[ \t]*$)/d' /etc/httpd/conf/httpd.conf
grep -E "^[ \t]*ServerName " /etc/httpd/conf/httpd.conf && y="1" || y="0"
if [ ${y} = "1" ]; then
sed -r -i '/^[ \t]*ServerName[ \t]*.*/c ServerName '"${HOSTNAME}"':9000' /etc/httpd/conf/httpd.conf
else
sed -r -i "1i ServerName "${HOSTNAME}":9000" /etc/httpd/conf/httpd.conf
fi
cat /etc/httpd/conf/httpd.conf
chkconfig httpd on
service httpd restart
配置IPtables
service iptables restart
iptables -D INPUT -p tcp --dport 9000 -j ACCEPT
iptables -I INPUT -p tcp --dport 9000 -j ACCEPT
service iptables save
iptables -L
配置:MySQL
mkdir -p /zabbix/mysqldb
vi /etc/my.cnf
設(shè)置:
datadir=/zabbix/mysqldb
max_connections=1000
關(guān)閉mysql
service mysqld stop
mysql_install_db
初始化啟動Mysql數(shù)據(jù)庫
chkconfig mysqld on
service mysqld start
設(shè)置MySQL的root管理員賬戶的密碼
mysqladmin -u root password 'a123456'
創(chuàng)建zabbix數(shù)據(jù)庫
mysql -u root -p
mysql> show variables like '%datadir%';
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'a123456';
mysql> FLUSH PRIVILEGES;
mysql> quit
安裝zabbix中心服務(wù)器組件
Yum安裝
yum install zabbix-server-mysql zabbix-web-mysql -y
zabbix_server -V
Zabbix server v2.4.8 (revision 59539) (20 April 2016)
Compilation time: May 4 2016 01:32:12
為zabbix中心服務(wù)器創(chuàng)建:數(shù)據(jù)庫架構(gòu)和表結(jié)構(gòu)
find / -name zabbix-server-mysql\*
mysql -u zabbix --password=a123456 -D zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
mysql -u zabbix --password=a123456 -D zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
mysql -u zabbix --password=a123456 -D zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
mysql -u zabbix --password=a123456 -D zabbix
mysql> select database();
mysql> show tables;
修改配置文件
test -f /etc/zabbix/zabbix_server.conf.bak || cp -f /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak
cat >/etc/zabbix/zabbix_server.conf<<EOF
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBPort=3306
DBName=zabbix
DBUser=zabbix
DBPassword=a123456
ListenPort=10051
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
## 如果需要監(jiān)控VMware ESXi服務(wù)器平臺,就需要添加以下參數(shù)
StartVMwareCollectors=10
VMwareFrequency=60
VMwarePerfFrequency=60
VMwareCacheSize=80M
VMwareTimeout=10
## 配置<查詢信息>和<接收信息>的進(jìn)程數(shù)
StartPollers=200
StartTrappers=200
EOF
啟動:zabbix-server服務(wù)
chkconfig zabbix-server on
service zabbix-server start
netstat -tunlp | grep zabbix
配置:zabbix的Web前端
cat >/etc/httpd/conf.d/zabbix.conf<<EOF
# Zabbix monitoring system php web frontend
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
## 設(shè)置:時(shí)區(qū)的設(shè)置,必須啟用,注意:區(qū)分大小寫
php_value date.timezone Asia/Shanghai
</Directory>
<Directory "/usr/share/zabbix/conf">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/api">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/include">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/include/classes">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
EOF
重啟啟動:Apache的httpd服務(wù)
service httpd restart
訪問:zabbix的Web安裝頁面
http://zabbix.one.com/zabbix
配置自動探索和自動注冊

Paste_Image.png
自動探索配置

Paste_Image.png

Paste_Image.png

Paste_Image.png

Paste_Image.png
自動注冊
安裝zabbix-agent
下載并安裝:zabbix的yum源,然后,yum安裝zabbix-agent客戶端代理
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum install -y zabbix-agent
test -f /etc/zabbix/zabbix_agentd.conf.bak || cp -f /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak
sed -r -i '/(^[ \t]*#|^[ \t]*$)/d' /etc/zabbix/zabbix_agentd.conf
zabbix_server_ip="192.168.30.11"
zabbix_server_hostname=${HOSTNAME}
cat >/etc/zabbix/zabbix_agentd.conf<<EOF
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=${zabbix_server_ip}
ServerActive=${zabbix_server_ip}:10051
Hostname=${zabbix_server_hostname}
ListenPort=10050
HostMetadata=all
Include=/etc/zabbix/zabbix_agentd.d/
EOF
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
service iptables save
service iptables restart
修改客戶機(jī)配置文件
test -f /etc/zabbix/zabbix_agentd.conf.bak || cp -f /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak
sed -r -i '/(^[ \t]*#|^[ \t]*$)/d' /etc/zabbix/zabbix_agentd.conf
zabbix_server_ip="192.168.30.11"
zabbix_server_hostname=${HOSTNAME}
cat >/etc/zabbix/zabbix_agentd.conf<<EOF
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=${zabbix_server_ip}
ServerActive=${zabbix_server_ip}:10051
Hostname=${zabbix_server_hostname}
ListenPort=10050
HostMetadata=all
Include=/etc/zabbix/zabbix_agentd.d/
EOF
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
service iptables save
service iptables restart