安裝zabbix之前請自行先搭建好LAMP環境!
1、下載源碼安裝包並解壓
1.1 下載
[root@nmserver-7 ~]# mkdir zabbix [root@nmserver-7 ~]# cd zabbix/ [root@nmserver-7 zabbix]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz --2017-07-22 22:27:27-- https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz 正在解析主機 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)... 211.79.60.17, 2001:e10:ffff:1f02::17 正在連接 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|211.79.60.17|:443... 已連接。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:16016367 (15M) [application/x-gzip] 正在保存至: “zabbix-3.2.7.tar.gz” 100%[===================================================================================================================>] 16,016,367 195KB/s 用時 82s 2017-07-22 22:28:51 (190 KB/s) - 已保存 “zabbix-3.2.7.tar.gz” [16016367/16016367])
1.2 解壓
[root@nmserver-7 zabbix]# ls zabbix-3.2.7.tar.gz [root@nmserver-7 zabbix]# tar -zxvf zabbix-3.2.7.tar.gz
2、創建zabbix數據庫
zabbix server 、zabbix proxy及zabbix前端運行需要數據庫支持,因此要提前創建好數據庫和各種表格;
參考官方文檔: https://www.zabbix.com/documentation/3.2/manual/appendix/install/db_scripts
2.1 創建zabbix數據庫
[root@nmserver-7 zabbix-3.2.7]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 12 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.03 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | zabbix | +--------------------+ 4 rows in set (0.03 sec) MariaDB [(none)]>
2.2 系統創建zabbix用戶
#groupadd zabbix -g 501 #創建用戶組,並且設置UID501 #useradd -g zabbix -u 501 -m zabbix
注意一定要創建不然后面的zabbix服務會啟動不了,出現以下問題
問題一:
[root@nmserver-7 zabbix-3.2.7]# /usr/local/zabbix/sbin/zabbix_agentd zabbix_agentd [1380]: user zabbix does not exist zabbix_agentd [1380]: cannot run as root!
問題二:
[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd start Starting zabbix_agentd (via systemctl): [ 確定 ] [root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd status ● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled) Active: active (exited) since 日 2017-07-23 05:22:02 CST; 5s ago Docs: man:systemd-sysv-generator(8) Process: 1351 ExecStart=/etc/rc.d/init.d/zabbix_agentd start (code=exited, status=0/SUCCESS) 7月 23 05:22:02 nmserver-7.test.com systemd[1]: Starting SYSV: Starts and stops Zabbix Agent using chkconfig... 7月 23 05:22:02 nmserver-7.test.com zabbix_agentd[1351]: Starting zabbix_agentd: zabbix_agentd [1358]: user zabbix does not exist 7月 23 05:22:02 nmserver-7.test.com zabbix_agentd[1351]: zabbix_agentd [1358]: cannot run as root! 7月 23 05:22:02 nmserver-7.test.com zabbix_agentd[1351]: [失敗] 7月 23 05:22:02 nmserver-7.test.com systemd[1]: Started SYSV: Starts and stops Zabbix Agent using chkconfig.
2.3 創建數據庫表格
進入解壓源碼后的 /zabbix-3.2.7/database/mysql 目錄;
[root@nmserver-7 zabbix]# ls zabbix-3.2.7 zabbix-3.2.7.tar.gz [root@nmserver-7 zabbix]# pwd /root/zabbix [root@nmserver-7 zabbix]# cd zabbix-3.2.7/database/mysql/ [root@nmserver-7 mysql]# pwd /root/zabbix/zabbix-3.2.7/database/mysql [root@nmserver-7 mysql]# ls data.sql images.sql schema.sql [root@nmserver-7 mysql]#
2.4 將源碼包中的角本導入zabbix數據庫
[root@nmserver-7 mysql]# pwd /root/zabbix/zabbix-3.2.7/database/mysql [root@nmserver-7 mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql [root@nmserver-7 mysql]# mysql -uzabbix -pzabbix zabbix < images.sql [root@nmserver-7 mysql]# mysql -uzabbix -pzabbix zabbix < data.sql [root@nmserver-7 mysql]# mysql -uzabbix -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> use zabbix; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [zabbix]> show tables; +----------------------------+ | Tables_in_zabbix | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | ....................
....................
....................
| | users_groups | | usrgrp | | valuemaps | +----------------------------+ 127 rows in set (0.00 sec) MariaDB [zabbix]>
可見數據庫及表格已經成功創建完成;
3、編譯安裝
3.1 編譯
./configure --help 可以查詢編譯時可選參數;
[root@nmserver-7 zabbix]# cd zabbix-3.2.7 [root@nmserver-7 zabbix-3.2.7]# ./configure --help `configure' configures Zabbix 3.2.7 to adapt to many kinds of systems.
.................
.................
我這里只安裝zabbix server 和zabbix agentd 服務器,參考官方的編譯參數 代碼如下:
[root@nmserver-7 mysql]# cd /root/zabbix/zabbix-3.2.7 [root@nmserver-7 zabbix-3.2.7]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml --prefix=/usr/local/zabbix
安裝路徑根據需要修改--prefix參數
第一次編譯時時出現問題“configure: error: LIBXML2 library not found” 如下
解決方法:
[root@nmserver-7 zabbix-3.2.7]# yum install libxml2-devel 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 libxml2-devel.i686.0.2.9.1-6.el7_2.3 將被 安裝 --> 正在處理依賴關系 xz-devel,它被軟件包 libxml2-devel-2.9.1-6.el7_2.3.i686 需要 --> 正在檢查事務 ---> 軟件包 xz-devel.i686.0.5.2.2-1.el7 將被 安裝 --> 解決依賴關系完成 ... ...
... ...
再次編譯出現以下問題:
checking for pkg-config... /bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for xml2-config... /bin/xml2-config checking for xmlReadMemory in -lxml2... yes checking for net-snmp-config... no configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
解決方法如下:
[root@nmserver-7 zabbix-3.2.7]# yum install net-snmp-devel
安裝完畢后進行第三次編譯,編譯成功!
[root@nmserver-7 zabbix-3.2.7]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/usr/local/zabbix checking for a BSD-compatible install... /bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes configure: Configuring Zabbix 3.2.7 checking whether make sets $(MAKE)... (cached) yes checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking for gcc... gcc ...... ......
......
Configuration: Detected OS: linux-gnu Install path: /usr/local/zabbix Compilation arch: linux Compiler: gcc Compiler flags: -g -O2 Library-specific flags: database: -I/usr/include/mysql libXML2: -I/usr/include/libxml2 Net-SNMP: -I/usr/local/include -I/usr/lib/perl5/CORE -I. -I/usr/include Enable server: yes Server details: With database: MySQL WEB Monitoring: cURL Native Jabber: no SNMP: yes IPMI: no SSH: no TLS: no ODBC: no Linker flags: -L/usr/lib/mysql -L/usr/lib -rdynamic Libraries: -lmysqlclient -lxml2 -lnetsnmp -lcurl -lm -ldl -lresolv Enable proxy: no Enable agent: yes Agent details: TLS: no Linker flags: -rdynamic Libraries: -lcurl -lm -ldl -lresolv Enable Java gateway: no LDAP support: no IPv6 support: yes *********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * *********************************************************** [root@nmserver-7 zabbix-3.2.7]#
3.2 安裝zabbix
[root@nmserver-7 zabbix-3.2.7]# make install
3.3 驗證安裝成功
[root@nmserver-7 conf]# /usr/local/zabbix/sbin/zabbix_server -V zabbix_server (Zabbix) 3.2.7 Revision 70298 18 July 2017, compilation time: Jul 23 2017 04:01:34 Copyright (C) 2017 Zabbix SIA License 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 to the license. There is NO WARRANTY, to the extent permitted by law. [root@nmserver-7 conf]# /usr/local/zabbix/sbin/zabbix_agentd -V zabbix_agentd (daemon) (Zabbix) 3.2.7 Revision 70298 18 July 2017, compilation time: Jul 23 2017 04:01:34 Copyright (C) 2017 Zabbix SIA License 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 to the license. There is NO WARRANTY, to the extent permitted by law. [root@nmserver-7 conf]#
3、啟用服務
3.1修改服務器和客戶端配置文件
zabbix_server配置文件修改,主要設置好連接數據的數據庫名稱、登陸賬號還有密碼!
[root@nmserver-7 init.d]# vi /usr/local/zabbix/etc/zabbix_server.conf ..... 75 # Mandatory: no 76 # Default: 77 # DBHost=localhost 78 79 ### Option: DBName ......85 # DBName= 86 87 DBName=zabbix 88 ......100 # Default: 101 # DBUser= 102 103 DBUser=zabbix 104 ......109 # Mandatory: no 110 # Default: 111 # DBPassword= 112 DBPassword=zabbix
zabbix_agentd配置文件修改;主要配置好zabbix server的IP地址;
[root@nmserver-7 init.d]# vi /usr/local/zabbix/etc/zabbix_agentd.conf
......
89 # Server=
90
91 Server=127.0.0.1
92
93 ### Option: ListenPort
94 # Agent will listen on this port for connections from the server.
......
ServerActive=127.0.0.1
......
Hostname=127.0.0.1
......
將配置文件中的Server、ServerActive、Hostname參數設置成zabbix服務器的IP地址即可,我這次安裝的zabbix_agentd和zabbix_server在同一服務器上,所在IP地址為本機IP地址;
3.2 修改firewall設置
開放zabbix端口10050和10051
[root@nmserver-7 init.d]# firewall-cmd --permanent --add-port=10051/tcp success [root@nmserver-7 init.d]# firewall-cmd --permanent --add-port=10050/tcp success [root@nmserver-7 init.d]# systemctl restart firewalld [root@nmserver-7 init.d]#
3.3 設置開機啟動
3.3.1 將源碼包中提供的init.d啟動腳本拷貝到系統中
[root@nmserver-7 zabbix-3.2.7]# ls aclocal.m4 compile config.sub depcomp m4 misc src AUTHORS conf configure frontends Makefile missing upgrades bin config.guess configure.ac include Makefile.am NEWS build config.log COPYING INSTALL Makefile.in README ChangeLog config.status database install-sh man sass
[root@nmserver-7 zabbix-3.2.7]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/ -v "misc/init.d/fedora/core/zabbix_agentd" -> "/etc/init.d/zabbix_agentd" "misc/init.d/fedora/core/zabbix_server" -> "/etc/init.d/zabbix_server" [root@nmserver-7 zabbix-3.2.7]#
3.3.2 編輯啟動腳本以適應自己的安裝環境
修改服務器端啟動文件
#vi /etc/init.d/zabbix_server
將BASEDIR=/usr/local/替換為BASEDIR=/usr/local/zabbix(以之前編譯的位置為准)
修改客戶器端啟動文件:
#vi /etc/init.d/zabbix_agentd
將BASEDIR=/usr/local/替換為BASEDIR=/usr/local/zabbix(以之前編譯的位置為准)
3.4 服務啟動與配置驗證
方法一:
[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_server start Starting zabbix_server (via systemctl): [ 確定 ] [root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd start Starting zabbix_agentd (via systemctl): [ 確定 ] [root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_server status ● zabbix_server.service - SYSV: Starts and stops Zabbix Server using chkconfig Loaded: loaded (/etc/rc.d/init.d/zabbix_server; bad; vendor preset: disabled) Active: active (running) since 日 2017-07-23 05:36:18 CST; 18s ago Docs: man:systemd-sysv-generator(8) Process: 1769 ExecStart=/etc/rc.d/init.d/zabbix_server start (code=exited, status=0/SUCCESS) CGroup: /system.slice/zabbix_server.service ├─1779 /usr/local/zabbix/sbin/zabbix_server ├─1784 /usr/local/zabbix/sbin/zabbix_server: configuration syncer [waiting 60 sec f... ├─1785 /usr/local/zabbix/sbin/zabbix_server: db watchdog [synced alerts config in 0... ├─1786 /usr/local/zabbix/sbin/zabbix_server: poller #1 [got 0 values in 0.000011 se... ├─1787 /usr/local/zabbix/sbin/zabbix_server: poller #2 [got 0 values in 0.000011 se... ├─1788 /usr/local/zabbix/sbin/zabbix_server: poller #3 [got 0 values in 0.000011 se... ├─1789 /usr/local/zabbix/sbin/zabbix_server: poller #4 [got 0 values in 0.000011 se... ├─1790 /usr/local/zabbix/sbin/zabbix_server: poller #5 [got 0 values in 0.000014 se... ├─1791 /usr/local/zabbix/sbin/zabbix_server: unreachable poller #1 [got 0 values in... ├─1792 /usr/local/zabbix/sbin/zabbix_server: trapper #1 [processed data in 0.000000... ├─1793 /usr/local/zabbix/sbin/zabbix_server: trapper #2 [processed data in 0.000000... ├─1794 /usr/local/zabbix/sbin/zabbix_server: trapper #3 [processed data in 0.000000... ├─1795 /usr/local/zabbix/sbin/zabbix_server: trapper #4 [processed data in 0.000000... ├─1796 /usr/local/zabbix/sbin/zabbix_server: trapper #5 [processed data in 0.001351... ├─1797 /usr/local/zabbix/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.0000... ├─1798 /usr/local/zabbix/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fai... ├─1799 /usr/local/zabbix/sbin/zabbix_server: housekeeper [startup idle for 30 minut... ├─1800 /usr/local/zabbix/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 even... ├─1801 /usr/local/zabbix/sbin/zabbix_server: http poller #1 [got 0 values in 0.0013... ├─1802 /usr/local/zabbix/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.... ├─1803 /usr/local/zabbix/sbin/zabbix_server: history syncer #1 [synced 0 items in 0... ├─1804 /usr/local/zabbix/sbin/zabbix_server: history syncer #2 [synced 0 items in 0... ├─1805 /usr/local/zabbix/sbin/zabbix_server: history syncer #3 [synced 0 items in 0... ├─1806 /usr/local/zabbix/sbin/zabbix_server: history syncer #4 [synced 0 items in 0... ├─1807 /usr/local/zabbix/sbin/zabbix_server: escalator #1 [processed 0 escalations ... ├─1808 /usr/local/zabbix/sbin/zabbix_server: proxy poller #1 [exchanged data with 0... ├─1809 /usr/local/zabbix/sbin/zabbix_server: self-monitoring [processed data in 0.0... └─1815 /usr/local/zabbix/sbin/zabbix_server: task manager [processed 0 task(s) in 0... 7月 23 05:36:18 nmserver-7.test.com systemd[1]: Starting SYSV: Starts and stops Zabbix Serv..... 7月 23 05:36:18 nmserver-7.test.com zabbix_server[1769]: Starting zabbix_server: [ 確定 ] 7月 23 05:36:18 nmserver-7.test.com systemd[1]: Started SYSV: Starts and stops Zabbix Serve...g. Hint: Some lines were ellipsized, use -l to show in full. [root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd status ● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled) Active: active (running) since 日 2017-07-23 05:36:26 CST; 19s ago Docs: man:systemd-sysv-generator(8) Process: 1849 ExecStart=/etc/rc.d/init.d/zabbix_agentd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/zabbix_agentd.service ├─1859 /usr/local/zabbix/sbin/zabbix_agentd ├─1860 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec] ├─1861 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection] ├─1862 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection] ├─1863 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection] └─1864 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec] 7月 23 05:36:26 nmserver-7.test.com systemd[1]: Starting SYSV: Starts and stops Zabbix Agen..... 7月 23 05:36:26 nmserver-7.test.com zabbix_agentd[1849]: Starting zabbix_agentd: [ 確定 ] 7月 23 05:36:26 nmserver-7.test.com systemd[1]: Started SYSV: Starts and stops Zabbix Agent...g. Hint: Some lines were ellipsized, use -l to show in full. [root@nmserver-7 zabbix-3.2.7]# netstat -tulp 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:ssh 0.0.0.0:* LISTEN 1084/sshd tcp 0 0 0.0.0.0:zabbix-agent 0.0.0.0:* LISTEN 1859/zabbix_agentd tcp 0 0 0.0.0.0:zabbix-trapper 0.0.0.0:* LISTEN 1779/zabbix_server tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd tcp6 0 0 [::]:zabbix-agent [::]:* LISTEN 1859/zabbix_agentd tcp6 0 0 [::]:zabbix-trapper [::]:* LISTEN 1779/zabbix_server tcp6 0 0 [::]:http [::]:* LISTEN 10072/httpd udp 0 0 localhost:323 0.0.0.0:* 592/chronyd udp6 0 0 localhost:323 [::]:* 592/chronyd [root@nmserver-7 zabbix-3.2.7]#
方法二:
[root@nmserver-7 zabbix-3.2.7]# /usr/local/zabbix/sbin/zabbix_server [root@nmserver-7 zabbix-3.2.7]# /usr/local/zabbix/sbin/zabbix_agentd [root@nmserver-7 zabbix-3.2.7]# netstat -tulp 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:ssh 0.0.0.0:* LISTEN 1084/sshd tcp 0 0 0.0.0.0:zabbix-agent 0.0.0.0:* LISTEN 2031/zabbix_agentd tcp 0 0 0.0.0.0:zabbix-trapper 0.0.0.0:* LISTEN 1974/zabbix_server tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd tcp6 0 0 [::]:zabbix-agent [::]:* LISTEN 2031/zabbix_agentd tcp6 0 0 [::]:zabbix-trapper [::]:* LISTEN 1974/zabbix_server tcp6 0 0 [::]:http [::]:* LISTEN 10072/httpd udp 0 0 localhost:323 0.0.0.0:* 592/chronyd udp6 0 0 localhost:323 [::]:* 592/chronyd [root@nmserver-7 zabbix-3.2.7]#
3.5 設置zabbix server 和zabbix agentd開機自動啟動
[root@nmserver-7 zabbix-3.2.7]# chkconfig --add zabbix_server [root@nmserver-7 zabbix-3.2.7]# chkconfig --add zabbix_agentd [root@nmserver-7 zabbix-3.2.7]# chkconfig --level 35 zabbix_server on [root@nmserver-7 zabbix-3.2.7]# chkconfig --level 35 zabbix_agentd on [root@nmserver-7 zabbix-3.2.7]# chkconfig --list 注意:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置數據可能被原生 systemd 配置覆蓋。 如果您想列出 systemd 服務,請執行 'systemctl list-unit-files'。 欲查看對特定 target 啟用的服務請執行 'systemctl list-dependencies [target]'。 netconsole 0:關 1:關 2:關 3:關 4:關 5:關 6:關 network 0:關 1:關 2:開 3:開 4:開 5:開 6:關 zabbix_agentd 0:關 1:關 2:關 3:開 4:關 5:開 6:關 zabbix_server 0:關 1:關 2:關 3:開 4:關 5:開 6:關 [root@nmserver-7 zabbix-3.2.7]#
4、 前端Web配置
4.1 查詢apache配置文件確認DocumentRoot位置
[root@nmserver-7 ~]# vi /etc/httpd/conf/httpd.conf 116 # DocumentRoot: The directory out of which you will serve your 117 # documents. By default, all requests are taken from this directory, but 118 # symbolic links and aliases may be used to point to other locations. 119 # 120 DocumentRoot "/var/www/html" 121 122 # 123 # Relax access to content within /var/www. 124 #
4.2 拷貝源碼包中的前端PHP代碼到apache根目錄
[root@nmserver-7 zabbix-3.2.7]# mkdir /var/www/html/zabbix/
[root@nmserver-7 zabbix-3.2.7]# pwd /root/zabbix/zabbix-3.2.7 [root@nmserver-7 zabbix-3.2.7]# cp -a ./frontends/php/ /var/www/html/zabbix
4.3 更改zabbix網頁文件權限
[root@nmserver-7 zabbix-3.2.7]# chown -R zabbix.zabbix /var/www/html/zabbix/
4.4 重啟apache Web服務器
[root@nmserver-7 zabbix-3.2.7]# systemctl restart httpd
5、瀏覽器登陸進行zabbix安裝初始化
5.1 瀏覽器輸入http://192.168.8.9/zabbix/
注意有時此頁面會顯示403錯誤 無權限訪問;這時需要reboot服務器再進行登陸;
5.2 下一步檢測安裝前的一些配置是否滿足
我這里有4個錯誤報警,這里出現的問題須要解決完后才能進行一下步操作;對缺少模塊的須要重新編譯相應模塊並加載,
大部分參數只須要修改PHP配置文件即可滿足條件,針對上面4個錯誤提示來修改PHP配置文件:
[root@nmserver-7 zabbix-3.2.7]# vi /etc/php.ini #在php配置文件的672行將8M改為16M 672 post_max_size = 8M-->16M #在384行將30改為300 384 max_execution_time = 30-->300 #在394行將max_inpu_time原來60改為300 394 max_input_time = 60-->300 #在配置文件878行添加亞洲時區 878 ;date.timezone = 878 date.timezone = Asia/Shanghai :wq 將4個參數修改完成后保存退出
重啟apache服務
[root@nmserver-7 zabbix-3.2.7]# systemctl restart httpd
再重新瀏覽器登陸http://192.168.8.9/zabbix/setup.php
這次安裝條件全部滿足沒有報警提示
好了,可以進行下一步操作了!
5.3 配置數據庫連接
注意:database port是 0表示是默認3306端口
數據庫名稱、賬號名字、密碼 根據之前創建數據庫時的設置來添加,我這里只用添加“Password"項為”zabbix"即可,然后可以下一步了!
5.4 關於zabbix 服務器的配置
主要有三個參數:host 、port 、name
前二個參數默認即可,Name為zabbix服務器的名字這里可以根據自己情況而設置,我這里設置成NMServer-7,設置好下一步!
5.5 安裝摘要,對前面設置參數匯總
沒問題就下一步~~~
5.6 安裝
這時突然出現以下問題:
根據提示找出產生這個問題的主要原因是從源碼拷貝PHP配置文件后,有關zabbix的配置文件需要修改;
源配置文件內容如下: 可以看到名字沒有修改,配置也不對
[root@nmserver-7 zabbix-3.2.7]# cd /var/www/html/zabbix/conf/ [root@nmserver-7 conf]# ls maintenance.inc.php zabbix.conf.php.example [root@nmserver-7 conf]# ll 總用量 8 -rw-r--r--. 1 zabbix zabbix 1036 7月 18 18:41 maintenance.inc.php -rw-r--r--. 1 zabbix zabbix 411 7月 18 18:41 zabbix.conf.php.example [root@nmserver-7 conf]# cd /var/www/html/zabbix/conf/ [root@nmserver-7 conf]# ls maintenance.inc.php zabbix.conf.php.example [root@nmserver-7 conf]# cat zabbix.conf.php.example <?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = 'localhost'; $DB['PORT'] = '0'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = ''; // 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; [root@nmserver-7 conf]#
修改配置文件名稱,編輯配置文件參數,按照之前設置的添加好,配置如下:
[root@nmserver-7 conf]# cp zabbix.conf.php.example zabbix.conf.php [root@nmserver-7 conf]# ls maintenance.inc.php zabbix.conf.php zabbix.conf.php.example [root@nmserver-7 conf]# vi zabbix.conf.php <?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = 'localhost'; $DB['PORT'] = '0'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = 'zabbix'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB['SCHEMA'] = ''; $ZBX_SERVER = 'localhost'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = 'NMServer-7'; :wq
6、登陸zabbix
6.1 登陸
前端安裝好以下直接跳出以下界面,點“Login"
進入登陸界面:
注意默認賬號是“Admin" ,密碼是:”zabbix" ,Admin的A是大寫切記!
6.2 檢查狀態改為中文
狀態正常
修改語言:administration->users->language->Chinese(zh_CN)->update
按F5刷新瀏覽器,可見中文界面
7、zabbix安裝結束
安裝只是做為zabbix的入門,接下來要學習各種監控才是重點。
加油!