通常大公司都會使用一些監控平臺軟件監控服務器運行狀態,不然服務器發生問題了,須要等到用戶的反饋就會不及時,產生很大的損失了。php
常見的開源監控軟件有:cacti、nagios、zabbix、smokeping、open-falcon等。mysql
nagios和zabbix流行度很高,cacti和smokeping偏向於基礎的監控,例如cacti監控網絡設備等(IDC機房用),成圖很是漂亮。ios
前幾年nagios不少公司在用,後來zabbix異軍突起開始流行起來,他比nagios有更多優點,配置也更簡單。nginx
cacti、nagios和zabbix服務端的監控中心須要php環境的支持,zabbix和cacti用mysql記錄,nagios不記錄歷史數據而注重服務的當前狀態。web
open-falcon是小米公司開發的,早起小米公司用zabbix監控,後來爲了知足個性化需求,本身開發了open-falcon,借鑑了zabbix的監控思想。sql
不少大公司:滴滴、360、微博、京東等都在用open-falcon。數據庫
zabbix會把數據記錄到mysql,再造成圖表。 nagios注重關注狀態不關心歷史數據。 zabbix能夠直接在瀏覽器裏方便配置。express
zabbix是基於C/S架構使用C++語言開發的,監控中心支持web配置管理,主流有3.2版本,最新的是3.4版本。apache
zabbix須要有一個服務端,在客戶端上也要安裝一個agent服務,而後agent採集客戶端機器的數據,主動上報給服務端,也能夠服務端主動去agent上抓數據。vim
agent有兩種模式:主動、被動。
監控中心開啓php環境,一臺server中心支持上萬臺的agent,瓶頸在於採集數據的量。
若是數據量大可使用zabbix-proxy代理,充當server的角色,減輕server端的壓力,代理獲得分析結果後再彙報。
zabbix-agent主要負責收集監控服務項目的數據
zabbix包含有五個組件:
一、Server 二、Web UI 三、數據存儲 Mysql 四、proxy:能夠一個局域網配置一個proxy代理 五、agent:每臺被監控的機器上都要安裝
zabbix的監控流程圖:
準備兩臺機器:A爲Server、B爲客戶端 一、A上到zabbix官網下載rpm的yum源,而後使用yum安裝的相關組件:直接yum epel源也能夠,可是版本爲2.2太舊了,不建議
[root@nginx src]# wget https://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm --2018-07-07 16:34:28-- https://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|:443... 已鏈接。 已發出 HTTP 請求,正在等待迴應... 200 OK 長度:13392 (13K) [application/x-redhat-package-manager] 正在保存至: 「zabbix-release-3.2-1.el7.noarch.rpm」 100%[=============================================================================================================>] 13,392 --.-K/s 用時 0s 2018-07-07 16:34:44 (307 MB/s) - 已保存 「zabbix-release-3.2-1.el7.noarch.rpm」 [13392/13392]) [root@nginx 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%]
二、yum安裝zabbix相關的包:zabbix-agent、zabbix-get、zabbix-server-mysql、zabbix-web、zabbix-web-mysql(會自動安裝httpd和php)
[root@nginx src]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql 已安裝: zabbix-agent.x86_64 0:3.2.11-1.el7 zabbix-get.x86_64 0:3.2.11-1.el7 zabbix-server-mysql.x86_64 0:3.2.11-1.el7 zabbix-web.noarch 0:3.2.11-1.el7 zabbix-web-mysql.noarch 0:3.2.11-1.el7 做爲依賴被安裝: OpenIPMI-libs.x86_64 0:2.0.23-2.el7 OpenIPMI-modalias.x86_64 0:2.0.23-2.el7 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 fping.x86_64 0:3.10-4.el7 iksemel.x86_64 0:1.4-6.el7 libX11.x86_64 0:1.6.5-1.el7 libX11-common.noarch 0:1.6.5-1.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXpm.x86_64 0:3.5.12-1.el7 libxcb.x86_64 0:1.12-1.el7 libzip.x86_64 0:0.10.1-8.el7 php.x86_64 0:5.4.16-45.el7 php-bcmath.x86_64 0:5.4.16-45.el7 php-cli.x86_64 0:5.4.16-45.el7 php-common.x86_64 0:5.4.16-45.el7 php-gd.x86_64 0:5.4.16-45.el7 php-ldap.x86_64 0:5.4.16-45.el7 php-mbstring.x86_64 0:5.4.16-45.el7 php-mysql.x86_64 0:5.4.16-45.el7 php-pdo.x86_64 0:5.4.16-45.el7 php-xml.x86_64 0:5.4.16-45.el7 t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7
三、單獨安裝mysql:在my.cnf中修改mysql的字符集,使web界面支持中文不會亂碼
[root@nginx ~]# vim /etc/my.cnf [mysqld] character_set_server=utf8 //加入這行配置 [root@nginx ~]# /etc/init.d/mysqld restart //重啓mysql Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!
四、創建zabbix的mysql庫和訪問用戶:
mysql> create database zabbix character set utf8; Query OK, 1 row affected (0.02 sec) mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by '7826078'; Query OK, 0 rows affected (0.02 sec)
五、導入原始數據到zabbix庫:自帶庫數據在/usr/share/doc/zabbix-server-mysql-3.2.11/ 目錄下
[root@nginx data]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/ [root@nginx zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql.gz NEWS README [root@nginx zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz [root@nginx zabbix-server-mysql-3.2.11]# mysql -uroot -pxxxxxxx zabbix <create.sql Warning: Using a password on the command line interface can be insecure.
六、啓動zabbix-server服務、httpd服務:停掉nginx服務以避免httpd80端口被nginx佔用
[root@nginx zabbix-server-mysql-3.2.11]# systemctl stop nginx //停掉nginx服務 [root@nginx zabbix-server-mysql-3.2.11]# netstat -lntp 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:22 0.0.0.0:* LISTEN 822/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1149/master tcp6 0 0 :::22 :::* LISTEN 822/sshd tcp6 0 0 ::1:25 :::* LISTEN 1149/master tcp6 0 0 :::3306 :::* LISTEN 1677/mysqld [root@nginx zabbix-server-mysql-3.2.11]# systemctl start zabbix-server //啓動zabbix-server [root@nginx zabbix-server-mysql-3.2.11]# ps aux|grep zabbix zabbix 2034 0.0 0.1 254628 3496 ? S 17:01 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf root 2037 0.0 0.0 112720 972 pts/0 S+ 17:02 0:00 grep --color=auto zabbix [root@nginx zabbix-server-mysql-3.2.11]# systemctl start httpd //啓動httpd [root@nginx zabbix-server-mysql-3.2.11]# netstat -lntp 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:22 0.0.0.0:* LISTEN 822/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1149/master tcp6 0 0 :::80 :::* LISTEN 2046/httpd tcp6 0 0 :::22 :::* LISTEN 822/sshd tcp6 0 0 ::1:25 :::* LISTEN 1149/master tcp6 0 0 :::3306 :::* LISTEN 1677/mysqld [root@nginx zabbix-server-mysql-3.2.11]# ps aux|grep httpd root 2046 0.3 0.8 394440 15528 ? Ss 17:03 0:00 /usr/sbin/httpd -DFOREGROUND apache 2049 0.0 0.4 394572 7684 ? S 17:04 0:00 /usr/sbin/httpd -DFOREGROUND apache 2050 0.0 0.4 394572 7684 ? S 17:04 0:00 /usr/sbin/httpd -DFOREGROUND apache 2051 0.0 0.4 394572 7684 ? S 17:04 0:00 /usr/sbin/httpd -DFOREGROUND apache 2052 0.0 0.4 394572 7684 ? S 17:04 0:00 /usr/sbin/httpd -DFOREGROUND apache 2053 0.0 0.4 394572 7684 ? S 17:04 0:00 /usr/sbin/httpd -DFOREGROUND root 2056 0.0 0.0 112720 968 pts/0 R+ 17:04 0:00 grep --color=auto httpd [root@nginx zabbix-server-mysql-3.2.11]# systemctl enable zabbix-server //設置開機啓動zabbix-server Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service. [root@nginx zabbix-server-mysql-3.2.11]# systemctl enable httpd //設置開機啓動httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@nginx zabbix-server-mysql-3.2.11]# chkconfig nginx off //nginx開機不啓動
七、開啓zabbix服務後,進程正常,可是沒有監聽端口:須要查看日誌排查錯誤
[root@nginx ~]# ps aux|grep zabbix //有zabbix進程 zabbix 1112 0.0 0.1 254628 3504 ? S 19:53 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf root 1370 0.0 0.0 112720 972 pts/0 S+ 20:16 0:00 grep --color=auto zabbix [root@nginx ~]# netstat -lntp //可是沒有zabbix端口監聽 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:22 0.0.0.0:* LISTEN 837/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1193/master tcp6 0 0 :::80 :::* LISTEN 839/httpd tcp6 0 0 :::22 :::* LISTEN 837/sshd tcp6 0 0 ::1:25 :::* LISTEN 1193/master tcp6 0 0 :::3306 :::* LISTEN 1091/mysqld [root@nginx ~]# cat /var/log/zabbix/zabbix_server.log //查看zabbix日誌,顯示沒法連接mysql 2034:20180707:170155.179 Starting Zabbix Server. Zabbix 3.2.11 (revision 76339). 2034:20180707:170155.179 ****** Enabled features ****** 2034:20180707:170155.179 SNMP monitoring: YES 2034:20180707:170155.179 IPMI monitoring: YES 2034:20180707:170155.179 Web monitoring: YES 2034:20180707:170155.179 VMware monitoring: YES 2034:20180707:170155.179 SMTP authentication: YES 2034:20180707:170155.179 Jabber notifications: YES 2034:20180707:170155.179 Ez Texting notifications: YES 2034:20180707:170155.179 ODBC: YES 2034:20180707:170155.179 SSH2 support: YES 2034:20180707:170155.179 IPv6 support: YES 2034:20180707:170155.179 TLS support: YES 2034:20180707:170155.179 ****************************** 2034:20180707:170155.179 using configuration file: /etc/zabbix/zabbix_server.conf 2034:20180707:170155.198 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
修改配置文件conf文件,鏈接mysql:增長DB相關的幾行配置,重啓zabbix-server就能夠監聽端口了
[root@nginx ~]# vim /etc/zabbix/zabbix_server.conf # Default: # PidFile=/tmp/zabbix_server.pid PidFile=/var/run/zabbix/zabbix_server.pid DBHost=127.0.0.1 DBName=zabbix DBUser=zabbix DBPassword=xxxxxx [root@nginx ~]# ps aux|grep zabbix zabbix 1401 1.1 0.2 254808 4184 ? S 20:25 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 1405 0.0 0.1 254808 2512 ? S 20:25 0:00 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes] zabbix 1406 0.0 0.1 254808 2724 ? S 20:25 0:00 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.009305 sec, idle 60 sec] zabbix 1407 0.1 0.2 361748 5260 ? S 20:25 0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000007 sec, idle 5 sec] zabbix 1408 0.0 0.2 361748 5260 ? S 20:25 0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000006 sec, idle 5 sec] zabbix 1409 0.0 0.2 361748 5260 ? S 20:25 0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000007 sec, idle 5 sec] zabbix 1410 0.0 0.2 361748 5260 ? S 20:25 0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000005 sec, idle 5 sec] zabbix 1411 0.0 0.2 361748 5260 ? S 20:25 0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000007 sec, idle 5 sec] zabbix 1412 0.0 0.2 361748 5260 ? S 20:25 0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000007 sec, idle 5 sec] zabbix 1413 0.0 0.1 254808 3616 ? S 20:25 0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection] zabbix 1414 0.0 0.1 254808 3616 ? S 20:25 0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection] zabbix 1415 0.0 0.1 254808 3616 ? S 20:25 0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection] zabbix 1417 0.0 0.1 254808 3616 ? S 20:25 0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection] zabbix 1419 0.0 0.1 254808 3616 ? S 20:25 0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection] zabbix 1421 0.0 0.1 257380 2688 ? S 20:25 0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000006 sec, idle 5 sec] zabbix 1422 0.0 0.1 254808 2728 ? S 20:25 0:00 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.005476 sec, idle 30 sec] zabbix 1424 0.0 0.1 254808 2508 ? S 20:25 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] zabbix 1425 0.0 0.1 254880 2968 ? S 20:25 0:00 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.005906 sec, 0 maintenances in 0.000000 sec, idle 29 sec] zabbix 1427 0.0 0.1 254808 2904 ? S 20:25 0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001905 sec, idle 5 sec] zabbix 1429 0.0 0.2 359168 5084 ? S 20:25 0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.002436 sec, idle 60 sec] zabbix 1430 0.0 0.1 254808 2888 ? S 20:25 0:00 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000002 sec, idle 1 sec] zabbix 1431 0.0 0.1 254808 2888 ? S 20:25 0:00 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000002 sec, idle 1 sec] zabbix 1432 0.0 0.1 254808 2888 ? S 20:25 0:00 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 1 sec] zabbix 1433 0.0 0.1 254808 2888 ? S 20:25 0:00 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000002 sec, idle 1 sec] zabbix 1437 0.0 0.2 254808 3828 ? S 20:25 0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.002680 sec, idle 3 sec] zabbix 1440 0.0 0.2 254808 3828 ? S 20:25 0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000005 sec, idle 5 sec] zabbix 1442 0.0 0.1 254808 2656 ? S 20:25 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000010 sec, idle 1 sec] zabbix 1446 0.0 0.1 254808 2876 ? S 20:25 0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.002907 sec, idle 5 sec] root 1453 0.0 0.0 112724 972 pts/0 S+ 20:25 0:00 grep --color=auto zabbix [root@nginx ~]# netstat -lntp //zabbix-server監聽端口是10051 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:22 0.0.0.0:* LISTEN 837/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1193/master tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1401/zabbix_server tcp6 0 0 :::80 :::* LISTEN 839/httpd tcp6 0 0 :::22 :::* LISTEN 837/sshd tcp6 0 0 ::1:25 :::* LISTEN 1193/master tcp6 0 0 :::10051 :::* LISTEN 1401/zabbix_server tcp6 0 0 :::3306 :::* LISTEN 1091/mysqld
八、配置web界面:打開瀏覽器輸入 192.168.87.128/zabbix,打開zabbix配置頁面
點擊下一步:檢驗運行環境,出現fail則須要修正
修改php時區:
[root@nginx ~]# vim /etc/php.ini date.timezone=Asia/Shanghai [root@nginx ~]# systemctl restart httpd //重啓httpd便可
從新配置web界面:時區問題解決,繼續下一步
配置數據庫和zabbix-server的信息
成功完成配置
登陸zabbix服務中心:
登錄後修改密碼:Administration-->users-->Admin-->ChangePassword:選擇中文語言
九、配置B機器,zabbix-agent端:
[root@lgs src]# wget https://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm //下載zabbix的yum源 --2018-07-07 20:57:06-- https://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|:443... 已鏈接。 已發出 HTTP 請求,正在等待迴應... 200 OK 長度:13392 (13K) [application/x-redhat-package-manager] 正在保存至: 「zabbix-release-3.2-1.el7.noarch.rpm」 100%[=============================================================================================================>] 13,392 --.-K/s 用時 0s 2018-07-07 20:57:08 (159 MB/s) - 已保存 「zabbix-release-3.2-1.el7.noarch.rpm」 [13392/13392]) [root@lgs src]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm //安裝zabbix的yum源 警告: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@lgs src]# yum install -y zabbix-agent //安裝zabbix-agent包 已加載插件:fastestmirror base | 3.6 kB 00:00:00 epel/x86_64/metalink | 6.7 kB 00:00:00 epel | 3.2 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 zabbix | 2.9 kB 00:00:00 zabbix-non-supported | 951 B 00:00:00 (1/6): extras/7/x86_64/primary_db | 150 kB 00:00:00 (2/6): epel/x86_64/group_gz | 88 kB 00:00:01 (3/6): zabbix/x86_64/primary_db | 87 kB 00:00:02 (4/6): updates/7/x86_64/primary_db | 3.6 MB 00:00:03 (5/6): epel/x86_64/updateinfo | 927 kB 00:00:06 (6/6): epel/x86_64/primary | 3.5 MB 00:00:12 zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:00 Loading mirror speeds from cached hostfile * epel: mirrors.huaweicloud.com epel 12603/12603 zabbix-non-supported 4/4 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 zabbix-agent.x86_64.0.3.2.11-1.el7 將被 安裝 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================================= 正在安裝: zabbix-agent x86_64 3.2.11-1.el7 zabbix 348 k 事務概要 ======================================================================================================================================================= 安裝 1 軟件包 總下載量:348 k 安裝大小:1.3 M Downloading packages: 警告:/var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-3.2.11-1.el7.x86_64.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEYkB 00:00:00 ETA zabbix-agent-3.2.11-1.el7.x86_64.rpm 的公鑰還沒有安裝 zabbix-agent-3.2.11-1.el7.x86_64.rpm | 348 kB 00:00:04 從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 檢索密鑰 導入 GPG key 0xA14FE591: 用戶ID : "Zabbix LLC <packager@zabbix.com>" 指紋 : a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591 軟件包 : zabbix-release-3.2-1.el7.noarch (installed) 來自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 Running transaction check Running transaction test Transaction test succeeded Running transaction 警告:RPM 數據庫已被非 yum 程序修改。 正在安裝 : zabbix-agent-3.2.11-1.el7.x86_64 1/1 驗證中 : zabbix-agent-3.2.11-1.el7.x86_64 1/1 已安裝: zabbix-agent.x86_64 0:3.2.11-1.el7 完畢!
十、配置B機器的zabbix-agent的配置文件:指定zabbix服務端的信息等
[root@lgs src]# vim /etc/zabbix/zabbix_agentd.conf Server=192.168.87.128 //服務端的ip,只開啓這個選項, 表明是被動模式,服務端過來抓取數據 ServerActive=192.168.87.128 //服務端的ip,開啓這個選項,表明是主動模式,agent主動上報agent的數據 Hostname=lgs-zabbix //zabbix服務定義的hostname [root@lgs src]# systemctl start zabbix-agent //啓動zabbix-agent [root@lgs src]# systemctl enable zabbix-agent //打開開機啓動zabbix-agent Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
進去mysql,直接修改zabbix庫的users表的密碼信息:
mysql> 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 mysql> show tables -> ; +----------------------------+ | Tables_in_zabbix | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | | auditlog | | auditlog_details | | autoreg_host | | conditions | | config | | corr_condition | | corr_condition_group | | corr_condition_tag | | corr_condition_tagpair | | corr_condition_tagvalue | | corr_operation | | correlation | | dbversion | | dchecks | | dhosts | | drules | | dservices | | escalations | | event_recovery | | event_tag | | events | | expressions | | functions | | globalmacro | | globalvars | | graph_discovery | | graph_theme | | graphs | | graphs_items | | group_discovery | | group_prototype | | groups | | history | | history_log | | history_str | | history_text | | history_uint | | host_discovery | | host_inventory | | hostmacro | | hosts | | hosts_groups | | hosts_templates | | housekeeper | | httpstep | | httpstepitem | | httptest | | httptestitem | | icon_map | | icon_mapping | | ids | | images | | interface | | interface_discovery | | item_application_prototype | | item_condition | | item_discovery | | items | | items_applications | | maintenances | | maintenances_groups | | maintenances_hosts | | maintenances_windows | | mappings | | media | | media_type | | opcommand | | opcommand_grp | | opcommand_hst | | opconditions | | operations | | opgroup | | opinventory | | opmessage | | opmessage_grp | | opmessage_usr | | optemplate | | problem | | problem_tag | | profiles | | proxy_autoreg_host | | proxy_dhistory | | proxy_history | | regexps | | rights | | screen_user | | screen_usrgrp | | screens | | screens_items | | scripts | | service_alarms | | services | | services_links | | services_times | | sessions | | slides | | slideshow_user | | slideshow_usrgrp | | slideshows | | sysmap_element_url | | sysmap_url | | sysmap_user | | sysmap_usrgrp | | sysmaps | | sysmaps_elements | | sysmaps_link_triggers | | sysmaps_links | | task | | task_close_problem | | timeperiods | | trends | | trends_uint | | trigger_depends | | trigger_discovery | | trigger_tag | | triggers | | users | | users_groups | | usrgrp | | valuemaps | +----------------------------+ 127 rows in set (0.00 sec) mysql> desc users; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ | userid | bigint(20) unsigned | NO | PRI | NULL | | | alias | varchar(100) | NO | UNI | | | | name | varchar(100) | NO | | | | | surname | varchar(100) | NO | | | | | passwd | char(32) | NO | | | | | url | varchar(255) | NO | | | | | autologin | int(11) | NO | | 0 | | | autologout | int(11) | NO | | 900 | | | lang | varchar(5) | NO | | en_GB | | | refresh | int(11) | NO | | 30 | | | type | int(11) | NO | | 1 | | | theme | varchar(128) | NO | | default | | | attempt_failed | int(11) | NO | | 0 | | | attempt_ip | varchar(39) | NO | | | | | attempt_clock | int(11) | NO | | 0 | | | rows_per_page | int(11) | NO | | 50 | | +----------------+---------------------+------+-----+---------+-------+ 16 rows in set (0.00 sec) mysql> update users set passwd=md5('961303') where alias='Admin'; //直接更新Admin用戶的密碼便可。 Query OK, 1 row affected (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 0
修改後從新用新密碼登陸。