zabbix監控流程圖
php
安裝zabbixmysql
[root@qingyun-01 ~]# rpm -i http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm 警告:/var/tmp/rpm-tmp.8EUWZ1: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY #官網有附帶教程
[root@qingyun-01 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
#啓動mysql [root@qingyun-01 mysql]# /etc/init.d/mysqld start
vim /etc/my.cnf //須要增長配置
character_set_server = utf8
ios
[root@qingyun-01 mysql]# systemctl restart mysql mysql> create database zabbix character set utf8; Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'qingyunzabbix'; Query OK, 0 rows affected (0.02 sec) #讓zabbix web 服務能夠鏈接數據庫
#進入該目錄 [root@qingyun-01 mysql]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/ #壓縮包須要解壓一下 [root@qingyun-01 zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql.gz NEWS README [root@qingyun-01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz [root@qingyun-01 zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql NEWS README #導入庫裏面 [root@qingyun-01 zabbix-server-mysql-3.2.11]# mysql -uroot zabbix < create.sql
[root@qingyun-01 zabbix-server-mysql-3.2.11]# systemctl start zabbix-server #檢查zabbix服務 [root@qingyun-01 zabbix-server-mysql-3.2.11]# ps aux |grep zabbix zabbix 2267 0.0 0.3 254580 3496 ? S 16:41 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbi_server.conf root 2270 0.0 0.0 112676 984 pts/0 R+ 16:41 0:00 grep --color=auto zabbix #若是以前安裝過Nginx,須要先檢查是否啓動 [root@qingyun-01 zabbix-server-mysql-3.2.11]# ps aux | grep nginx root 2272 0.0 0.0 112676 980 pts/0 R+ 16:41 0:00 grep --color=auto nginx #啓動httpd 並 ps [root@qingyun-01 zabbix-server-mysql-3.2.11]# systemctl start httpd [root@qingyun-01 zabbix-server-mysql-3.2.11]# ps aux |grep httpd root 2279 0.3 1.5 394412 15456 ? Ss 16:42 0:00 /usr/sbin/httpd -DFOREGROUND apache 2287 0.0 0.7 394544 7692 ? S 16:42 0:00 /usr/sbin/httpd -DFOREGROUND apache 2288 0.0 0.7 394544 7692 ? S 16:42 0:00 /usr/sbin/httpd -DFOREGROUND apache 2289 0.0 0.7 394544 7692 ? S 16:42 0:00 /usr/sbin/httpd -DFOREGROUND apache 2290 0.0 0.7 394544 7692 ? S 16:42 0:00 /usr/sbin/httpd -DFOREGROUND apache 2291 0.0 0.7 394544 7692 ? S 16:42 0:00 /usr/sbin/httpd -DFOREGROUND root 2293 0.0 0.0 112676 984 pts/0 R+ 16:42 0:00 grep --color=auto httpd #查看是否監聽80端口 [root@qingyun-01 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 934/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1018/master tcp6 0 0 :::80 :::* LISTEN 2279/httpd tcp6 0 0 :::22 :::* LISTEN 934/sshd tcp6 0 0 ::1:25 :::* LISTEN 1018/master tcp6 0 0 :::3306 :::* LISTEN 1845/mysqld
[root@qingyun-01 zabbix-server-mysql-3.2.11]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@qingyun-01 zabbix-server-mysql-3.2.11]# systemctl enable zabbix-server Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service. #若是安裝過Nginx 須要停掉 [root@qingyun-01 zabbix-server-mysql-3.2.11]# systemctl disable nginx
#經過查看監聽端口,發現沒有監聽端口 #須要查看日誌排查問題 [root@qingyun-01 ~]# less /var/log/zabbix/zabbix_server.log
#編輯配置文件以後,須要重啓服務,加載配置文件 [root@qingyun-01 ~]# systemctl restart zabbix-server [root@qingyun-01 ~]# ps aux |grep zabbix
[root@qingyun-01 ~]# netstat -lntp |grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2375/zabbix_server tcp6 0 0 :::10051 :::* LISTEN 2375/zabbix_server
#設置時區 [root@qingyun-01 ~]# vim /etc/php.ini #編輯好配置文件後,重啓httpd [root@qingyun-01 ~]# systemctl restart httpd #重啓完成後,刷新將不報錯
用戶名admin 密碼zabbix
nginx
備註:修改完密碼後,能夠設置成中文顯示。web
zabbix客戶端安裝sql
#下載yum源 [root@qingyun-02 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm 獲取http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm 警告:/var/tmp/rpm-tmp.JZlW14: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY 準備中... ################################# [100%] 正在升級/安裝... 1:zabbix-release-3.2-1.el7 ################################# [100%] #安裝 [root@qingyun-02 ~]# yum install -y zabbix-agent #編輯配置文件 [root@qingyun-02 ~]# vim /etc/zabbix/zabbix_agentd.conf
內容以下
Server 配置被動模式
配置監控中心的ip
ServerActive 配置主動模式
設置客戶端名稱
數據庫
[root@qingyun-02 ~]# systemctl start zabbix-agent [root@qingyun-02 ~]# ps aux |grep zabbix zabbix 1180 0.0 0.1 80664 1264 ? S 17:54 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbi_agentd.conf zabbix 1181 0.0 0.1 80664 1300 ? S 17:54 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec] zabbix 1182 0.0 0.1 80664 1848 ? S 17:54 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] zabbix 1183 0.0 0.1 80664 1848 ? S 17:54 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] zabbix 1184 0.0 0.1 80664 1848 ? S 17:54 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] zabbix 1185 0.0 0.2 80796 2196 ? S 17:54 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] root 1187 0.0 0.0 112676 984 pts/0 R+ 17:54 0:00 grep --color=auto zabbix [root@qingyun-02 ~]# 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:80 0.0.0.0:* LISTEN 932/nginx: master p tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 917/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1010/master tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1180/zabbix_agentd tcp6 0 0 :::22 :::* LISTEN 917/sshd tcp6 0 0 ::1:25 :::* LISTEN 1010/master tcp6 0 0 :::10050 :::* LISTEN 1180/zabbix_agentd
#登陸數據庫 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 | 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.03 sec)
#修改密碼的命令 mysql> update users set passwd=md5('qingyun1') where alias= 'Admin'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from users; +--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+--------------+---------------+---------------+ | userid | alias | name | surname | passwd | url | autologin | autologout | lang | refresh | type | theme | attempt_failed | attempt_ip | attempt_clock | rows_per_page | +--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+--------------+---------------+---------------+ | 1 | Admin | Zabbix | Administrator | 4e5a9284849f3af9ece4a2892b97dabb | | 1 | 0 | en_GB | 30 | 3 | default | 6 | 192.168.21.1 | 1517391222 | 50 | | 2 | guest | | | d41d8cd98f00b204e9800998ecf8427e | | 0 | 900 | en_GB | 30 | 1 | default | 0 | | 0 | 50 | +--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+--------------+---------------+---------------+ 2 rows in set (0.00 sec)