@AchEng
zabbix簡介前言
常見開源的的監控系統有zabbix ,nagios ,cacti。
nagios的簡單介紹
1,重在監控告警,在這一方面zabbix比他更優秀,告警配置可視化,web化
2,nagios添加監控需要更改配置文件。
3,沒有監控的歷史數據,圖形支持差,也就是說只是知道報警,但是沒有記錄原因
4,不支持分布時候監控系統。
比如:不支持分布式部署
Cacti的簡單介紹
1,重在采集服務器。網路設備的監控數據並繪圖
2,依賴於snmp協議
3,不好自定義監控
4,告警支持不友好
zabbix的簡單介紹
1,所有監控配置都web化,web采用php開發
2,支持分布式監控
3,支持多種方式數據采集:簡單監控,agent監控,snmp接口,jmx接口監控
4,告警配置web化:郵件,微信,釘釘,短信
5,zaabix和grafana的結合方便監控數據的可視化
比如:支持
zabbix監控的搭建簡單理論
1,zabbix server會去采集監控數據,采集的監控數據會寫入到sql數據庫
2,zabbix的web后端采用的php語言開發,所有的配置信息,用戶認證等都會寫入到sql數據庫。
3,企業級zabbix的搭建依賴環境:主流采用LNMP(centos7+nginx+mysql+php)
4,環境下用戶請求流程
用戶->nginx—>php-fpm->運行php程序->操作mysql
zabbix工作原理圖

zabbix 由以下幾個組件部分構成:
>1) Zabbix Server:負責接收 agent 發送的報告信息的核心組件,所有配置,統計數據及操作數據均由其組織進行;--->2) Database Storage:專用於存儲所有配置信息,以及由 zabbix 收集的數據;--->3) Web interface:zabbix 的 GUI 接口,通常與 Server 運行在同一台主機上;--->4) Proxy:可選組件,常用於分布監控環境中,代理 Server 收集部分被監控端的監控數據並統一發往 Server 端;--->5) Agent:部署在被監控主機上,負責收集本地數據並發往 Server 端或 Proxy 端;注:zabbix node 也是 zabbix server 的一種 。--->進程默認情況下zabbix包含5個程序: zabbix_agentd、 zabbix_get、 zabbix_proxy、zabbix_sender、zabbix_server,另外一個 zabbix_java_gateway 是可選,這個需要另外安裝---下面來分別介紹下他們各自的作用:abbix_agentd客戶端守護進程,此進程收集客戶端數據,例如 cpu 負載、內存、硬盤使用情況等。--->zabbix_getzabbix 工具,單獨使用的命令,通常在 server 或者proxy端執行獲取遠程客戶端信息的命令。 通常用戶排錯。 例如在server端獲取不到客戶端的內存數據, 我們可以使用zabbix_get獲取客戶端的內容的方式來做故障排查。--->zabbix_senderzabbix 工具,用於發送數據給 server 或者proxy,通常用於耗時比較長的檢查。很多檢查非常耗時間,導致 zabbix 超時。於是我們在腳本執行完畢之后,使用 sender 主動提交數據。--->zabbix_serverzabbix 服務端守護進程。zabbix_agentd、zabbix_get、zabbix_sender、zabbix_proxy、zabbix_java_gateway 的數據最終都是提交到 server備注:當然不是數據都是主動提交給 zabbix_server,也有的是 server 主動去取數據。--->zabbix_proxyzabbix 代理守護進程。功能類似server,唯一不同的是它只是一個中轉站,它需要把收集到的數據提交/被提交到 server 里。--->zabbix_java_gatewayzabbix2.0 之后引入的一個功能。顧名思義:Java 網關,類似 agentd,但是只用於Java方面。需要特別注意的是,它只能主動去獲取數據,而不能被動獲取數據。 它的數據最終會給到server或者proxy。---
zabbix監控環境中相關術語
#主機(host) :要監控的網絡設備,可由 IP 或 DNS 名稱指定;---#主機組(host group):主機的邏輯容器,可以包含主機和模板,但同一個組織內的主機和模板不能互相鏈接;主機組通常在給用戶或用戶組指派監控權限時使用;---#監控項(item) :一個特定監控指標的相關的數據;這些數據來自於被監控對象;item是 zabbix 進行數據收集的核心,相對某個監控對象,每個 item 都由"key"標識;---#觸發器(trigger) :一個表達式,用於評估某監控對象的特定 item 內接收到的數據是否在合理范圍內,也就是閾值;接收的數據量大於閾值時,觸發器狀態將從"OK"轉變為"Problem",當數據再次恢復到合理范圍,又轉變為"OK";---#事件(event) :觸發一個值得關注的事情,比如觸發器狀態轉變,新的 agent 或重新上線的 agent 的自動注冊等;---#動作(action) :指對於特定事件事先定義的處理方法,如發送通知,何時執行操作;---#報警媒介類型(media) :發送通知的手段或者通道,如 Email、Jabber 或者 SMS 等;---#模板 (template) :用於快速定義被監控主機的預設條目集合, 通常包含了 item、 trigger、graph、screen、 application 以及 low-level discovery rule;模板可以直接鏈接至某個主機;---#前端(frontend) :Zabbix 的 web 接口
zabbix各種相關組件關系圖

一搭建zabbix
1搭建環境
| 操作系統 | 主機名 | ip | 內存 |
|---|---|---|---|
| centos7.5 | zabbix | 192.168.200.173 | 1G |
1.1搭建nginx
[root@zabbix ~]# cat /etc/redhat-releaseCentOS Linux release 7.5.1804 (Core)[root@zabbix ~]# setenforce 0setenforce: SELinux is disabled[root@zabbix ~]# systemctl stop firewalld[root@zabbix ~]# systemctl stop NetworkManager[root@zabbix ~]# lsanaconda-ks.cfg nginx-1.16.1.tar.gz[root@zabbix ~]# yum install -y wget gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel#安裝支持程序我們源碼編譯[root@zabbix ~]# tar xf nginx-1.16.1.tar.gz -C /usr/src/[root@zabbix ~]# cd /usr/src/nginx-1.16.1/[root@zabbix nginx-1.16.1]# lsauto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src[root@zabbix nginx-1.16.1]# ./configure --prefix=/usr/local/nginx && make && make install#編譯安裝[root@zabbix nginx-1.16.1]# ln -s /usr/local/nginx/sbin/* /usr/bin/ #將命令鏈接出來[root@zabbix nginx-1.16.1]#which nginx#查看有了nginx的命令/usr/bin/nginx[root@zabbix nginx-1.16.1]# cd /usr/local/nginx/conf/[root@zabbix conf]# lsfastcgi.conf fastcgi_params.default mime.types nginx.conf.default uwsgi_paramsfastcgi.conf.default koi-utf mime.types.default scgi_params uwsgi_params.defaultfastcgi_params koi-win nginx.conf scgi_params.default win-utf[root@zabbix conf]# egrep -v "#|^$" nginx.conf.default > nginx.conf#精簡配置文件[root@zabbix conf]# cat nginx.confworker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 80;server_name localhost;location / {root html;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}}[root@zabbix conf]# nginx -t#檢測一下配置文件有沒有語法錯誤nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@zabbix conf]# /usr/local/nginx/sbin/nginx#啟動nginx[root@zabbix conf]# ss -antup | grep 80tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=18266,fd=6),("nginx",pid=18265,fd=6))#查看下nginx的端口有沒有開#使用systemctl管理nginx[root@zabbix conf]# vim /usr/lib/systemd/system/nginx.service[Unit] #這個模塊主要是對服務的描述Description=nginx #描述服務是什么After=network.target # 描述服務的類別[Service] #是服務的具體運行參數Type=forking #后台運行的形式ExecStart=/usr/local/nginx/sbin/nginx #啟動命令[Install] #服務安裝的相關設置WantedBy=multi-user.target#測試一下啊systemctl管理(如果這里有問題,請重啟下服務器就可以了)[root@zabbix conf]# ss -antup | grep 80tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1213,fd=6),("nginx",pid=1212,fd=6))[root@zabbix conf]# systemctl stop nginx[root@zabbix conf]# ss -antup | grep 80[root@zabbix conf]##開啟[root@zabbix conf]# systemctl start nginx[root@zabbix conf]# ss -antup | grep 80tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1249,fd=6),("nginx",pid=1248,fd=6))
1.2關於systemctl管理服務參數說明
- [Service]部分是服務的關鍵,是服務的一些具體運行參數的設置
- Type=forking是后台運行的形式,
- PIDFile為存放PID的文件路徑,
- ExecStart為服務的運行命令,
- ExecReload為重啟命令,
- ExecStop為停止命令,
- rivateTmp=True表示給服務分配獨立的臨時空間,
*注意:[Service]部分的啟動、重啟、停止命令全部要求使用絕對路徑,使用相對路徑則會報錯;
1.3在瀏覽器上驗證下nginx

二搭建php
php和nginx結合使用是有2中方式的,
1是socket方式(這個方式需要兩個服務在同一個服務器上)
2是網絡方式,這樣的可以不在同一個服務其上 (默認是網絡)
2.1編譯安裝php
[root@zabbix conf]# cd ~[root@zabbix ~]# wget http://hk1.php.net/distributions/php-5.6.40.tar.gz #現在5.64安裝包[root@zabbix ~]# yum -y install epel-release #用yum安裝一個epel源,這個文件是擴展的一些服務的源[root@zabbix ~]# yum -y clean all[root@zabbix ~]# yum makecache[root@zabbix ~]# yum -y install gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel[root@zabbix ~]# wget https://www.php.net/distributions/php-5.6.40.tar.gz[root@zabbix ~]# echo "$?"0[root@zabbix ~]# lsanaconda-ks.cfg nginx-1.16.1.tar.gz php-5.6.40.tar.gz[root@zabbix ~]# tar xf php-5.6.40.tar.gz -C /usr/src/[root@zabbix ~]# cd /usr/src/php-5.6.40/[root@zabbix php-5.6.40]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm#出現一下的式樣就ok了Generating filesconfigure: creating ./config.statuscreating main/internal_functions.ccreating main/internal_functions_cli.c+--------------------------------------------------------------------+| License: || This software is subject to the PHP License, available in this || distribution in the file LICENSE. By continuing this installation || process, you are bound by the terms of this license agreement. || If you do not agree with the terms of this license, you must abort || the installation process at this point. |+--------------------------------------------------------------------+Thank you for using PHP.[root@zabbix php-5.6.40]# make && make install
php主要編譯安裝說明
- [x]--prefix指定php的安裝目錄
- [x]--with-config-file-path指定php的配置文件位置
- [x]--with-mysql、--with-mysqli讓php可以操作mysql
- [x]--enable-fpm主要是nginx要來調用php語言得使用php-fpm
2.2啟動php
[root@zabbix php-5.6.40]# tail -1 /etc/profile #添加環境變量export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/[root@zabbix php-5.6.40]# source /etc/profile #讓他立即生效[root@zabbix php-5.6.40]# php-fpm -t #檢測一下配置文件有沒有錯誤,現在報錯是因為沒有配置文件在里面,我們需要復制一份過去,[04-Nov-2019 10:04:15] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)[04-Nov-2019 10:04:15] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'[04-Nov-2019 10:04:15] ERROR: FPM initialization failed[root@zabbix php-5.6.40]# ls php.ini-php.ini-development php.ini-production# deve是開發環境的,production是生產環境的[root@zabbix php-5.6.40]# cp php.ini-production /usr/local/php/etc/php.ini[root@zabbix php-5.6.40]# cd /usr/local/php/etc/[root@zabbix etc]# lspear.conf php-fpm.conf.default php.ini[root@zabbix etc]# cp php-fpm.conf.default php-fpm.conf[root@zabbix etc]# lspear.conf php-fpm.conf php-fpm.conf.default php.ini[root@zabbix etc]# php-fpm -t[04-Nov-2019 10:16:00] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful[root@zabbix etc]# php-fpm -vPHP 5.6.40 (fpm-fcgi) (built: Nov 4 2019 09:37:11)Copyright (c) 1997-2016 The PHP GroupZend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies#使用systemctl將php管理起來,並啟動[root@zabbix etc]# cat /usr/lib/systemd/system/php-fpm.service[Unit]Description=php-fpmAfter=network.target[Service]Type=forkingExecStart=/usr/local/php/sbin/php-fpm[Install]WantedBy=multi-user.target[root@zabbix etc]# systemctl start php-fpm[root@zabbix etc]# ss -antup | grep 9000tcp LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=8872,fd=0),("php-fpm",pid=8871,fd=0),("php-fpm",pid=8870,fd=7))
2.3修改nginx的配置,讓php和nginx連用起來
[root@zabbix etc]# cd /usr/local/nginx/conf/[root@zabbix conf]# cat nginx.confworker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 80;server_name localhost;location / {root html;index index.html index.htm index.php; #必須加上.php結尾的主頁,要不然nginx調用動態的時候找不到回直接報錯就不找了}location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #去哪里尋找php文件。include fastcgi_params;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}}[root@zabbix conf]# nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@zabbix conf]# nginx -s reload[root@zabbix conf]# cd /usr/local/nginx/html/[root@zabbix html]# touch index.php #里邊什么都不用寫[root@zabbix html]# cat test.php<?phpecho "mr.su it's ok";?>
2.4驗證php+nginx是否連接成功

三mysql數據庫安裝
3.1搭建mysql數據庫
[root@zabbix html]# cd ~[root@zabbix ~]# wget https://www.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39.tar.gz[root@zabbix ~]# lsanaconda-ks.cfg mysql-5.6.39.tar.gz nginx-1.16.1.tar.gz php-5.6.40.tar.gz[root@zabbix ~]# yum install -y gcc gcc-c++ make tar openssl openssl-devel cmake ncurses ncurses-devel[root@zabbix ~]# useradd -M -s /sbin/nologin mysql[root@zabbix ~]# tar xf mysql-5.6.39.tar.gz -C /usr/src/[root@zabbix ~]# cd /usr/src/mysql-5.6.39/[root@zabbix mysql-5.6.39]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1[root@zabbix mysql-5.6.39]# echo "$?"0[root@zabbix mysql-5.6.39]# make && make install[root@zabbix mysql-5.6.39]# echo "$?"0[root@zabbix mysql-5.6.39]# cp support-files/mysql.server /etc/init.d/mysqld[root@zabbix mysql-5.6.39]# chmod +x /etc/init.d/mysqld[root@zabbix mysql-5.6.39]# tail -1 /etc/profile #修改環境變量,本質是要服務器找到命令,所以做軟連接也是可以的export PATH=$PATH:/usr/local/mysql/bin/#修改配置文件[root@zabbix mysql-5.6.39]# cat /etc/my.cnf[mysqld]bind-address=0.0.0.0port=3306datadir=/data/mysqluser=mysqlskip-name-resolvelong_query_time=2slow_query_log_file=/data/mysql/mysql-slow.logexpire_logs_days=2innodb-file-per-table=1innodb_flush_log_at_trx_commit = 2log_warnings = 1max_allowed_packet = 512Mconnect_timeout = 60net_read_timeout = 120[mysqld_safe]log-error=/data/mysql/mysqld.logpid-file=/data/mysql/mysqld.pid
重要的編譯選項說明
- [x] CMACK_INSTALL_PREFIX指定安裝的目錄
- [x] MYSQL_DATADIR指定Mysql的數據目錄
3.2初始化數據庫
[root@zabbix mysql-5.6.39]# mkdir -p /data/mysql #建立數據目錄[root@zabbix mysql-5.6.39]# chown -R mysql:mysql /usr/local/mysql /data/mysql/ #分別對數據目錄,和運行目錄授權[root@zabbix mysql-5.6.39]# yum install -y perl-Module-Install #初始數據庫的一個依賴程序[root@zabbix mysql-5.6.39]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql/ #初始完成以后輸出的特別像亂碼,往上看,找到兩個ok就初始化完成了[root@zabbix mysql-5.6.39]# cat /usr/lib/systemd/system/mysqld.service #使用systemctl管理mysql[Unit]Description=mysqldAfter=network.target[Service]Type=forkingExecStart=/etc/init.d/mysqld start[Install]WantedBy=multi-user.target[root@zabbix mysql-5.6.39]# systemctl start mysqld[root@zabbix mysql-5.6.39]# ss -antup | grep 3306tcp LISTEN 0 80 *:3306 *:* users:(("mysqld",pid=26225,fd=10))
3.3給mysql建立zabbix賬號並驗證連接
[root@zabbix mysql-5.6.39]# cd ~[root@zabbix ~]# mysqladmin -h 127.0.0.1 -u root password 'zabbixpwd'Warning: Using a password on the command line interface can be insecure.[root@zabbix ~]# echo "$?"0[root@zabbix ~]# mysql -uroot -pzabbixpwd -h 127.0.0.1Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.6.39 Source distributionCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.200.%' IDENTIFIED BY 'zabbixpwd' WITH GRANT OPTION;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> exit[root@zabbix ~]# mysql -uroot -pzabbixpwd -h 192.168.200.173 #驗證密碼在遠處登錄mysql> exit[root@zabbix ~]# cat /usr/local/nginx/html/test_mysql.php #建立測試nginx+php+mysql 的測試文件<?php$link=mysql_connect("127.0.0.1","root","zabbixpwd");if(!$link) echo "FAILD!連接錯誤,用戶名密碼不對";else echo "OK!可以連接";?>
3.4通過http://192.168.200.173/test_mysqsl.php

四搭建zabbix4.0
4.1下載並編譯安裝zabbix
[root@zabbix ~]# yum install -y libevent-devel wget tar gcc gcc-c++ make net-snmp-devel libxml2-devel libcurl-devel #yum安裝zabbix的支持程序[root@zabbix ~]# useradd -M -s /sbin/nologin zabbix[root@zabbix ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz #下載zabbix4.0的源碼包[root@zabbix ~]# lsanaconda-ks.cfg mysql-5.6.39.tar.gz nginx-1.16.1.tar.gz php-5.6.40.tar.gz zabbix-4.0.3.tar.gz[root@zabbix ~]# tar xf zabbix-4.0.3.tar.gz -C /usr/src/[root@zabbix ~]# cd /usr/src/zabbix-4.0.3/[root@zabbix zabbix-4.0.3]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2#出現以下的就ok了************************************************************ Now run 'make install' ** ** Thank you for using Zabbix! ** <http://www.zabbix.com> ************************************************************[root@zabbix zabbix-4.0.3]# make && make install[root@zabbix zabbix-4.0.3]# tail -1 /etc/profile #修改變量文件,使其能找到命令export PATH=$PATH:/usr/local/zabbix/sbin/:/usr/local/zabbix/bin/[root@zabbix zabbix-4.0.3]# source /etc/profile #立即生效[root@zabbix zabbix-4.0.3]# zabbix_server --versionzabbix_server (Zabbix) 4.0.3Revision 87993 20 December 2018, compilation time: Nov 13 2019 09:44:17Copyright (C) 2018 Zabbix SIALicense GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.This is free software: you are free to change and redistribute it according tothe license. There is NO WARRANTY, to the extent permitted by law.
選項說明
- --prefix指定安裝目錄
- --enable-server安裝zabbix server
- --enable-agent安裝zabbix agent
- --with-mysql用mysql來存儲
4.2初始化zabbix數據庫,啟動zabbix
[root@zabbix zabbix-4.0.3]# mysql -h 127.0.0.1 -uroot -pzabbixpwdmysql> create database zabbix character set utf8 collate utf8_bin;Query OK, 1 row affected (0.00 sec)mysql> grant all privileges on zabbix.* to zabbix@'127.0.0.1' identified by 'zabbixpwd';Query OK, 0 rows affected (0.04 sec)mysql> flush privileges;Query OK, 0 rows affected (0.04 sec)mysql> set names utf8; #設置編碼Query OK, 0 rows affected (0.00 sec)mysql> use zabbix; #切換數據庫准備導表Database changedmysql> source /usr/src/zabbix-4.0.3/database/mysql/schema.sql #開始導表,不要順序亂了mysql> source /usr/src/zabbix-4.0.3/database/mysql/data.sqlmysql> source /usr/src/zabbix-4.0.3/database/mysql/images.sql #導表完成#修改zabbix的配置文件[root@zabbix zabbix-4.0.3]# cd /usr/local/zabbix/etc/[root@zabbix etc]# lszabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d[root@zabbix etc]# cp zabbix_server.conf zabbix_server.conf.bak[root@zabbix etc]# lszabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.bak zabbix_server.conf.d[root@zabbix etc]# cat zabbix_server.confLogFile=/usr/local/zabbix/zabbix_server.logDBHost=127.0.0.1DBName=zabbixDBUser=zabbixDBPassword=zabbixpwdDBPort=3306Timeout=30AlertScriptsPath=/usr/local/zabbix/alertscripts #放置我們微信告警,以及郵件告警腳本的位置。ExternalScripts=/usr/local/zabbix/externalscriptsLogSlowQueries=3000#一定要把配置文件里的#號都刪掉#啟動zabbix[root@zabbix etc]# chown zabbix:zabbix -R /usr/local/zabbix/ #給目錄降權[root@zabbix etc]# zabbix_server #啟動zabbix,命令就是zabbix[root@zabbix etc]# ss -lntup | grep 10051 #查看端口,server端已經啟動tcp LISTEN 0 128 *:10051[root@zabbix etc]# mkdir -p /usr/local/nginx/html/zabbix[root@zabbix etc]# cp -a /usr/src/zabbix-4.0.3/frontends/php/* /usr/local/nginx/html/zabbix/ #將所有的zabbix的網頁復制到nginx下
4.3在web界面登錄zabbix
使用ip登錄。ip/zabbix


#修改php的文件[root@zabbix etc]# vim /usr/local/php/etc/php.ini#將以下幾行修改成這個樣子660:post_max_size = 32M372:max_execution_time = 350382:max_input_time = 350936:date.timezone = Asia/Shanghai702:always_populate_raw_post_data = -1[root@zabbix etc]# systemctl restart php-fpm #重啟php[root@zabbix etc]# ss -antup | grep 9000tcp LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=42895,fd=0),("php-fpm",pid=42894,fd=0),("php-fpm",pid=42893,fd=7))








root@zabbix ~]# lsanaconda-ks.cfg mysql-5.6.39.tar.gz nginx-1.16.1.tar.gz php-5.6.40.tar.gz zabbix-4.0.3.tar.gz zabbix.conf.php[root@zabbix ~]# mv zabbix.conf.php /usr/local/nginx/html/zabbix/conf/[root@zabbix ~]# cat /usr/local/nginx/html/zabbix/conf/zabbix.conf.php #里面改就是我們剛剛形成的一些內容<?php// Zabbix GUI configuration file.global $DB;$DB['TYPE'] = 'MYSQL';$DB['SERVER'] = '127.0.0.1';$DB['PORT'] = '3306';$DB['DATABASE'] = 'zabbix';$DB['USER'] = 'zabbix';$DB['PASSWORD'] = 'zabbixpwd';// Schema name. Used for IBM DB2 and PostgreSQL.$DB['SCHEMA'] = '';$ZBX_SERVER = 'localhost';$ZBX_SERVER_PORT = '10051';$ZBX_SERVER_NAME = '';$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;


4.4禁用沒用的用戶


4.5修改超戶的密碼






4.6zabbix網頁漢化補丁包
[root@zabbix ~]# ls /usr/local/nginx/html/zabbix/fonts/ #這個目錄里放着的就是zabbix的字體,但是沒有中文字體所以會出現亂碼,我們的解決方法就是下載個字體覆蓋到這DejaVuSans.ttf[root@zabbix ~]# wget https://raw.githubusercontent.com/chenqing/ng-mini/master/font/msyh.ttf #下載字體的網址。[root@zabbix ~]# lsanaconda-ks.cfg msyh.ttf mysql-5.6.39.tar.gz nginx-1.16.1.tar.gz php-5.6.40.tar.gz zabbix-4.0.3.tar.gz[root@zabbix ~]# mv msyh.ttf /usr/local/nginx/html/zabbix/fonts/[root@zabbix ~]# ls /usr/local/nginx/html/zabbix/fonts/DejaVuSans.ttf msyh.ttf[root@zabbix ~]# vim /usr/local/nginx/html/zabbix/include/defines.inc.php #修改php文件里的默認,將DejaVuSans字體,改成msyh微軟雅黑字體65 define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name110 define('ZBX_FONT_NAME', 'msyh'); #將65行和110行替換成這個樣子。#php插入的不像java之類的需要編譯類文件等,直接就可以使用。
4.7漢化完成



