安裝Zabbix-Server
安裝Zabbix官方源
1
2
|
rpm -ivh http: //repo .zabbix.com /zabbix/2 .4 /rhel/6/x86_64/zabbix-release-2 .4-1.el6.noarch.rpm
|
安裝zabbix服務端(這裡安裝的是2.4版本)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
yum -y install zabbix-server zabbix-server-mysql zabbix-agent zabbix-get
#修改配置檔案: vi /etc/zabbix/zabbix_server .conf
DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix #啟動zabbix /etc/init .d /zabbix-server start
/etc/init .d /zabbix-agent start
#設定開機啟動: chkconfig zabbix-server on chkconfig zabbix-agent on |
安裝php:(預設安裝的是5.3版本)
1
2
3
4
5
6
7
8
9
10
|
yum install php php-fpm
vim /etc/php .ini
post_max_size = 16M max_execution_time = 300 max_input_time = 300 date .timezone = Asia /Shanghai
/etc/init .d /php-fpm start
chkconfig php-fpm on |
安裝mysql:(預設安裝的是5.1版本)
1
2
3
4
5
|
yum install -y mysql mysql-server
chkconfig mysqld on #加入開機啟動
/etc/init .d /mysqld start #啟動mysql資料庫
|
建立zabbix的資料庫
1
2
3
4
5
6
7
8
9
10
11
12
13
|
mysqladmin -u rootpassword `mysql`
mysql -uroot –pmysql create database zabbixcharacter set utf8;
grant all on zabbix.*to zabbix@localhost identified by `zabbix` ;
flush privileges; #匯入Zabbix-Server資料庫: cd /usr/share/doc/zabbix-server-mysql-2 .4.8 /create/ mysql -uzabbix-pzabbix zabbix <schema.sql #匯入資料結構
mysql -uzabbix -pzabbix zabbix<images.sql #匯入圖片
mysql -uzabbix -pzabbix zabbix<data.sql #匯入資料
|
安裝zabbix Client
1
2
|
rpm-Uvh http: //repo .zabbix.com /zabbix/2 .4 /rhel/6/x86_64/zabbix-release-2 .4-1.el6.noarch.rpm
|
安裝zabbix agent:
1
|
yum -y install zabbix-agent zabbix-get
|
編輯配置檔案:
1
2
3
4
5
6
|
sed -i `s#Server=127.0.0.1#Server=server_ip#g` /etc/zabbix/zabbix_agentd .conf
grepServer= /etc/zabbix/zabbix_agentd .conf
啟動zabbix agent: /etc/init .d /zabbix-agent start
chkconfig zabbix-agent on |
##########################################
1
2
3
4
5
6
7
8
|
mysql安裝遇到的錯誤: /usr/bin/mysqladmin : errorwhile loading shared libraries: libmysqlclient.so.16: cannot open shared objectfile: No such file or directory
解決辦法:yum reinstallmysql-libs –y Zabbix安裝以後一直在一地步和第二步之間迴圈,無法進入第三步。 解決: mkdir /var/lib/php/session –p
chown –Rnginx.nginx /var/lib/php/session
這樣就解決了。 |
使用zabbix監控mysql資料庫:
Zabbix官方也自帶了MySQL監控模板,但是生產環境推薦使用percona的監控外掛。
1
|
https: //www .percona.com /doc/percona-monitoring-plugins/1 .1 /zabbix/index .html
|
手工新增一臺mysql資料庫的監控(agent端):
1
2
|
安裝percona倉庫: rpm-ivh http: //www .percona.com /downloads/percona-release/redhat/0 .1-3 /percona-release-0 .1-3.noarch.rpm
|
部署監控環境:
1
2
3
4
5
|
yum install zabbix22-agent php php-mysql -y
yum install percona-zabbix-templates -y #安裝監控模板
vi /etc/zabbix_agentd .conf
include= /etc/zabbix_agentd .conf.d/
#mkdir /etc/ zabbix_agentd.conf.d/ |
複製模板到該目錄下:
1
|
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql .conf /etc/zabbix_agentd .conf.d/
|
讓php可以連線到mysql上:
1
2
3
4
|
vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats .php.cnf
<?php $mysql_user= `root` ;
$mysql_pass= `password` ;
|
測試並修改監控指令碼:
1
2
|
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper .sh gg
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper .shrunning-slave
|
匯入zabbix模板:
1
2
3
|
將 /var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2 .0.9-sver1.1.6.xml
下載到本地,然後在zabbix上匯入 Configuration -> Templates-> Import |