|
- 19.1 Linux监控平台介绍
- 19.2 zabbix监控介绍
- 19.3/19.4/19.6 安装zabbix
- 19.5 忘记Admin密码如何做
19.1 Linux监控平台介绍
- 监控存在的原因
- 站点出了问题,没有人知道,等用户发现了,才提醒供应商;对公司影响很大
- 常见开源监控软件
- cacti、nagios、zabbix、smokeping、open-falcon等等 //主流 nagios、zabbix
- cacti、smokeping偏向于基础监控,成图非常漂亮 //比较适合监控网络设备
- cacti、nagios、zabbix服务端监控中心,需要php环境支持,其中zabbix和cacti都需要mysql作为数据存储,nagios不用存储历史数据,注重服务或者监控项的状态,zabbix会获取服务或者监控项目的数据,会把数据记录到数据库里,从而可以成图;
- 因为zabbix配置简单,优势明显,早起使用nagios的企业,慢慢的转向使用zabbix
- nagios,需要更改配置文件,并不支持web界面一键执行,nagios和zabbix相比,nagios 更注重的是某一个监控的状态,不关注历史;zabbix,则是把每一次监控的数值反馈出来,方便后期数据图去分析监控整个状态;nagios不支持mysql,需要安装插件以后才支持web界面;zabbix 支持mysql,可以成图,可以记录历史数据
- zabbix 在web界面下管理得非常彻底,可以增加监控节点,报警预知等等
- open-falcon为小米公司开发,开源后受到诸多大公司和运维工程师的追捧,适合大企业,滴滴、360、新浪微博、京东等大公司在使用这款监控软件,监控的思想和结构值得研究
- 后续以介绍zabbix为主
19.2 zabbix监控介绍
- C/S架构,基于C++开发,监控中心支持web界面配置和管理
- 单server节点可以支持上万台客户端
- 最新版本3.4,官方文档https://www.zabbix.com/manuals
- 5个组件
- zabbix-server 监控中心,接收客户端上报信息,负责配置、统计、操作数据
- 数据存储 存放数据,比如mysql
- web界面 也叫web UI,在web界面下操作配置是zabbix简单易用的主要原因
- zabbix-proxy 可选组件,它可以代替zabbix-server的功能,减轻server的压力
- zabbix-agent 客户端软件,负责采集各个监控服务或项目的数据,并上报
- 最新版本3.4,官方文档https://www.zabbix.com/manuals 5个组件 zabbix-server 监控中心,接收客户端上报信息,负责配置、统计、操作数据 数据存储 存放数据,比如mysql
web界面 也叫web UI,在web界面下操作配置是zabbix简单易用的主要原因 zabbix-proxy 可选组件,它可以代替zabbix-server的功能,减轻server的压力 zabbix-agent 客户端软件(每一台客户端都需要安装),负责采集各个监控服务或项目的数据,并上报
监控流程图:
19.3 安装zabbix(上)
- 安装之前要准备俩台机器,一台服务端,一台客户端,这里我们用aming-01 服务端,aming-02 客户端
- 默认yum安装的zabbix版本是2.2的太旧,所以选择安装官方提供的repo源
- wget http://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@aming-01 ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
--2017-11-15 22:25:32--
正在解析主机 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 用时 0s
2017-11-15 22:25:34 (100 MB/s) -
已保存 “zabbix-release-3.2-1.el7.noarch.rpm” [13392/13392])
[root@aming-01 ~]#
[root@aming-01 ~]# 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%]
[root@aming-01 ~]#
[root@aming-02 ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
--2017-11-15 22:25:38--
正在解析主机 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
4.18KB/s 用时 3.1s
2017-11-15 22:25:46 (4.18 KB/s) -
已保存 “zabbix-release-3.2-1.el7.noarch.rpm” [13392/13392])
[root@aming-02 ~]#
[root@aming-02 ~]# 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%]
[root@aming-02 ~]#
- 然后可以看到/etc/yum.repos.d 目录下多了一个 zabbix.repo,这个其实就是刚刚我们安装的rpm包所安装的一个文件,有了这个源之后,就可以直接yum 安装zabbix了。
[root@aming-01 ~]# cat /etc/yum.repos.d/CentOS-Base.repo CentOS-Media.repo epel-testing.repo
CentOS-CR.repo CentOS-Sources.repo zabbix.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
CentOS-fasttrack.repo epel.repo.1
[root@aming-01 ~]# cat /etc/yum.repos.d/zabbix.repo [zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[root@aming-01 ~]#
- yum安装zabbix 的包,都有哪些包呢
- 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,这个是web界面,zabbix-server-mysql ,web和mysql打交道,安装一些web和mysql打交道的一些东西
[root@aming-01 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
已安装: zabbix-agent.x86_64 0:3.2.10-2.el7 zabbix-get.x86_64 0:3.2.10-2.el7
zabbix-server-mysql.x86_64 0:3.2.10-2.el7 zabbix-web.noarch 0:3.2.10-2.el7
zabbix-web-mysql.noarch 0:3.2.10-2.el7 作为依赖被安装: OpenIPMI-libs.x86_64 0:2.0.19-15.el7 OpenIPMI-modalias.x86_64 0:2.0.19-15.el7
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7
dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7
fping.x86_64 0:3.10-4.el7 httpd.x86_64 0:2.4.6-67.el7.centos.6
httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 iksemel.x86_64 0:1.4-6.el7
libXpm.x86_64 0:3.5.12-1.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3
libxslt.x86_64 0:1.1.28-5.el7 libzip.x86_64 0:0.10.1-8.el7
mailcap.noarch 0:2.1.41-2.el7 php.x86_64 0:5.4.16-42.el7
php-bcmath.x86_64 0:5.4.16-42.el7 php-cli.x86_64 0:5.4.16-42.el7
php-common.x86_64 0:5.4.16-42.el7 php-gd.x86_64 0:5.4.16-42.el7
php-ldap.x86_64 0:5.4.16-42.el7 php-mbstring.x86_64 0:5.4.16-42.el7
php-mysql.x86_64 0:5.4.16-42.el7 php-pdo.x86_64 0:5.4.16-42.el7
php-xml.x86_64 0:5.4.16-42.el7 t1lib.x86_64 0:5.1.2-14.el7
unixODBC.x86_64 0:2.3.1-11.el7 完毕![root@aming-01 ~]#
- 如果mysql之前没有安装的话,需要根据lamp那一章的mysql安装方法安装mysql,也可以直接yum安装mysql
- 因为我们之前已经安装过mysql,这里就省略了
- 先看下mysql有没有启动起来,没有就要启动
[root@aming-01 ~]# ps aux |grep mysql
root 1181 0.0 0.1 115392 1684 ? S 21:49 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/aming-01.pid
mysql 1700 0.1 45.5 1300844 455476 ? Sl 21:50 0:05 /usr/local/mysql/bin/mysqd --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/aming-01.err --pid-file=/data/mysql/aming-01.pid --socket=/tmp/mysql.sock
root 2922 0.0 0.0 112680 980 pts/0 R+ 23:20 0:00 grep --color=auto mysql
[root@aming-01 ~]#
- 接下来还需要编辑下mysql的配置文件,设定一个默认的字符集
- vim /etc/my.cnf //需要增加配置 character_set_server = utf8
- 如果不设置中文的话,到时候web界面中文显示就会有问题
[root@aming-01 ~]# vi /etc/my.cnf[mysqld]
character_set_server = utf8
datadir=/data/mysqlsocket=/tmp/mysql.sock
server-id=131log_bin=aminglinux1
# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-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
#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:wq
[root@aming-01 ~]# vi /etc/my.cnf
[root@aming-01 ~]#
[root@aming-01 ~]# systemctl restart mysql
[root@aming-01 ~]#
- 然后进入mysql命令行,创建zabbix库 create database zabbix character set utf8;
- 再创建用户 grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'aming-zabbix';
[root@aming-01 ~]# mysql -uroot -paminglinux
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1Server version: 5.6.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>
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 (0.00 sec)
mysql> quit
Bye
[root@aming-01 ~]#
- 导入数据
- cd /usr/share/doc/zabbix-server-mysql-3.2.7
- 给他解压一下 gzip -d create.sql.gz
- 导入文件mysql -uroot -pxxx zabbix < create.sql
[root@aming-01 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.10/
[root@aming-01 zabbix-server-mysql-3.2.10]#
[root@aming-01 zabbix-server-mysql-3.2.10]# lsAUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@aming-01 zabbix-server-mysql-3.2.10]# gzip -d create.sql.gz
[root@aming-01 zabbix-server-mysql-3.2.10]# lsAUTHORS ChangeLog COPYING create.sql NEWS README
[root@aming-01 zabbix-server-mysql-3.2.10]# mysql -uroot -paminglinux zabbix < create.sql
Warning: Using a password on the command line interface can be insecure.
[root@aming-01 zabbix-server-mysql-3.2.10]#
[root@aming-01 ~]# systemctl start zabbix-server[root@aming-01 ~]#
- 还要启动httpd服务,但是在启动之前要检查下,系统里面有没有启动nginx服务,如果启动了nginx说明监听80端口 ,如果nginx服务启动了就要把它给关闭
[root@aming-01 ~]# ps aux |grep nginx
root 1095 0.0 0.1 45992 1180 ? Ss 21:49 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 1097 0.0 0.3 48480 3796 ? S 21:49 0:00 nginx: worker process
nobody 1098 0.0 0.3 48480 3808 ? S 21:49 0:00 nginx: worker process
root 3200 0.0 0.0 112680 980 pts/0 R+ 23:34 0:00 grep --color=auto nginx
[root@aming-01 ~]#
[root@aming-01 ~]# /etc/init.d/nginx stop
Stopping nginx (via systemctl): [ 确定 ]
[root@aming-01 ~]#
[root@aming-01 ~]# !psps aux |grep nginx
root 3222 0.0 0.0 112680 980 pts/0 R+ 23:35 0:00 grep --color=auto nginx
[root@aming-01 ~]# netstat -lntpActive 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:20048 0.0.0.0:* LISTEN 1136/rpc.mountd
tcp 0 0 0.0.0.0:50995 0.0.0.0:* LISTEN 991/rpc.statd
tcp 0 0 0.0.0.0:46261 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1065/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1792/master
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp6 0 0 :::3306 :::* LISTEN 3132/mysqld
tcp6 0 0 :::40463 :::* LISTEN 991/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20048 :::* LISTEN 1136/rpc.mountd
tcp6 0 0 :::39446 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN 1065/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1792/master
tcp6 0 0 :::2049 :::* LISTEN -
[root@aming-01 ~]#
- 看下有没有监听80端口,没有监听80端口就可以顺利的把httpd 服务启动起来,再来看有没有监听80端口
[root@aming-01 ~]# systemctl start httpd
[root@aming-01 ~]# !netnetstat -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:20048 0.0.0.0:* LISTEN 1136/rpc.mountd
tcp 0 0 0.0.0.0:50995 0.0.0.0:* LISTEN 991/rpc.statd
tcp 0 0 0.0.0.0:46261 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1065/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1792/master
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp6 0 0 :::3306 :::* LISTEN 3132/mysqld
tcp6 0 0 :::40463 :::* LISTEN 991/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 3230/httpd
tcp6 0 0 :::20048 :::* LISTEN 1136/rpc.mountd
tcp6 0 0 :::39446 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN 1065/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1792/master
tcp6 0 0 :::2049 :::* LISTEN -
[root@aming-01 ~]#
- 那么如果以后想要httpd开机启动,还有zabbix-server 还需要把它加入到服务的启动列表里面去
[root@aming-01 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.
target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@aming-01 ~]# 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.
[root@aming-01 ~]#
[root@aming-01 ~]# systemctl disable nginx
nginx.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nginx off
[root@aming-01 ~]#
[root@aming-01 ~]# chkconfig nginx off
[root@aming-01 ~]#
[root@aming-01 ~]# ps aux |grep zabbix
zabbix 3197 0.0 0.3 256076 3448 ? S 23:33 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
root 3365 0.0 0.0 112680 980 pts/0 R+ 23:40 0:00 grep --color=auto zabbix
[root@aming-01 ~]#
[root@aming-01 ~]# !netnetstat -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:20048 0.0.0.0:* LISTEN 1136/rpc.mountd
tcp 0 0 0.0.0.0:50995 0.0.0.0:* LISTEN 991/rpc.statd
tcp 0 0 0.0.0.0:46261 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1065/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1792/master
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp6 0 0 :::3306 :::* LISTEN 3132/mysqld
tcp6 0 0 :::40463 :::* LISTEN 991/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 3230/httpd
tcp6 0 0 :::20048 :::* LISTEN 1136/rpc.mountd
tcp6 0 0 :::39446 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN 1065/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1792/master
tcp6 0 0 :::2049 :::* LISTEN -
[root@aming-01 ~]#
- 进程还在,但是没有看到zabbix的监听的端口,说明有问题,下节来看下问题出在哪里
[root@aming-01 ~]# !psps aux |grep zabbix
zabbix 3197 0.0 0.3 256076 3448 ? S 23:33 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
root 3369 0.0 0.0 112680 980 pts/0 R+ 23:42 0:00 grep --color=auto zabbix
[root@aming-01 ~]#19.4 安装zabbix(中)
- 接着上面的问题,没有查到zabbix 监听的端口,可以查看下它的日志,
[root@aming-01 ~]# less /var/log/zabbix/zabbix_server.log
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)~
~
~
~
(END)
- 说明不能连接mysql ,所以还需要去改下配置文件
- vim /etc/zabbix/zabbix_server.conf //修改或增加
- DBHost=127.0.0.1 //在DBName=zabbix上面增加 ,搜索DBHost
- DBPassword=aming-zabbix //在DBuser下面增加
### 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=localhostDBHost=127.0.0.1
### Option: DBName-- 插入 --
- 这里的ip写多少127.0.0.1 ,也可以写localhost
- 因为mysql和zabbix装在同一台机器上,这里可以写localhost或者127.0.0.1;如果是在生产环境上,有时候为了提升zabbix的性能,可能会把MySQL装在其他机器上,这是的DBHost,就需要写上mysql的ip
DBUser=zabbix
DBPassword=aming-zabbix
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.-- 插入 --
[root@aming-01 ~]# vim /etc/zabbix/zabbix_server.conf
root@aming-01 ~]#
- 这个地方的DBPassword=aming-zabbix 是指的咱们授权的时候用的密码
- 更改完这几项就可以启动服务了,之前启动过,这里重启一下就ok
[root@aming-01 ~]# systemctl restart zabbix-server
[root@aming-01 ~]# !psps aux |grep zabbix
zabbix 3407 3.1 0.4 256256 4136 ? S 23:54 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix 3410 0.0 0.2 256256 2468 ? S 23:54 0:00 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes]
zabbix 3411 0.0 0.2 256256 2680 ? S 23:54 0:00 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.012940 sec, idle 60 sec]
zabbix 3412 0.5 0.5 363204 5200 ? S 23:54 0:00 /usr/sbin/zabbix_server: poller
#1 [got 0 values in 0.000004 sec, idle 5 sec]zabbix 3413 0.4 0.5 363204 5200 ? S 23:54 0:00 /usr/sbin/zabbix_server: poller
#2 [got 0 values in 0.000005 sec, idle 5 sec]zabbix 3414 0.5 0.5 363204 5200 ? S 23:54 0:00 /usr/sbin/zabbix_server: poller
#3 [got 0 values in 0.000006 sec, idle 5 sec]zabbix 3415 0.5 0.5 363204 5200 ? S 23:54 0:00 /usr/sbin/zabbix_server: poller
#4 [got 0 values in 0.000007 sec, idle 5 sec]zabbix 3416 0.5 0.5 363204 5200 ? S 23:54 0:00 /usr/sbin/zabbix_server: poller
#5 [got 0 values in 0.000005 sec, idle 5 sec]zabbix 3417 0.4 0.5 363204 5200 ? S 23:54 0:00 /usr/sbin/zabbix_server: unreachable poller
#1 [got 0 values in 0.000005 sec, idle 5 sec]zabbix 3418 0.0 0.3 256256 3584 ? S 23:54 0:00 /usr/sbin/zabbix_server: trapper
#1 [processed data in 0.000000 sec, waiting for connection]zabbix 3419 0.0 0.3 256256 3584 ? S 23:54 0:00 /usr/sbin/zabbix_server: trapper
#2 [processed data in 0.000000 sec, waiting for connection]zabbix 3420 0.0 0.3 256256 3584 ? S 23:54 0:00 /usr/sbin/zabbix_server: trapper
#3 [processed data in 0.000000 sec, waiting for connection]zabbix 3422 0.0 0.3 256256 3584 ? S 23:54 0:00 /usr/sbin/zabbix_server: trapper
#4 [processed data in 0.000000 sec, waiting for connection]zabbix 3424 0.0 0.3 256256 3584 ? S 23:54 0:00 /usr/sbin/zabbix_server: trapper
#5 [processed data in 0.000000 sec, waiting for connection]zabbix 3426 0.0 0.2 258832 2620 ? S 23:54 0:00 /usr/sbin/zabbix_server: icmp pinger
#1 [got 0 values in 0.000006 sec, idle 5 sec]zabbix 3427 0.0 0.2 256256 2688 ? S 23:54 0:00 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.110521 sec, idle 30 sec]
zabbix 3428 0.0 0.2 256256 2468 ? S 23:54 0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
zabbix 3429 0.0 0.2 256256 2688 ? S 23:54 0:00 /usr/sbin/zabbix_server: timer
#1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 15 sec]zabbix 3430 0.0 0.2 256256 2840 ? S 23:54 0:00 /usr/sbin/zabbix_server: http poller
#1 [got 0 values in 0.001036 sec, idle 5 sec]zabbix 3431 0.2 0.5 360620 5040 ? S 23:54 0:00 /usr/sbin/zabbix_server: discoverer
#1 [processed 0 rules in 0.066387 sec, idle 60 sec]zabbix 3432 0.0 0.2 256256 2828 ? S 23:54 0:00 /usr/sbin/zabbix_server: history syncer
#1 [synced 0 items in 0.000001 sec, idle 1 sec]zabbix 3433 0.0 0.2 256256 2828 ? S 23:54 0:00 /usr/sbin/zabbix_server: history syncer
#2 [synced 0 items in 0.000003 sec, idle 1 sec]zabbix 3434 0.0 0.2 256256 2828 ? S 23:54 0:00 /usr/sbin/zabbix_server: history syncer
#3 [synced 0 items in 0.000002 sec, idle 1 sec]zabbix 3441 0.0 0.2 256256 2828 ? S 23:54 0:00 /usr/sbin/zabbix_server: history syncer
#4 [synced 0 items in 0.000003 sec, idle 1 sec]zabbix 3442 0.0 0.3 256256 3764 ? S 23:54 0:00 /usr/sbin/zabbix_server: escalator
#1 [processed 0 escalations in 0.001375 sec, idle 3 sec]zabbix 3443 0.0 0.3 256256 3760 ? S 23:54 0:00 /usr/sbin/zabbix_server: proxy poller
#1 [exchanged data with 0 proxies in 0.000005 sec, idle 5 sec]zabbix 3444 0.0 0.2 256256 2588 ? S 23:54 0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000007 sec, idle 1 sec]
zabbix 3445 0.0 0.2 256256 2812 ? S 23:54 0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.001277 sec, idle 5 sec]
root 3458 0.0 0.0 112680 980 pts/0 R+ 23:54 0:00 grep --color=auto zabbix
[root@aming-01 ~]#
- 再来看下监听的端口,zabbix 应该监听10051端口
[root@aming-01 ~]# !netnetstat -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:20048 0.0.0.0:* LISTEN 1136/rpc.mountd
tcp 0 0 0.0.0.0:50995 0.0.0.0:* LISTEN 991/rpc.statd
tcp 0 0 0.0.0.0:46261 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1065/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1792/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 3407/zabbix_server
tcp6 0 0 :::3306 :::* LISTEN 3132/mysqld
tcp6 0 0 :::40463 :::* LISTEN 991/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 3230/httpd
tcp6 0 0 :::20048 :::* LISTEN 1136/rpc.mountd
tcp6 0 0 :::39446 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN 1065/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1792/master
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::10051 :::* LISTEN 3407/zabbix_server
[root@aming-01 ~]#
- 接下来需要配置web界面了,打开浏览器
- 输入你的ip地址也就是你的监控中心的ip地址 192.168.202.130/zabbix
- 进入到这个安装界面点next step 就可以了
- 这里会出现一个提示,ok的就不用管,fail的,显然需要你设置它的时区,date.timezone
- date.timezone写 亚洲上海,或者亚洲北京、重庆 date.timezone = Asia/Shanghai
[root@aming-01 ~]# vi /etc/php.ini
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[CLI Server]
; Whether the CLI web server uses ANSI color coding in its terminal output.
cli_server.color = On
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezonedate.timezone = Asia/Shanghai
; http://php.net/date.default-latitude
;date.default_latitude = 31.7667; http://php.net/date.default-longitude
;date.default_longitude = 35.2333; http://php.net/date.sunrise-zenith
-- INSERT --
[root@aming-01 ~]# vi /etc/php.ini
[root@aming-01 ~]#
- 定义完之后,重新httpd服务,然后再去浏览器刷新
[root@aming-01 ~]# systemctl restart httpd
[root@aming-01 ~]#
- 最终让你看看你填的信息
- 恭喜你已经成功安装了zabbix前端
- 然后点几finish 登录
- 默认的用户名 admin 密码 zabbix
- 登录进去之后首先要去更改密码,因为这个密码大家都知道,是默认的密码,如果以后线上的密码不更改,那就很危险,很有可能被别人那道权限,
- 进去点change password
- 这时候密码改了,还没有变成中文,需要刷新下
- 我们退出来重进下
- 这个就是咱么的zabbix web界面了,这个时候因为你还么有加入任何的监控主机,所以也没有什么数据。
19.5 忘记Admin密码如何做
- 进入mysql的
- mysql -uroot -paminglinux;
- 进入zabbix库
- use zabbix;
- 查看所有表
- show tables
[root@aming-01 ~]# mysql -uroot -paminglinux
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.6.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>
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>
- 以后监控的服务器,监控的主机很多的话,这些表会越来越大,所有需要指定合适的监控规则、策略,比如数据量需要保留多长时间,那么在定义这个监控项目的时候就该想到,比如要保留1个月、还是1年,还是其他时间;可能,监控的站点服务量很大的话,一天就要涨好几个G,那么你的服务器磁盘能支持保存多长时间;
- 密码默认存放的表是users里面
- 查看表 desc users;
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>
- 我们需要修改的就是passwd的表
- 修改密码 update users set passwd=md5('aminglinux') where alias='Admin';
mysql> update users set passwd=md5('lishiming1') where alias='Admin';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
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 | 148308853a00bdc6ed461689d4c72649 | | 1 | 0 | zh_CN | 30 | 3 | default | 0 | | 0 | 50 |
| 2 | guest | | | d41d8cd98f00b204e9800998ecf8427e | | 0 | 900 | en_GB | 30 | 1 | default | 0 | | 0 | 50 |
+--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+------------+---------------+---------------+
2 rows in set (0.00 sec)
mysql>
- 这个时候就可以去使用新的密码(lishiming1)浏览器登录zabbix
- 这就是怎么样去重置你的zabbix管理员密码
19.6 安装zabbix(下)
- Zabbix客户端安装
- 在客户端上也需要下载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
- yum install -y zabbix-agent
- 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界面下设置同样的主机名
- systemctl start zabbix-agent
- systemctl enable zabbix-agent
- 由于我们之前已经下载 、安装了zabbix yum源
- 接下来直接yum 安装 zabbix-agent 组件
[root@aming-02 ~]# yum install -y zabbix-agent
已加载插件:fastestmirror
base | 3.6 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/3): extras/7/x86_64/primary_db | 130 kB 00:00:00
(2/3): zabbix/x86_64/primary_db | 82 kB 00:00:02
(3/3): updates/7/x86_64/primary_db | 3.6 MB 00:00:08
zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
zabbix-non-supported
4/4正在解决依赖关系--> 正在检查事务---> 软件包
zabbix-agent.x86_64.0.3.2.10-2.el7 将被 安装-->
解决依赖关系完成依赖关系解决=======================================================================================================
Package 架构 版本 源 大小
=======================================================================================================
正在安装: zabbix-agent x86_64 3.2.10-2.el7 zabbix 347 k
事务概要=======================================================================================================安装 1
软件包总下载量:347 k安装大小:1.3 M
Downloading packages:警告:/var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-3.2.10-2.el7.x86_64.
rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
zabbix-agent-3.2.10-2.el7.x86_64.rpm 的公钥尚未安装zabbix-agent-3.2.10-2.el7.x86_64.rpm
| 347 kB 00:00:13
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 检索密钥导入 GPG key 0xA14FE591:
用户ID : "Zabbix LLC "
指纹 : 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-A14FE591Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : zabbix-agent-3.2.10-2.el7.x86_64
1/1 验证中 : zabbix-agent-3.2.10-2.el7.x86_64
1/1 已安装: zabbix-agent.x86_64 0:3.2.10-2.el7
完毕!
[root@aming-02 ~]#
- 安装好后,修改配置文件vim /etc/zabbix/zabbix_agentd.conf
- 修改三个地方
- 1.在客户端指定一个白名单 Hostname=aming-02 //方便服务中心识别客户端机器
-
- Server=192.168.202.130 //ip为监控中心的IP
- ServerActive=192.168.202.130//这个涉及到一个主动和被动模式;如果这里不填写服务中心的IP,那么就只能使用被动模式;这个IP是主动模式时候用的
[root@aming-02 ~]# vim /etc/zabbix/zabbix_agentd.conf
# Mandatory: no# Default:
# Hostname=Hostname=aming-0
2### Option: HostnameItem
# Mandatory: no
# Default:
# Server=Server=192.168.202.130
# Mandatory: no
# Default:
# ServerActive=ServerActive=192.168.202.130:wq
[root@aming-02 ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@aming-02 ~]#
[root@aming-02 ~]# systemctl start zabbix-agent
[root@aming-02 ~]# ps aux |grep zabbix
zabbix 2377 0.0 0.1 80608 1256 ? S 20:27 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 2378 0.0 0.1 80608 1288 ? S 20:27 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 2379 0.0 0.1 80608 1836 ? S 20:27 0:00 /usr/sbin/zabbix_agentd: listener #1
[waiting for connection]zabbix
2380 0.0 0.1 80608 1836 ?
S 20:27 0:00 /usr/sbin/zabbix_agentd: listener
2 [waiting for connection]zabbix 2381 0.0 0.1 80608 1836 ? S 20:27 0:00 /usr/sbin/zabbix_agentd: listener #3
[waiting for connection]zabbix
2382 0.0 0.2 80608 2180 ? S 20:27 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]root
2384 0.0 0.0 112680 980 pts/0 R+ 20:28 0:00 grep --color=auto zabbix
[root@aming-02 ~]#
- 查看下监听的端口,这个端口是10050,客户端, 服务端端口是10051
[root@aming-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:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1742/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2065/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2377/zabbix_agentd
tcp6 0 0 :::3306 :::* LISTEN 2002/mysqld
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::22 :::* LISTEN 1742/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2065/master
tcp6 0 0 :::10050 :::* LISTEN 2377/zabbix_agentd
[root@aming-02 ~]#
|
|