歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 6.5下Zabbix2.4.8安裝配置

CentOS 6.5下Zabbix2.4.8安裝配置

日期:2017/2/28 13:43:30   编辑:Linux教程

一、Zabbix特性簡介

Zabbix可以監控網絡和服務的監控狀況. Zabbix利用靈活的告警機制,允許用戶對事件發送基於Email的告警. 這樣可以保證快速的對問題作出相應. Zabbix可以利用存儲數據提供傑出的報告及圖形化方式. 這一特性將幫助用戶完成容量規劃。

二、本次實戰環境

名稱 主機名 ip zabbix server server134 192.168.159.134 zabbix agent server135 192.168.159.135

三、服務器安裝步驟

3.1、安裝開發軟件包及zabbix安裝所依賴的軟件包

[root@server134 ~]yum groupinstall "Development Tools"

[root@server134 ~]# yum install php-common php-odbc php-pear curl curl-devel perl-DBI php-xml ntpdate php-bcmath mysql httpd php-mysql mysql-server php php-gd ntpdate

3.2、同步服務端的時間,避免時間不同導致不可用的監控數據

[root@server134 ~]# ntpdate pool.ntp.org

8 Feb 18:41:20 ntpdate[2871]: step time server 85.199.214.100 offset 4.665038 sec

3.3、創建zabbix服務運行的用戶和組

[root@server134 ~]# groupadd -g 201 zabbix

[root@server134 ~]# useradd -g zabbix -u 201 -m zabbix

3.4、啟動mysql、創建zabbix數據庫、設置用戶密碼訪問

[root@server134 ~]# /etc/init.d/mysqld start

[root@server134 ~]# mysql -u root -p

mysql> create database zabbix character set utf8;

Query OK, 1 row affected (0.08 sec)

mysql> grant all privileges on *.* to 'zabbix'@'%' identified by 'zishang77';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

因本文使用的是mysql5.7,MySQL默認開啟了validate_password插件,進行密碼驗證,需要很強的密碼強度才能通過認證此版本對密碼的要求比較嚴格,本文做了如下調整

查閱官方文檔後發現有以下三種密碼策略:

Policy Tests Performed 0 or LOW Length 1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters 2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

mysql> select @@validate_password_policy;

+----------------------------+

| @@validate_password_policy |

+----------------------------+

| MEDIUM |

+----------------------------+

1 row in set (0.00 sec)

mysql> SHOW VARIABLES LIKE 'validate_password%';

+--------------------------------------+--------+

| Variable_name | Value |

+--------------------------------------+--------+

| validate_password_check_user_name | OFF |

| validate_password_dictionary_file | |

| validate_password_length | 8 |

| validate_password_mixed_case_count | 1 |

| validate_password_number_count | 1 |

| validate_password_policy | MEDIUM |

| validate_password_special_char_count | 1 |

+--------------------------------------+--------+

7 rows in set (0.08 sec)

mysql> set global validate_password_policy=0;#設置密碼的策略為low

Query OK, 0 rows affected (0.00 sec)


mysql> set global validate_password_mixed_case_count=0#設置指定了密碼中大小字母的長度

-> ;

Query OK, 0 rows affected (0.00 sec)


mysql> set global validate_password_number_count=2;#設置指定了密碼中數據的長度

Query OK, 0 rows affected (0.00 sec)


mysql> set global validate_password_special_char_count=0;#設置密碼中的特殊字符為0

Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=6;#設置密碼長度為6

Query OK, 0 rows affected (0.00 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'zabbix'@'%' identified by 'zabbix';

Query OK, 0 rows affected, 1 warning (0.06 sec)


3.5、安裝zabbix,並導入zabbix包中的數據到mysql的zabbix數據庫中

[root@server134 mnt]# tar zxvf zabbix-2.4.8.tar.gz

[root@server134 mnt]# cd zabbix-2.4.8

[root@server134 mnt]# cd zabbix-2.4.8

[root@server134 zabbix-2.4.8]# mysql -uzabbix -pzabbix zabbix<database/mysql/schema.sql

mysql: [Warning] Using a password on the commnd line interface can be insecure.

[root@server134 zabbix-2.4.8]# mysql -uzabbix -pzabbix zabbix<database/mysql/images.sql

mysql: [Warning] Using a password on the command line interface can be insecure.

[root@server134 zabbix-2.4.8]# mysql -uzabbix -pzabbix zabbix<database/mysql/data.sql

mysql: [Warning] Using a password on the command line interface can be insecure.

[root@server134 zabbix-2.4.8]# ./configure --sysconfdir=/etc/zabbix --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-ssh2 --enable-java


configure: error: MySQL library not found

[root@server134 zabbix-2.4.8]# yum install mysql-devel

[root@server134 zabbix-2.4.8]# make &&make install


3.6、Copy zabbixserver端跟agent端的啟動腳本,並設置執行權限

[root@server134 zabbix-2.4.8]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/

[root@server134 zabbix-2.4.8]# cp misc/init.d/tru64/zabbix_server /etc/init.d/

[root@server134 zabbix-2.4.8]# chmod +x /etc/init.d/zabbix_*

[root@server134 zabbix-2.4.8]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/

[root@server134 zabbix-2.4.8]# cp misc/init.d/tru64/zabbix_server /etc/init.d/

[root@server134 zabbix-2.4.8]# chmod +x /etc/init.d/zabbix_*

[root@server134 zabbix-2.4.8]# mkdir /var/www/html/zabbix

[root@server134 zabbix-2.4.8]# cp -a frontends/php/* /var/www/html/zabbix/

[root@server134 zabbix-2.4.8]# chown -R apache.apache /var/www/html/zabbix/


3.7、調整使用zabbix服務所需的php參數

[root@server134 zabbix-2.4.8]# vi /etc/php.ini

date.timezone = Asia/Shanghai

max_execution_time = 300

max_input_time = 300

post_max_size = 32M

memory_limit = 128M

mbstring.func_overload = 0

[root@server134 zabbix-2.4.8]# service httpd restart


3.8、調整zabbix服務所需的參數

[root@server134 ~]# vi /etc/zabbix/zabbix_server.conf

DBHost=192.168.159.134

DBName= zabbix

DBUser=zabbix

DBPassword=zabbix

DBSocket=/var/lib/mysql/mysql.sock

StartPollers=30 開啟多線程數,一般不要超過30個

StartTrappers=20 trapper線程數

StartPingers=10 fping線程數

StartDiscoverers=120

ListenIP=0.0.0.0

MaxHousekeeperDelete=5000

CacheSize=128M 用來保存監控數據的緩存數,根據監控主機的數量適當調整

StartDBSyncers=8 數據庫同步時間

HistoryCacheSize=128M

TrendCacheSize=128M 總趨勢緩存大小

HistoryTextCacheSize=128M

AlertScriptsPath=/etc/zabbix/alertscripts

LogSlowQueries=1000

[root@server134 ~]# service httpd restart

[root@server134 ~]# /etc/init.d/zabbix_server start

3.8、圖形化安裝zabbix

http://192.168.159.134/zabbix/setup.php

Copyright © Linux教程網 All Rights Reserved