監控介紹php
爲何要作監控?mysql
能夠提早發現潛在的故障隱患,第一時間解決掉。把影響下降。ios
常見的監控軟件:nginx
cacti nagios zaabix(用得最多) open-falcon prometheus grafana 等等web
安裝zabbix4.0sql
[root@wangzb01 ~]# rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm 獲取https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm 警告:/var/tmp/rpm-tmp.p8q9Nk: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY 準備中... ################################# [100%] 正在升級/安裝... 1:zabbix-release-4.0-1.el7 ################################# [100%] [root@wangzb01 ~]# yum list | grep zabbix //查看zabbix相關的包 [root@wangzb01 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql //安裝這幾個包 [root@wangzb01 ~]# netstat -ltnp //查看端口,端口不要和nginx,Tomcat衝突 [root@wangzb01 ~]# mysql -uroot -pmysql //登陸數據庫 MariaDB [(none)]> create database zabbix //建立數據庫 MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbix'; //建立數據庫用戶名密碼 [root@wangzb01 ~]# vi /etc/zabbix/zabbix_server.conf //編輯配置文件 DBHost=127.0.0.1 DBName=zabbix DBUser=zabbix DBPassword=zabbix [root@wangzb01 ~]# systemctl start zabbix-server //啓動服務 [root@wangzb01 ~]# ps aux | grep zabbix //查看服務 root 7830 0.0 0.0 112724 988 pts/0 S+ 22:08 0:00 grep --color=auto zabbix 發現並未啓動成功 [root@wangzb01 ~]# vim /var/log/zabbix/zabbix_server.log //查看日誌 緣由是沒有導入zabbix的數據庫 [root@wangzb01 ~]# ls /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz //查看create.sql文件 [root@wangzb01 ~]# gzip -d /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz //解壓文件 [root@wangzb01 ~]# ls /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql //查看解壓後的文件 [root@wangzb01 ~]# mysql -uroot -pmysql zabbix < /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql //將create.sql導入到zabbix庫中 [root@wangzb01 ~]# systemctl start zabbix-server //再次啓動服務 [root@wangzb01 ~]# ps aux | grep zabbix_server zabbix 8121 0.0 0.4 257668 4312 ? S 22:15 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 8123 0.0 0.3 257668 3292 ? S 22:15 0:00 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.054641 sec, idle 60 sec] zabbix 8124 0.0 0.2 257668 2552 ? S 22:15 0:00 /usr/sbin/zabbix_server: alerter #1 started zabbix 8125 0.0 0.2 257668 2552 ? S 22:15 0:00 /usr/sbin/zabbix_server: alerter #2 started zabbix 8126 0.0 0.2 257668 2552 ? S 22:15 0:00 /usr/sbin/zabbix_server: alerter #3 started zabbix 8127 0.0 0.2 257668 2552 ? S 22:15 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] zabbix 8128 0.0 0.2 257668 2892 ? S 22:15 0:00 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.002961 sec, idle 59 sec] zabbix 8129 0.0 0.2 257668 2892 ? S 22:15 0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001293 sec, idle 5 sec] zabbix 8130 0.0 0.5 362136 5288 ? S 22:15 0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.001912 sec, idle 60 sec] zabbix 8131 0.0 0.3 257792 3568 ? S 22:15 0:00 /usr/sbin/zabbix_server: history syncer #1 [processed 0 values, 0 triggers in 0.000032 sec, idle 1 sec] zabbix 8132 0.0 0.3 257792 3592 ? S 22:15 0:00 /usr/sbin/zabbix_server: history syncer #2 [processed 0 values, 0 triggers in 0.000026 sec, idle 1 sec] zabbix 8134 0.0 0.3 257820 3432 ? S 22:15 0:00 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000053 sec, idle 1 sec] zabbix 8136 0.0 0.3 257844 3524 ? S 22:15 0:00 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000024 sec, idle 1 sec] zabbix 8137 0.0 0.3 257668 3828 ? S 22:15 0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.002923 sec, idle 3 sec] zabbix 8138 0.0 0.3 257668 3828 ? S 22:15 0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000127 sec, idle 5 sec] zabbix 8139 0.0 0.2 257668 2640 ? S 22:15 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000021 sec, idle 1 sec] zabbix 8140 0.0 0.2 257668 2916 ? S 22:15 0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000742 sec, idle 5 sec] zabbix 8141 0.0 0.5 365412 5504 ? S 22:15 0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000011 sec, idle 5 sec] zabbix 8142 0.0 0.5 365412 5504 ? S 22:15 0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000009 sec, idle 5 sec] zabbix 8143 0.0 0.5 365412 5504 ? S 22:15 0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000010 sec, idle 5 sec] zabbix 8144 0.0 0.5 365412 5528 ? S 22:15 0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000031 sec, idle 5 sec] zabbix 8145 0.0 0.5 365412 5500 ? S 22:15 0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000031 sec, idle 5 sec] zabbix 8146 0.0 0.5 365412 5564 ? S 22:15 0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000058 sec, idle 4 sec] zabbix 8147 0.0 0.3 257668 3644 ? S 22:15 0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection] zabbix 8148 0.0 0.3 257668 3644 ? S 22:15 0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection] zabbix 8149 0.0 0.3 257668 3644 ? S 22:15 0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection] zabbix 8150 0.0 0.3 257668 3644 ? S 22:15 0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection] zabbix 8151 0.0 0.3 257668 3644 ? S 22:15 0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection] zabbix 8152 0.0 0.2 261044 2648 ? S 22:15 0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000025 sec, idle 5 sec] zabbix 8159 0.0 0.3 257668 3320 ? S 22:15 0:00 /usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.012806 sec during 5.012875 sec] zabbix 8160 0.0 0.3 257668 3072 ? S 22:15 0:00 /usr/sbin/zabbix_server: preprocessing manager #1 [queued 0, processed 0 values, idle 5.002992 sec during 5.003076 sec] zabbix 8166 0.0 0.2 257668 2712 ? S 22:15 0:00 /usr/sbin/zabbix_server: preprocessing worker #1 started zabbix 8167 0.0 0.2 257668 2712 ? S 22:15 0:00 /usr/sbin/zabbix_server: preprocessing worker #2 started zabbix 8169 0.0 0.2 257668 2604 ? S 22:15 0:00 /usr/sbin/zabbix_server: preprocessing worker #3 started root 8185 0.0 0.0 112728 988 pts/0 S+ 22:18 0:00 grep --color=auto zabbix [root@wangzb01 ~]# vim /etc/zabbix/zabbix_server.conf Server=127.0.0.1 ServerActive=127.0.0.1 [root@wangzb01 ~]# systemctl start zabbix-agent [root@wangzb01 ~]# ps aux | grep zabbix_agent zabbix 8209 0.0 0.1 80784 1300 ? S 22:23 0:00 /usr/sbin/zabbix_agend -c /etc/zabbix/zabbix_agentd.conf zabbix 8210 0.0 0.1 80784 1380 ? S 22:23 0:00 /usr/sbin/zabbix_agend: collector [idle 1 sec] zabbix 8211 0.0 0.1 80784 1848 ? S 22:23 0:00 /usr/sbin/zabbix_agend: listener #1 [waiting for connection] zabbix 8212 0.0 0.2 80784 2140 ? S 22:23 0:00 /usr/sbin/zabbix_agend: listener #2 [waiting for connection] zabbix 8213 0.0 0.1 80784 1848 ? S 22:23 0:00 /usr/sbin/zabbix_agend: listener #3 [waiting for connection] zabbix 8214 0.0 0.2 80916 2128 ? S 22:23 0:00 /usr/sbin/zabbix_agend: active checks #1 [idle 1 sec] root 8218 0.0 0.0 112724 992 pts/0 S+ 22:24 0:00 grep --color=auto zabbix_agent
因爲nginx的80端口和zabbix須要的httpd服務的80端口衝突,所以須要停用nginx服務並啓用httpd服務數據庫
[root@wangzb01 ~]# systemctl stop nginx [root@wangzb01 ~]# systemctl start httpd [root@wangzb01 ~]# netstat -lntp tcp6 0 0 :::80 :::* LISTEN 8554/httpd 能夠看到80端口對應的服務是httpd
在瀏覽器中輸入地址加80端口便可打開zabbixvim
而後在瀏覽器輸入地址http://192.168.1.34/zabbix 訪問進入安裝界面瀏覽器
有fail,須要定義時區app
[root@wangzb01 ~]# vim /etc/php.ini date.timezone = Aisa/Shanghai [root@wangzb01 ~]# systemctl restart httpd
返回瀏覽器界面刷新一下,就所有OK了
點擊下一步
輸入server信息點擊下一步
進入zabbix界面,到此,zabbix服務端安裝完成。