C/S架構,基於C++開發,監控中心支持web界面配置和管理php
單個server節點能夠支持上萬臺客戶端mysql
5個組件web
監控流程圖sql
在兩臺機器上安裝,一臺是服務端(test-a:192.168.77.134),一臺是客戶端(centos0:192.168.77.129)。數據庫
第一步,服務端安裝zabbix,導入數據,啓動服務apache
[root@test-a ~]# wget https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm # 下載不下來,就經過瀏覽器下載後上傳 [root@test-a ~]# rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm # 安裝rpm warning: zabbix-release-3.4-2.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-3.4-2.el7 ################################# [100%] [root@test-a ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql # 安裝相關的工具包 # zabbix-agent 客戶端工具 # zabbix-get 服務端工具,獲取客戶端收集的相關監控數據 # zabbix-server-mysql 服務端工具,和mysql相關的工具 # zabbix-web 服務端工具,監控展現網頁工具 # zabbix-web-mysql 服務端工具,網頁與mysql相關的工具 # 建立zabbix的mysql庫及用戶,並導入初始數據 [root@test-a ~]# ps aux|grep mysql root 2234 0.0 0.1 115436 1728 ? S 08:46 0:00 /bin/sh /usr/local/mysql/bin/mysqd_safe --datadir=/data/mysql --pid-file=/usr/local/mysql/mysqld.pid mysql 2463 0.1 18.4 1117940 186076 ? Sl 08:46 0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/db.err --pid-file=/usr/local/mysql/mysqld.pid --socket=/usr/local/mysqlmysql.sock --port=3306 root 2777 0.0 0.0 112704 972 pts/0 S+ 09:12 0:00 grep --color=auto mysql # mysql 的配置須要添加character-set-server = utf8,使支持中文 [root@test-a ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.23-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix character set utf8; -- 建立庫 Query OK, 1 row affected (0.04 sec) mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'test111'; -- 添加用戶及受權 Query OK, 0 rows affected, 1 warning (0.30 sec) mysql> quit Bye [root@test-a ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.15/ [root@test-a zabbix-server-mysql-3.4.15]# ls AUTHORS ChangeLog COPYING create.sql.gz NEWS README [root@test-a zabbix-server-mysql-3.4.15]# cp create.sql.gz create.sql.gz.default # 備份一下 [root@test-a zabbix-server-mysql-3.4.15]# gzip -d create.sql.gz # 解壓 [root@test-a zabbix-server-mysql-3.4.15]# ls AUTHORS ChangeLog COPYING create.sql create.sql.gz.default NEWS README [root@test-a zabbix-server-mysql-3.4.15]# mysql -uroot -ptest111 zabbix < create.sql # 導入數據,須要幾秒導入 mysql: [Warning] Using a password on the command line interface can be insecure. [root@test-a ~]# vim /etc/zabbix/zabbix_server.conf # 配置DBHost=127.0.0.1 和 DBPassword=test111,就是剛受權的ip及密碼 [root@test-a ~]# systemctl start zabbix-server [root@test-a ~]# ps -aux|grep zabbix zabbix 3164 45.5 0.3 254608 4036 ? R 09:35 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 3167 0.0 0.2 254608 2316 ? S 09:35 0:00 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes] zabbix 3168 0.0 0.2 254608 2320 ? S 09:35 0:00 /usr/sbin/zabbix_server: alerter [connecting to the database] zabbix 3169 0.0 0.2 254608 2320 ? S 09:35 0:00 /usr/sbin/zabbix_server: alerter [connecting to the database] zabbix 3170 0.0 0.2 254608 2320 ? S 09:35 0:00 /usr/sbin/zabbix_server: alerter [connecting to the database] zabbix 3171 0.0 0.2 254608 2316 ? S 09:35 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] zabbix 3172 0.5 0.2 254608 2548 ? S 09:35 0:00 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 8 sec] zabbix 3173 0.0 0.2 254604 2644 ? S 09:35 0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.104076 sec, idle 5 sec] zabbix 3174 6.0 0.3 358328 3916 ? D 09:35 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 3175 2.0 0.2 254604 2644 ? S 09:35 0:00 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000042 sec, idle 1 sec] zabbix 3177 0.0 0.2 254604 2644 ? S 09:35 0:00 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000040 sec, idle 1 sec] zabbix 3179 0.0 0.2 254604 2644 ? S 09:35 0:00 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000029 sec, idle 1 sec] zabbix 3181 2.0 0.2 254604 2644 ? S 09:35 0:00 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000024 sec, idle 1 sec] zabbix 3183 2.0 0.3 254608 3576 ? S 09:35 0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.051954 sec, idle 3 sec] zabbix 3185 3.0 0.3 254608 3580 ? S 09:35 0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000584 sec, idle 5 sec] zabbix 3187 0.0 0.2 254608 2408 ? S 09:35 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000440 sec, idle 1 sec] zabbix 3188 0.0 0.2 254608 2552 ? S 09:35 0:00 /usr/sbin/zabbix_server: task manager [started, idle 1 sec] zabbix 3189 0.0 0.3 358328 3916 ? R 09:35 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 3191 0.0 0.3 358328 3916 ? D 09:35 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf root 3193 0.0 0.0 112704 972 pts/0 S+ 09:35 0:00 grep --color=auto zabbix [root@test-a ~]# netstat -ntlp # 查看zabbix的監聽端口: 10051 說明啓動成功,若是啓動報錯了,根據日誌(/var/log/zabbix/zabbix_server.log)解決問題 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2465/master tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3164/zabbix_server tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 0.0.0.0:44016 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 1313/rpc.mountd tcp 0 0 0.0.0.0:56497 0.0.0.0:* LISTEN 1231/rpc.statd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1214/sshd tcp6 0 0 ::1:25 :::* LISTEN 2465/master tcp6 0 0 :::51514 :::* LISTEN 1231/rpc.statd tcp6 0 0 :::2049 :::* LISTEN - tcp6 0 0 :::10051 :::* LISTEN 3164/zabbix_server tcp6 0 0 :::55049 :::* LISTEN - tcp6 0 0 :::3306 :::* LISTEN 2463/mysqld tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::80 :::* LISTEN 2999/httpd tcp6 0 0 :::20048 :::* LISTEN 1313/rpc.mountd tcp6 0 0 :::22 :::* LISTEN 1214/sshd
第二步,網頁配置(server-ip/zabbix)
訪問 http://192.168.77.134/zabbix,會出來安裝界面vim
點擊 next step,會發現有紅色提示,那是由於php沒有配置時區,早/etc/php.ini中配置date.timezone = Asia/Shanghai後,重啓apache,從新刷新網頁就沒有提示了centos
而後輸入mysql相關配置,點擊next step安裝完成啦瀏覽器
到登陸頁面輸入默認帳戶admin,密碼zabbix,登陸
登陸成功後,首先更改密碼和系統語言
點Change password進行密碼替換,下面的Language選擇Chinese
刷新主頁
zabbix服務名
第三步,客戶端安裝及配置啓動
[root@centos0 ~]# rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm 警告:zabbix-release-3.4-2.el7.noarch.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY 準備中... ################################# [100%] 正在升級/安裝... 1:zabbix-release-3.4-2.el7 ################################# [100%] [root@centos0 ~]# yum install -y zabbix-agent [root@centos0 ~]# vim /etc/zabbix/zabbix_agentd.conf # 更改Server, ServerActive爲對應的zabbix服務器IP, Hostname爲對應的zabbix服務名稱(不是主機名,web工具安裝時配置的,不記得了能夠在web裏去找) [root@centos0 ~]# systemctl start zabbix-agent [root@centos0 ~]# netstat -ntlp # 監聽的端口是10050 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3550/master tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 3989/zabbix_agentd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2599/sshd tcp6 0 0 ::1:25 :::* LISTEN 3550/master tcp6 0 0 :::10050 :::* LISTEN 3989/zabbix_agentd tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::22 :::* LISTEN 2599/sshd
進入mysql,選擇zabbix庫及users表,更改對應用戶的密碼便可,
[root@test-a logs]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 331 Server version: 5.7.23-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 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> 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 | varchar(32) | NO | | 15m | | | lang | varchar(5) | NO | | en_GB | | | refresh | varchar(32) | NO | | 30s | | | 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.31 sec) mysql> update users set passwd=md5('test111') where alias='Admin'; # 設置新密碼爲test111 Query OK, 0 rows affected (0.10 sec) Rows matched: 1 Changed: 0 Warnings: 0