监控平台及zabbix监控介绍
安装zabbix
1.下载安装包:
[root@weixing01 ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm--2018-04-13 01:44:59-- http://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|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:13392 (13K) [application/x-redhat-package-manager]
正在保存至: “zabbix-release-3.2-1.el7.noarch.rpm”
100%[===========================================================>] 13,392 --.-K/s 用时 0.001s
2018-04-13 01:45:04 (11.9 MB/s) - 已保存 “zabbix-release-3.2-1.el7.noarch.rpm” [13392/13392])
2.安装:
[root@weixing01 ~]# 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%]
3.安装服务端需要包:
yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
4.编辑配置文件:
[root@weixing01 ~]# vim /etc/my.cnf
[mysqld]
character_set_server = utf8
datadir=/data/mysql
socket=/tmp/mysql.sock
server-id=130
log_bin=weixing11
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d
~
5.重启服务:
[root@weixing01 ~]# systemctl restart mysqld.service
6.创建库:创建用户
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 'aming-zabbix';
Query OK, 0 rows affected (1.71 sec)
7.导入数据:
[root@weixing01 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@weixing01 zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@weixing01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[root@weixing01 zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql NEWS README
[root@weixing01 zabbix-server-mysql-3.2.11]# mysql -uroot -pwei914 zabbix < create.sql
Warning: Using a password on the command line interface can be insecure.
8.启动服务:
[root@weixing01 ~]# systemctl start zabbix-server
[root@weixing01 ~]# ps aux |grep nginx
root 924 0.0 0.1 45988 1168 ? Ss 08:36 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 927 0.0 0.4 48476 4016 ? S 08:36 0:00 nginx: worker process
nobody 928 0.0 0.3 48476 3784 ? S 08:36 0:00 nginx: worker process
root 1925 0.0 0.0 112676 984 pts/0 R+ 09:08 0:00 grep --color=auto nginx
[root@weixing01 ~]# /etc/init.d/nginx stop
Stopping nginx (via systemctl): [ 确定 ]
[root@weixing01 ~]# !ps
ps aux |grep nginx
root 1947 0.0 0.0 112676 984 pts/0 S+ 09:08 0:00 grep --color=auto nginx
[root@weixing01 ~]# !netst
netstat -lntp |grep java
[root@weixing01 ~]# 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:53611 0.0.0.0:* LISTEN 900/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 920/rpc.mountd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 887/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1168/master
tcp 0 0 0.0.0.0:45754 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20048 :::* LISTEN 920/rpc.mountd
tcp6 0 0 :::37970 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN 887/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1168/master
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::50248 :::* LISTEN 900/rpc.statd
tcp6 0 0 :::3306 :::* LISTEN 1705/mysqld
[root@weixing01 ~]# systemctl start httpd
9.设置开机启动:
[root@weixing01 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@weixing01 ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@weixing01 ~]# systemctl disable nginx
nginx.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nginx off
10.发现问题,未监听端口:修改配置文件
[root@weixing01 ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=127.0.0.1 //在DBName=zabbix上面增加
DBPassword=aming-zabbix //在DBuser下面增加
11.设置时区
[root@weixing01 ~]# vi /etc/php.ini
date.timezone = Asia/Shanghai
12.重启服务:
[root@weixing01 ~]# systemctl restart httpd
13.在网页按步骤配置密码:
14.客户端安装:
在客户端上也需要下载zabbix的yum源
wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
[root@weixing-03 ~]# yum install -y zabbix-agent
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink
15.编辑配置文件:
vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1修改为Server=192.168.133.130 //定义服务端的ip(被动模式)
ServerActive=127.0.0.1修改为ServerActive=192.168.133.130 //定义服务端的ip(主动模式)
Hostname=Zabbix server修改为Hostname=aming-123 //这是自定义的主机名,一会还需要在web界面下设置同样的主机名
16.启动服务:
[root@weixing-03 ~]# systemctl start zabbix-agent.service
[root@weixing-03 ~]# ps aux |grep zabbix
zabbix 1788 0.0 0.1 80664 1268 ? S 09:47 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbi_agentd.conf
zabbix 1789 0.0 0.1 80664 1304 ? S 09:47 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 1790 0.0 0.1 80664 1848 ? S 09:47 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 1791 0.0 0.1 80664 1848 ? S 09:47 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 1792 0.0 0.1 80664 1848 ? S 09:47 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 1793 0.0 0.2 80796 2212 ? S 09:47 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 1797 0.0 0.0 112676 980 pts/1 R+ 09:47 0:00 grep --color=auto zabbix
[root@weixing-03 ~]# 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:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 834/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1110/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1788/zabbix_agentd
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::22 :::* LISTEN 834/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1110/master
tcp6 0 0 :::10050 :::* LISTEN 1788/zabbix_agentd
tcp6 0 0 :::3306 :::* LISTEN 1047/mysqld