安裝配置Zabbix開源監控系統用於生產環境中

運行環境:

操作系統:CentOS release 6.10 (Final)

數據庫:MySQL Ver 14.14 Distrib 5.5.55

Web中間件:Apache/2.2.15 (Unix)

程序語言環境:PHP 5.4.45

軟件包:Zabbix 3.4

任務:安裝配置Zabbix,嘗試使用在生產環境中。

操作步驟:

1.安裝MySQL數據庫

# rpm -i https://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm 

2.安裝Zabbix server,Web前端,agent 

# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent 

3.創建初始數據庫

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '
password';
mysql> quit;

導入初始架構和數據,系統將提示您輸入新創建的密碼。

#zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

4.爲Zabbix server配置數據庫

編輯配置文件/etc/zabbix/zabbix_server.conf

DBPassword=password

5.爲Zabbix前端配置PHP

配置時區

[root@sky9890 conf.d]# pwd

/etc/httpd/conf.d

[root@sky9890 conf.d]# vi php.conf

php_value date.timezone Asia/Shanghai

[root@sky9890 ~]# vi /etc/php.ini

date.timezone =Asia/Shanghai 

6.啓動Zabbix server和agent進程

[root@sky9890 ~]# service zabbix-server restart

Shutting down Zabbix server:                               [確定]

Starting Zabbix server:                                    [確定]

[root@sky9890 ~]# service zabbix-agent restart

Shutting down Zabbix agent:                                [確定]

Starting Zabbix agent:   

7.配置Zabbix前端

[root@sky9890 zabbix]# pwd

/usr/share/zabbix

[root@sky9890 share]# cp –r  zabbix/   /var/www/html/

#如果前端無法訪問zabbix,將原安裝zabbix的源碼位置遷移到httpd的/var/www/html目錄下

連接到新安裝的Zabbix前端: http://server_ip_or_name/zabbix

前端配置,請訪問官網:https://www.zabbix.com/documentation/3.0/manual/installation/install#installing_frontend

 image.png

Pre-requisiteMinimum valueDescription
PHP version5.4.0
PHP memory_limit option128MBIn php.ini:
memory_limit = 128M
PHP post_max_size option16MBIn php.ini:
post_max_size = 16M
PHP upload_max_filesize option2MBIn php.ini:
upload_max_filesize = 2M
PHP max_execution_time option300 seconds (values 0 and -1 are allowed)In php.ini:
max_execution_time = 300
PHP max_input_time option300 seconds (values 0 and -1 are allowed)In php.ini:
max_input_time = 300
PHP session.auto_start optionmust be disabledIn php.ini:
session.auto_start = 0
Database supportOne of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLiteOne of the following modules must be installed:
ibm_db2, mysql, oci8, pgsql, sqlite3
bcmath
php-bcmath
mbstring
php-mbstring
PHP mbstring.func_overload optionmust be disabledIn php.ini:
mbstring.func_overload = 0
PHP always_populate_raw_post_data optionmust be disabledRequired only for PHP versions 5.6.0 or newer.
In php.ini:
always_populate_raw_post_data = -1
sockets
php-net-socket. Required for user script support.
gd2.0 or higherphp-gd. PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir).
libxml2.6.15php-xml or php5-dom
xmlwriter
php-xmlwriter
xmlreader
php-xmlreader
ctype
php-ctype
session
php-session
gettext
php-gettext
Since Zabbix 2.2.1, the PHP gettext extension is not a mandatory requirement for installing Zabbix. If gettext is not installed, the frontend will work as usual, however, the translations will not be available.

配置php.ini參數表

image.png

相關步驟按默認導航安裝即可。

配置Zabbix時要注意幾個事項:

1.配置zabbix.conf.php文件

[root@sky9890 web]# pwd

/etc/zabbix/web

[root@sky9890 web]# vi  zabbix.conf.php 

$DB['TYPE']     = 'MYSQL';

$DB['SERVER']   = 'localhost';

$DB['PORT']     = '3306';

$DB['DATABASE'] = '*****';

$DB['USER']     = '******';

$DB['PASSWORD'] = '**********';

// Schema name. Used for IBM DB2 and PostgreSQL.

$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';

$ZBX_SERVER_PORT = '10051';

$ZBX_SERVER_NAME = 'zabbix_server';

2.配置zabbix_agentd.conf和zabbix_server.conf兩個文件

[root@sky9890 zabbix]# pwd

/etc/zabbix

ServerActive=ip      #啓用服務IP

ListenIP=127.0.0.1   #啓用監控IP

3.配置防火牆

[root@sky9890 /]# cat /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT

-A OUTPUT  -p tcp -m state --state NEW -m tcp --dport 10050  -j ACCEPT

以上服務器端基本配置完成,客戶端在這裏不做說明。

4.相關Zabbix配置文檔請點擊下面鏈接:

http://blog.51cto.com/sky9896/1852873

http://blog.51cto.com/sky9896/1940105

5.運行效果圖如下:

image.png

自動監控設備運行情況

image.png

      監控Nginx

image.png

                                                                              監控IIS連接數

image.png

image.png

Zabbix功能強大於Cacti監控系統。

相對Cacti來講,Zabbix配置應用更復雜。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章