1. 程式人生 > >zabbix監控服務的部署

zabbix監控服務的部署

zabbix監控服務

  • zabbix :是一個基於WEB介面的提供分散式系統監視以及網路監視功能的企業級的開源解決方案。能監控各種網路引數,保證伺服器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各種問題。

部署zabbix

  • 因為zabbix是用PHP語言開發的,所以必須先部署lamp或者lnmp架構,使其能夠支援執行php網頁。
    lamp架構的部署
zabbix服務端安裝

這裡是已經搭好lamp架構的伺服器

//安裝依賴包
[[email protected] ~]# yum -y install net-snmp-devel libevent-devel 
//下載zabbix
[
[email protected]
~]# cd /usr/src/ [[email protected] src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz [[email protected] src]# tar xf zabbix-3.4.12.tar.gz //建立zabbix使用者和組 [[email protected] ~]# groupadd -r zabbix [[email protected]
~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix //配置zabbix資料庫 [[email protected] ~]# mysql -uroot -p mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.32 sec) mysql> grant all privileges on zabbix.* to [email protected] identified by 'zabbix123!'; Query OK, 0 rows affected, 2 warnings (0.09 sec) mysql> flush privileges; Query OK, 0 rows affected (0.05 sec) mysql> quit [
[email protected]
~]# cd /usr/src/zabbix-3.4.12/database/mysql/ [[email protected] mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. [[email protected] mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. [[email protected] mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure. //編譯安裝zabbix [[email protected] ~]# cd /usr/src/zabbix-3.4.12 [[email protected] zabbix-3.4.12]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 [[email protected] zabbix-3.4.12]# make install
zabbix服務端配置
[[email protected] ~]# ls /usr/local/etc/ 
zabbix_agentd.conf    zabbix_server.conf
zabbix_agentd.conf.d  zabbix_server.conf.d
[[email protected] ~]# vim /usr/local/etc/zabbix_server.conf
DBPassword=zabbix123!  //設定zabbix資料庫連線密碼

//啟動zabbix_server和zabbix_agentd
[[email protected] ~]# zabbix_server
[[email protected] ~]# zabbix_agentd
[[email protected] ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128          *:10050                    *:*                  
LISTEN     0      128          *:10051                    *:*                  
LISTEN     0      128    127.0.0.1:9000                     *:*                  
LISTEN     0      128         :::80                      :::*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::*                  
LISTEN     0      80          :::3306                    :::* 


zabbix服務端web介面安裝與配置
zabbix web介面安裝前配置
//修改/etc/php.ini的配置並重啟php-fpm
[[email protected] ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini 
[[email protected] ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini 
[[email protected] ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini 
[[email protected] ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini 
[[email protected] ~]# service php-fpm restart 
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[[email protected] ~]# cd /usr/src/zabbix-3.4.12 
[[email protected] zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix 
[[email protected] zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[[email protected] zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs

//配置apache虛擬主機
[[email protected] ~]# vim /etc/httpd24/httpd.conf
//新增以下內容
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName zabbix.dubai.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>


// 設定zabbix/conf目錄許可權,讓zabbix有許可權生成配置檔案zabbix.conf.php 
[[email protected] ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
//重啟apache
[[email protected] ~]# apachectl -t
Syntax OK
[[email protected] ~]# apachectl restart

安裝zabbix web介面
  • 修改/etc/hosts檔案,新增域名與IP的對映
  • 在瀏覽器上訪問域名,zabbix.dubai.com
  • 恢復zabbix/conf目錄的許可權為755
    在這裡插入圖片描述
    訪問域名安裝
    在這裡插入圖片描述

在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述

登入zabbix

zabbix預設登入使用者名稱和密碼:

使用者名稱 密碼
Admin zabbix

在這裡插入圖片描述