5.10 监控介绍
为什么要做监控?
可以提前发现潜在故障隐患,第一时间解决掉。把影响降低。
常见的监控软件:
cacti nagios zaabix open-falcon prometheus grafana
5.11-5.12 安装zabbix4.0
zabbix 官网 https://www.zabbix.com/
zabbix4.0 安装
1)安装zabbix yum源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
2)yum 安装
yum install zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
3)数据库操作
create database zabbix;
grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbix-pa';
4) 导入数据
/usr/share/doc/zabbix-server-mysql-4.0.3/create.sql.gz
gzip -d /usr/share/doc/zabbix-server-mysql-4.0.3/create.sql.gz |mysql -uroot -paminglinux zabbix
5) 编辑zabbix_server.conf
vi /etc/zabbix/zabbix_server.conf # 定义数据库相关的参数
systemctl start zabbix-server
systemctl enable zabbix-server
6)zabbix_agent.conf
vi /etc/zabbix/zabbix_agentd.conf #定义Server=127.0.0.1和 ServerActive=127.0.0.1
systemctl start zabbix-agent
systemctl enable zabbix-agent
7)httpd
systemctl start httpd # 如果已经启动了nginx,需要先把nginx关闭,然后启动httpd
8)webui配置
http://ip/zabbix 访问,解决php的问题 (date.timezone Asia/Shanghai) /etc/php.ini
默认密码 admin zabbix
部分截图
选择zabbix4.0,选择二进制安装在选择Red Hat Enterprise linux/centos
[root@test01 ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.ZRT0ya: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-4.0-1.el7 ################################# [100%]
看一看有多少关于zabbix的包
[root@test01 ~]# yum list |grep zabbix
zabbix-release.noarch 4.0-1.el7 installed
iksemel.x86_64 1.4-2.el7.centos zabbix-non-supported
iksemel-devel.x86_64 1.4-2.el7.centos zabbix-non-supported
iksemel-utils.x86_64 1.4-2.el7.centos zabbix-non-supported
pcp-export-pcp2zabbix.x86_64 4.1.0-5.el7_6 updates
pcp-export-zabbix-agent.x86_64 4.1.0-5.el7_6 updates
python-pyzabbix.noarch 0.7.3-2.el7 epel
uwsgi-stats-pusher-zabbix.x86_64 2.0.17.1-1.el7 epel
zabbix-agent.x86_64 4.0.5-1.el7 zabbix
zabbix-get.x86_64 4.0.5-1.el7 zabbix
zabbix-java-gateway.x86_64 4.0.5-1.el7 zabbix
zabbix-proxy-mysql.x86_64 4.0.5-1.el7 zabbix
zabbix-proxy-pgsql.x86_64 4.0.5-1.el7 zabbix
zabbix-proxy-sqlite3.x86_64 4.0.5-1.el7 zabbix
zabbix-sender.x86_64 4.0.5-1.el7 zabbix
zabbix-server-mysql.x86_64 4.0.5-1.el7 zabbix
zabbix-server-pgsql.x86_64 4.0.5-1.el7 zabbix
zabbix-web.noarch 4.0.5-1.el7 zabbix
zabbix-web-japanese.noarch 4.0.5-1.el7 zabbix
zabbix-web-mysql.noarch 4.0.5-1.el7 zabbix
zabbix-web-pgsql.noarch 4.0.5-1.el7 zabbix
zabbix22.x86_64 2.2.23-1.el7 epel
zabbix22-agent.x86_64 2.2.23-1.el7 epel
zabbix22-dbfiles-mysql.noarch 2.2.23-1.el7 epel
zabbix22-dbfiles-pgsql.noarch 2.2.23-1.el7 epel
zabbix22-dbfiles-sqlite3.noarch 2.2.23-1.el7 epel
zabbix22-proxy.noarch 2.2.23-1.el7 epel
zabbix22-proxy-mysql.x86_64 2.2.23-1.el7 epel
zabbix22-proxy-pgsql.x86_64 2.2.23-1.el7 epel
zabbix22-proxy-sqlite3.x86_64 2.2.23-1.el7 epel
zabbix22-server.noarch 2.2.23-1.el7 epel
zabbix22-server-mysql.x86_64 2.2.23-1.el7 epel
zabbix22-server-pgsql.x86_64 2.2.23-1.el7 epel
zabbix22-web.noarch 2.2.23-1.el7 epel
zabbix22-web-mysql.noarch 2.2.23-1.el7 epel
zabbix22-web-pgsql.noarch 2.2.23-1.el7 epel
zabbix30.x86_64 3.0.22-2.el7 epel
zabbix30-agent.x86_64 3.0.22-2.el7 epel
zabbix30-dbfiles-mysql.noarch 3.0.22-2.el7 epel
zabbix30-dbfiles-pgsql.noarch 3.0.22-2.el7 epel
zabbix30-dbfiles-sqlite3.noarch 3.0.22-2.el7 epel
zabbix30-proxy.noarch 3.0.22-2.el7 epel
zabbix30-proxy-mysql.x86_64 3.0.22-2.el7 epel
zabbix30-proxy-pgsql.x86_64 3.0.22-2.el7 epel
zabbix30-proxy-sqlite3.x86_64 3.0.22-2.el7 epel
zabbix30-server.noarch 3.0.22-2.el7 epel
zabbix30-server-mysql.x86_64 3.0.22-2.el7 epel
zabbix30-server-pgsql.x86_64 3.0.22-2.el7 epel
zabbix30-web.noarch 3.0.22-2.el7 epel
zabbix30-web-mysql.noarch 3.0.22-2.el7 epel
zabbix30-web-pgsql.noarch 3.0.22-2.el7 epel
主要安装这几个包
[root@test01 ~]# yum install zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
[root@test01 ~]# netstat -ltnp 看一下80端口是否被占用
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 2903/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1027/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1741/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2903/nginx: master
tcp6 0 0 :::3306 :::* LISTEN 1273/mysqld
tcp6 0 0 :::22 :::* LISTEN 1027/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1741/master
[root@test01 ~]# mysql -uroot -pchampin
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.12-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> create database zabbix; 新建一个库
Query OK, 1 row affected (0.003 sec)
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'champin';
Query OK, 0 rows affected (0.011 sec) 创建一个用户及密码
MariaDB [(none)]> quit
Bye
[root@test01 ~]# vim /etc/zabbix/zabbix_server.conf 编辑zabbix配置文件,
找到这两处地方
### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
# If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
DBHost=127.0.0.1
定义要连接的数据库地址
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=champin
定义数据库的密码
启动zabbix
[root@test01 ~]# systemctl start zabbix-server
[root@test01 ~]# ps aux |grep zabbix 看有没有启动成功
root 3041 0.0 0.0 112728 980 pts/0 R+ 13:57 0:00 grep --color=auto zabbix
看一看zabbix的日志路径如下
[root@test01 ~]# cat /var/log/zabbix/zabbix_server.log
3034:20190321:135723.379 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3034:20190321:135723.380 ****** Enabled features ******
3034:20190321:135723.380 SNMP monitoring: YES
3034:20190321:135723.380 IPMI monitoring: YES
3034:20190321:135723.380 Web monitoring: YES
3034:20190321:135723.380 VMware monitoring: YES
3034:20190321:135723.380 SMTP authentication: YES
3034:20190321:135723.380 Jabber notifications: YES
3034:20190321:135723.381 Ez Texting notifications: YES
3034:20190321:135723.381 ODBC: YES
3034:20190321:135723.381 SSH2 support: YES
3034:20190321:135723.381 IPv6 support: YES
3034:20190321:135723.381 TLS support: YES
3034:20190321:135723.381 ******************************
3034:20190321:135723.381 using configuration file: /etc/zabbix/zabbix_server.conf
3034:20190321:135723.436 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3034:20190321:135723.436 cannot use database "zabbix": database is not a Zabbix database
3044:20190321:135733.584 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3044:20190321:135733.584 ****** Enabled features ******
3044:20190321:135733.585 SNMP monitoring: YES
3044:20190321:135733.585 IPMI monitoring: YES
3044:20190321:135733.585 Web monitoring: YES
3044:20190321:135733.585 VMware monitoring: YES
3044:20190321:135733.585 SMTP authentication: YES
3044:20190321:135733.585 Jabber notifications: YES
3044:20190321:135733.585 Ez Texting notifications: YES
3044:20190321:135733.585 ODBC: YES
3044:20190321:135733.585 SSH2 support: YES
3044:20190321:135733.585 IPv6 support: YES
3044:20190321:135733.585 TLS support: YES
3044:20190321:135733.585 ******************************
3044:20190321:135733.585 using configuration file: /etc/zabbix/zabbix_server.conf
3044:20190321:135733.593 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3044:20190321:135733.593 cannot use database "zabbix": database is not a Zabbix database
3050:20190321:135743.809 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3050:20190321:135743.809 ****** Enabled features ******
3050:20190321:135743.810 SNMP monitoring: YES
3050:20190321:135743.810 IPMI monitoring: YES
3050:20190321:135743.810 Web monitoring: YES
3050:20190321:135743.810 VMware monitoring: YES
3050:20190321:135743.810 SMTP authentication: YES
3050:20190321:135743.810 Jabber notifications: YES
3050:20190321:135743.810 Ez Texting notifications: YES
3050:20190321:135743.810 ODBC: YES
3050:20190321:135743.810 SSH2 support: YES
3050:20190321:135743.810 IPv6 support: YES
3050:20190321:135743.810 TLS support: YES
3050:20190321:135743.810 ******************************
3050:20190321:135743.810 using configuration file: /etc/zabbix/zabbix_server.conf
3050:20190321:135743.816 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3050:20190321:135743.816 cannot use database "zabbix": database is not a Zabbix database
3056:20190321:135754.073 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3056:20190321:135754.073 ****** Enabled features ******
3056:20190321:135754.073 SNMP monitoring: YES
3056:20190321:135754.073 IPMI monitoring: YES
3056:20190321:135754.073 Web monitoring: YES
3056:20190321:135754.073 VMware monitoring: YES
3056:20190321:135754.073 SMTP authentication: YES
3056:20190321:135754.073 Jabber notifications: YES
3056:20190321:135754.073 Ez Texting notifications: YES
3056:20190321:135754.073 ODBC: YES
3056:20190321:135754.073 SSH2 support: YES
3056:20190321:135754.073 IPv6 support: YES
3056:20190321:135754.073 TLS support: YES
3056:20190321:135754.073 ******************************
3056:20190321:135754.073 using configuration file: /etc/zabbix/zabbix_server.conf
3056:20190321:135754.080 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3056:20190321:135754.080 cannot use database "zabbix": database is not a Zabbix database
3063:20190321:135804.352 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3063:20190321:135804.353 ****** Enabled features ******
3063:20190321:135804.353 SNMP monitoring: YES
3063:20190321:135804.353 IPMI monitoring: YES
3063:20190321:135804.353 Web monitoring: YES
3063:20190321:135804.353 VMware monitoring: YES
3063:20190321:135804.353 SMTP authentication: YES
3063:20190321:135804.353 Jabber notifications: YES
3063:20190321:135804.353 Ez Texting notifications: YES
3063:20190321:135804.353 ODBC: YES
3063:20190321:135804.353 SSH2 support: YES
3063:20190321:135804.353 IPv6 support: YES
3063:20190321:135804.353 TLS support: YES
3063:20190321:135804.353 ******************************
3063:20190321:135804.354 using configuration file: /etc/zabbix/zabbix_server.conf
3063:20190321:135804.373 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3063:20190321:135804.373 cannot use database "zabbix": database is not a Zabbix database
3070:20190321:135814.568 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3070:20190321:135814.568 ****** Enabled features ******
3070:20190321:135814.568 SNMP monitoring: YES
3070:20190321:135814.568 IPMI monitoring: YES
3070:20190321:135814.568 Web monitoring: YES
3070:20190321:135814.568 VMware monitoring: YES
3070:20190321:135814.568 SMTP authentication: YES
3070:20190321:135814.569 Jabber notifications: YES
3070:20190321:135814.569 Ez Texting notifications: YES
3070:20190321:135814.569 ODBC: YES
3070:20190321:135814.569 SSH2 support: YES
3070:20190321:135814.569 IPv6 support: YES
3070:20190321:135814.569 TLS support: YES
3070:20190321:135814.569 ******************************
3070:20190321:135814.569 using configuration file: /etc/zabbix/zabbix_server.conf
3070:20190321:135814.582 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3070:20190321:135814.582 cannot use database "zabbix": database is not a Zabbix database
3076:20190321:135824.798 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3076:20190321:135824.798 ****** Enabled features ******
3076:20190321:135824.798 SNMP monitoring: YES
3076:20190321:135824.798 IPMI monitoring: YES
3076:20190321:135824.798 Web monitoring: YES
3076:20190321:135824.798 VMware monitoring: YES
3076:20190321:135824.798 SMTP authentication: YES
3076:20190321:135824.798 Jabber notifications: YES
3076:20190321:135824.798 Ez Texting notifications: YES
3076:20190321:135824.798 ODBC: YES
3076:20190321:135824.798 SSH2 support: YES
3076:20190321:135824.798 IPv6 support: YES
3076:20190321:135824.798 TLS support: YES
3076:20190321:135824.798 ******************************
3076:20190321:135824.798 using configuration file: /etc/zabbix/zabbix_server.conf
3076:20190321:135824.806 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3076:20190321:135824.806 cannot use database "zabbix": database is not a Zabbix database
3082:20190321:135835.089 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
3082:20190321:135835.089 ****** Enabled features ******
3082:20190321:135835.089 SNMP monitoring: YES
3082:20190321:135835.089 IPMI monitoring: YES
3082:20190321:135835.089 Web monitoring: YES
3082:20190321:135835.089 VMware monitoring: YES
3082:20190321:135835.090 SMTP authentication: YES
3082:20190321:135835.090 Jabber notifications: YES
3082:20190321:135835.090 Ez Texting notifications: YES
3082:20190321:135835.090 ODBC: YES
3082:20190321:135835.090 SSH2 support: YES
3082:20190321:135835.090 IPv6 support: YES
3082:20190321:135835.090 TLS support: YES
3082:20190321:135835.090 ******************************
3082:20190321:135835.090 using configuration file: /etc/zabbix/zabbix_server.conf
3082:20190321:135835.107 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
3082:20190321:135835.107 cannot use database "zabbix": database is not a Zabbix database
实际原因好像是库里面没有导入表,安装的rpm包里面有MySQL相关的sql文件,需要把sql文件导入到库里面去
这个就是sql文件的路径
[root@test01 ~]# ls /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz
/usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz
[root@test01 ~]# gzip -d !$ 先解压然后再导入到zabbix库里面去
gzip -d /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz
[root@test01 ~]# ls /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql 这个sql文件
/usr/share/doc/zabbix-server-mysql-4.0.5/create.sql
用这个命令可以导入到zabbix库里面去
[root@test01 ~]# mysql -uroot -pchampin zabbix < /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql
再启动zabbix-server
[root@test01 ~]# systemctl start zabbix-server
[root@test01 ~]# ps aux |grep zabbix
zabbix 3447 0.4 0.4 259224 4292 ? S 14:07 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix 3449 0.0 0.3 259224 3252 ? S 14:07 0:00 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.040921 sec, idle 60 sec]
zabbix 3450 0.0 0.2 259224 2528 ? S 14:07 0:00 /usr/sbin/zabbix_server: alerter #1 started
zabbix 3451 0.0 0.2 259224 2528 ? S 14:07 0:00 /usr/sbin/zabbix_server: alerter #2 started
zabbix 3452 0.0 0.2 259224 2528 ? S 14:07 0:00 /usr/sbin/zabbix_server: alerter #3 started
zabbix 3453 0.0 0.2 259224 2524 ? S 14:07 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
zabbix 3454 0.0 0.2 259224 2860 ? S 14:07 0:00 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.001359 sec, idle 59 sec]
zabbix 3455 0.0 0.2 259224 2860 ? S 14:07 0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001596 sec, idle 5 sec]
zabbix 3456 0.0 0.5 363588 5216 ? S 14:07 0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000596 sec, idle 60 sec]
zabbix 3457 0.0 0.3 259376 3564 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #1 [processed 0 values, 0 triggers in 0.000019 sec, idle 1 sec]
zabbix 3458 0.0 0.3 259348 3560 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #2 [processed 2 values, 2 triggers in 0.017224 sec, idle 1 sec]
zabbix 3460 0.0 0.3 259404 3400 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000038 sec, idle 1 sec]
zabbix 3461 0.0 0.3 259348 3472 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000020 sec, idle 1 sec]
zabbix 3465 0.0 0.3 259224 3796 ? S 14:07 0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000750 sec, idle 3 sec]
zabbix 3466 0.0 0.3 259224 3796 ? S 14:07 0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000029 sec, idle 5 sec]
zabbix 3469 0.0 0.2 259224 2612 ? S 14:07 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000050 sec, idle 1 sec]
zabbix 3470 0.0 0.2 259224 2888 ? S 14:07 0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.001066 sec, idle 5 sec]
zabbix 3473 0.0 0.5 366972 5216 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000058 sec, idle 4 sec]
zabbix 3474 0.1 0.5 366976 5636 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000096 sec, idle 4 sec]
zabbix 3475 0.0 0.5 366976 5476 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000088 sec, idle 4 sec]
zabbix 3476 0.0 0.5 366976 5476 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #4 [got 2 values in 0.000218 sec, idle 4 sec]
zabbix 3477 0.0 0.5 366972 5216 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000057 sec, idle 4 sec]
zabbix 3478 0.0 0.5 366972 5216 ? S 14:07 0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000057 sec, idle 5 sec]
zabbix 3479 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix 3482 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix 3484 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix 3486 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
zabbix 3491 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix 3494 0.0 0.2 262600 2612 ? S 14:07 0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000048 sec, idle 5 sec]
zabbix 3495 0.0 0.3 259224 3292 ? S 14:07 0:00 /usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.023484 sec during 5.023640 sec]
zabbix 3497 0.0 0.3 259224 3044 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing manager #1 [queued 0, processed 6 values, idle 5.009712 sec during 5.009986 sec]
zabbix 3499 0.0 0.2 259224 2692 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing worker #1 started
zabbix 3500 0.0 0.2 259224 2692 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing worker #2 started
zabbix 3501 0.0 0.2 259224 2580 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing worker #3 started
root 3527 0.0 0.0 112728 980 pts/0 R+ 14:08 0:00 grep --color=auto zabbix
[root@test01 ~]# netstat -lntp 查看一下监听的端口 zabbixserver监听1051端口
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 2903/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1027/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1741/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2903/nginx: master
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3447/zabbix_server
tcp6 0 0 :::3306 :::* LISTEN 1273/mysqld
tcp6 0 0 :::22 :::* LISTEN 1027/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1741/master
tcp6 0 0 :::10051 :::* LISTEN 3447/zabbix_server
[root@test01 ~]# vim /etc/zabbix/zabbix_agentd.conf
主要改的两个地方,也是两种模式,主动上报、被动去取,通过这两个去修改
Server=127.0.0.1
ServerActive=127.0.0.1
[root@test01 ~]# vi /etc/zabbix/zabbix_agentd.conf
[root@test01 ~]# vim !$
vim /etc/zabbix/zabbix_agentd.conf
启动zabbix-agent
[root@test01 ~]# systemctl start zabbix-agent
[root@test01 ~]# ps aux |grep zabbix-agent
root 3601 0.0 0.0 112728 980 pts/0 R+ 14:25 0:00 grep --color=auto zabbix-agent
没有启动成,看日志
[root@test01 ~]# tail /var//log/zabbix/zabbix_agentd.log
3568:20190321:142043.012 IPv6 support: YES
3568:20190321:142043.012 TLS support: YES
3568:20190321:142043.012 **************************
3568:20190321:142043.012 using configuration file: /etc/zabbix/zabbix_agentd.conf
3568:20190321:142043.013 agent #0 started [main process]
3570:20190321:142043.028 agent #2 started [listener #1]
3569:20190321:142043.032 agent #1 started [collector]
3571:20190321:142043.039 agent #3 started [listener #2]
3573:20190321:142043.042 agent #5 started [active checks #1]
3572:20190321:142043.046 agent #4 started [listener #3]
好像没有报错
原来是启动成功了
[root@test01 ~]# ps aux |grep zabbix
zabbix 3447 0.0 0.4 259224 4292 ? S 14:07 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix 3449 0.0 0.3 259224 3252 ? S 14:07 0:00 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.044669 sec, idle 60 sec]
zabbix 3450 0.0 0.2 259224 2528 ? S 14:07 0:00 /usr/sbin/zabbix_server: alerter #1 started
zabbix 3451 0.0 0.2 259224 2528 ? S 14:07 0:00 /usr/sbin/zabbix_server: alerter #2 started
zabbix 3452 0.0 0.2 259224 2528 ? S 14:07 0:00 /usr/sbin/zabbix_server: alerter #3 started
zabbix 3453 0.0 0.2 259224 2524 ? S 14:07 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
zabbix 3454 0.0 0.2 259224 2860 ? S 14:07 0:00 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.000494 sec, idle 59 sec]
zabbix 3455 0.0 0.2 259224 2860 ? S 14:07 0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001643 sec, idle 5 sec]
zabbix 3456 0.0 0.5 363588 5216 ? S 14:07 0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.001544 sec, idle 60 sec]
zabbix 3457 0.0 0.3 259376 3564 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #1 [processed 0 values, 0 triggers in 0.000045 sec, idle 1 sec]
zabbix 3458 0.0 0.3 259348 3592 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #2 [processed 0 values, 0 triggers in 0.000014 sec, idle 1 sec]
zabbix 3460 0.0 0.3 259404 3584 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000038 sec, idle 1 sec]
zabbix 3461 0.0 0.3 259348 3604 ? S 14:07 0:00 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000012 sec, idle 1 sec]
zabbix 3465 0.0 0.3 259224 3796 ? S 14:07 0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.002393 sec, idle 3 sec]
zabbix 3466 0.0 0.3 259224 3796 ? S 14:07 0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000060 sec, idle 5 sec]
zabbix 3469 0.0 0.2 259224 2612 ? S 14:07 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000051 sec, idle 1 sec]
zabbix 3470 0.0 0.2 259224 2888 ? S 14:07 0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.001071 sec, idle 5 sec]
zabbix 3473 0.0 0.5 366976 5476 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000033 sec, idle 2 sec]
zabbix 3474 0.0 0.5 366976 5636 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000015 sec, idle 2 sec]
zabbix 3475 0.0 0.5 366976 5476 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000177 sec, idle 2 sec]
zabbix 3476 0.0 0.5 366976 5476 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000014 sec, idle 2 sec]
zabbix 3477 0.0 0.5 366976 5476 ? S 14:07 0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000085 sec, idle 2 sec]
zabbix 3478 0.0 0.5 366976 5584 ? S 14:07 0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000058 sec, idle 5 sec]
zabbix 3479 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix 3482 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix 3484 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix 3486 0.0 0.3 259224 3624 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
zabbix 3491 0.0 0.4 259388 4072 ? S 14:07 0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.005082 sec, waiting for connection]
zabbix 3494 0.0 0.2 262600 2612 ? S 14:07 0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000049 sec, idle 5 sec]
zabbix 3495 0.0 0.3 259224 3292 ? S 14:07 0:00 /usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.025405 sec during 5.025597 sec]
zabbix 3497 0.0 0.3 259224 3264 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing manager #1 [queued 0, processed 0 values, idle 5.014181 sec during 5.014238 sec]
zabbix 3499 0.0 0.2 259224 2692 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing worker #1 started
zabbix 3500 0.0 0.2 259224 2692 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing worker #2 started
zabbix 3501 0.0 0.2 259224 2580 ? S 14:07 0:00 /usr/sbin/zabbix_server: preprocessing worker #3 started
zabbix 3568 0.0 0.1 80708 1296 ? S 14:20 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 3569 0.0 0.1 80708 1364 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 3570 0.0 0.2 80832 2444 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 3571 0.0 0.2 80832 2260 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 3572 0.0 0.2 80832 2420 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 3573 0.0 0.2 80840 2124 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 3596 0.0 0.0 112732 976 pts/0 S+ 14:24 0:00 grep --color=auto zabbix
不是zabbix-agent是zabbix_agent
[root@test01 ~]# ps aux |grep zabbix-agent
root 3601 0.0 0.0 112728 980 pts/0 R+ 14:25 0:00 grep --color=auto zabbix-agent
[root@test01 ~]# ps aux |grep zabbix_agent
zabbix 3568 0.0 0.1 80708 1296 ? S 14:20 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agend.conf
zabbix 3569 0.0 0.1 80708 1384 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 3570 0.0 0.2 80832 2472 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 3571 0.0 0.2 80832 2472 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 3572 0.0 0.2 80832 2424 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 3573 0.0 0.2 80840 2124 ? S 14:20 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 3606 0.0 0.0 112728 984 pts/0 R+ 14:26 0:00 grep --color=auto zabbix_agent
接下来是安装webUI,要启动httpd的服务,同样是监听80端口,需要先停用nginx
[root@test01 ~]# systemctl stop nginx 先停用nginx服务
[root@test01 ~]# systemctl start httpd 启动httpd服务
[root@test01 ~]# netstat -lntp 看一看httpd是否监听了80端口
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 1027/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1741/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 3568/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3447/zabbix_server
tcp6 0 0 :::3306 :::* LISTEN 1273/mysqld
tcp6 0 0 :::80 :::* LISTEN 3639/httpd
tcp6 0 0 :::22 :::* LISTEN 1027/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1741/master
tcp6 0 0 :::10050 :::* LISTEN 3568/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 3447/zabbix_server
用浏览器直接用ip访问 192.168.28.107/zabbix
以下是截图
按next step,下一步会出现问题 date timezone,要去 vim /etc/php.ini里面定义时区(因httpd是yum安装的,要改php.ini的配置文件在etc下,如果是LNMP的话,它的php.ini会在/usr/local/php-fpm/etc/php.ini,路径是不一样的)
改完后重启一下
[root@test01 ~]# systemctl restart httpd
刷新一下看会不会再报错
继续点next step
这一步有默认密码 admin zabbix,最好把默认密码改一下。默认密码总是不安全的
点一下小人图标,点change password 就可以改密码了。也可以改语言 ,改好后,点update