1. 程式人生 > >Zabbi監控系統搭建

Zabbi監控系統搭建

ica ice type fine 連接 cal utf8 ger itl

1.安裝Zabbix

①從官網下載對應版本的zabbixrpm包

[root@localhost src]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
--2018-02-01 09:52:56--  http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
正在解析主機 repo.zabbix.com (repo.zabbix.com)... 162.243.159.138
正在連接 repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:13392 (13K) [application/x-redhat-package-manager]
正在保存至: “zabbix-release-3.2-1.el7.noarch.rpm”

100%[=======================================>] 13,392      --.-K/s 用時 0.02s

2018-02-01 09:52:56 (546 KB/s) - 已保存 “zabbix-release-3.2-1.el7.noarch.rpm” [13392/13392])

②此步驟為rpm安裝zabbix的repo源,安裝完成後可以在/etc/yum.repos.d文件夾下看到zabbix.repo的庫

[root@localhost src]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
警告:zabbix-release-3.2-1.el7.noarch.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY
準備中...                          ################################# [100%]
正在升級/安裝...
   1:zabbix-release-3.2-1.el7         ################################# [100%]
[root@localhost src]# ls //etc/yum.repos.d
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo  zabbix.repo
CentOS-CR.repo         CentOS-Media.repo      epel.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo    epel-testing.repo

③安裝zabbix服務器、agent、web支持等組件

[root@localhost src]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql

2.zabbix的初始配置

①編輯mysql配置文件/etc/my.cnf增加如下配置語句

character_set_server = utf8

②進入mysql數據庫,新建zabbix數據庫,並將字符集設置為utf8

mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)

③新建zabbix使用的用戶,並設置密碼

mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbix';
Query OK, 0 rows affected (0.01 sec)

④將zabbix的數據庫文件導入新建的數據庫中

[root@localhost src]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@localhost zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[root@localhost zabbix-server-mysql-3.2.11]# mysql -uroot zabbix < create.sql

⑤啟動httpd服務(yum安裝zabbix的時候會自動安裝上httpd與php)

[root@localhost zabbix-server-mysql-3.2.11]# systemctl start httpd; systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

⑥編輯配置文件/etc/zabbix/zabbix_server.conf,加入如下內容

DBHost=127.0.0.1 
DBPassword=zabbix

⑦啟動zabbix服務,並將zabbix服務加入啟動列表

[root@localhost zabbix-server-mysql-3.2.11]# systemctl start zabbix-server
[root@localhost zabbix-server-mysql-3.2.11]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@localhost zabbix-server-mysql-3.2.11]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      914/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      917/cupsd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1206/master
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      11734/zabbix_server
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
tcp6       0      0 :::80                   :::*                    LISTEN      11641/httpd
tcp6       0      0 :::22                   :::*                    LISTEN      914/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      917/cupsd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1206/master
tcp6       0      0 :::10051                :::*                    LISTEN      11734/zabbix_server
tcp6       0      0 :::3306                 :::*                    LISTEN      10419/mysqld

⑧編輯php的配置文件/etc/php.ini修改時區,將date.timezone的值修改為Asia/Shanghai。

修改完成後重新啟動httpd服務

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai

⑨安裝完成後在瀏覽器訪問http://ip/zabbix完成web端的初始化配置後即可登錄管理,默認賬戶admin,密碼zabbix

技術分享圖片

3.Zabbix客戶端安裝(Linux客戶端)

①與zabbix服務器一樣,顯配置好repos源後,yum安裝zabbix-agent

[root@test03 ~]# yum install -y zabbix-agent

②編輯客戶端的配置文件/etc/zabbix/zabbix_agentd.conf 修改指定的服務器信息

Server=172.23.1.200              //指定服務器地址(被動模式)
ServerActive=172.23.1.200        //指定服務器地址(主動模式)
Hostname=Zabbix-agent-test03     //指定主機名(需要同web設置一致)

③啟動zabbix-agent服務

[root@test03 ~]# systemctl start zabbix-agent
[root@test03 ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

4.Zabbix客戶端安裝(Windows客戶端安裝)

①在C盤新建zabbix文件夾,從官網下載對應版本的zabbix_agent

②將zabbix_agents_3.2.7.win\conf\zabbix_agentd.win.conf以及

zabbix_agents_3.2.7.win\bin\win64文件夾內的zabbix_agentd.exe、zabbix_get.exe、zabbix_sender.exe拷貝至c:\zabbix下

③修改conf文件內容如下

Server=172.23.1.200              //指定服務器地址(被動模式)
ServerActive=172.23.1.200        //指定服務器地址(主動模式)
Hostname=zhou-PC                 //指定主機名(需要同web設置一致)

④以管理員權限運行cmd,切換至C:\目錄下之後執行如下命令。顯示successfully則表示zabbix-agent服務安裝啟動完成。

c:\zabbix>zabbix_agentd.exe -c c:\zabbix\zabbix_agentd.win.conf -i
zabbix_agentd.exe [7420]: service [Zabbix Agent] installed successfully
zabbix_agentd.exe [7420]: event source [Zabbix Agent] installed successfully

c:\zabbix>zabbix_agentd.exe -c c:\zabbix\zabbix_agentd.win.conf -s
zabbix_agentd.exe [6164]: service [Zabbix Agent] started successfully


Zabbi監控系統搭建