blovekyo 发表于 2019-1-24 06:33:07

19.1 Linux监控平台介绍 19.2 zabbix监控介绍 19.3/19.4/19.6 安装zabbix 19.5 忘记Admin密码如何做


[*]  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/manuals5个组件 zabbix-server 监控中心,接收客户端上报信息,负责配置、统计、操作数据 数据存储 存放数据,比如mysql
web界面 也叫web UI,在web界面下操作配置是zabbix简单易用的主要原因 zabbix-proxy 可选组件,它可以代替zabbix-server的功能,减轻server的压力 zabbix-agent 客户端软件(每一台客户端都需要安装),负责采集各个监控服务或项目的数据,并上报
监控流程图:

[*]http://oqxf7c508.bkt.clouddn.com/blog/20171115/204946019.png?imageslim
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
# 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)
正在保存至: “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” )
#
# 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准备中...                        #################################
正在升级/安装...   1:zabbix-release-3.2-1.el7         #################################
#

[*]  客户端
# 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)
正在保存至: “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” )
#

# 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准备中...                        #################################
正在升级/安装...   1:zabbix-release-3.2-1.el7         #################################
#

[*]  然后可以看到/etc/yum.repos.d 目录下多了一个 zabbix.repo,这个其实就是刚刚我们安装的rpm包所安装的一个文件,有了这个源之后,就可以直接yum 安装zabbix了。
# cat /etc/yum.repos.d/CentOS-Base.repo       CentOS-Media.repo      epel-testing.repo
CentOS-CR.repo         CentOS-Sources.repo    zabbix.repo
CentOS-Debuginfo.repoCentOS-Vault.repo      
CentOS-fasttrack.repoepel.repo.1            
# cat /etc/yum.repos.d/zabbix.repo
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

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
#

[*]  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打交道的一些东西
# 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               完毕!#

[*]  如果mysql之前没有安装的话,需要根据lamp那一章的mysql安装方法安装mysql,也可以直接yum安装mysql
[*]  因为我们之前已经安装过mysql,这里就省略了
[*]  先看下mysql有没有启动起来,没有就要启动
# ps aux |grep mysql
root       11810.00.1 1153921684 ?      S    21:49   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/aming-01.pid
mysql      17000.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       29220.00.0 112680   980 pts/0    R+   23:20   0:00 grep --color=auto mysql
#

[*]  接下来还需要编辑下mysql的配置文件,设定一个默认的字符集
[*]  vim /etc/my.cnf //需要增加配置 character_set_server = utf8
[*]  如果不设置中文的话,到时候web界面中文显示就会有问题
# vi /etc/my.cnf
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
# vi /etc/my.cnf
#

[*]  然后重启下mysql
# systemctl restart mysql
#

[*]  然后进入mysql命令行,创建zabbix库 create database zabbix character set utf8;
[*]  再创建用户 grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'aming-zabbix';
# 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
#

[*]  导入数据
[*]  cd /usr/share/doc/zabbix-server-mysql-3.2.7
[*]  给他解压一下 gzip -d create.sql.gz
[*]  导入文件mysql -uroot -pxxx zabbix < create.sql
# cd /usr/share/doc/zabbix-server-mysql-3.2.10/
#
# lsAUTHORSChangeLogCOPYINGcreate.sql.gzNEWSREADME
# gzip -d create.sql.gz
# lsAUTHORSChangeLogCOPYINGcreate.sqlNEWSREADME
# mysql -uroot -paminglinux zabbix < create.sql
Warning: Using a password on the command line interface can be insecure.
#

[*]  启动zabbix 服务
# systemctl start zabbix-server#

[*]  还要启动httpd服务,但是在启动之前要检查下,系统里面有没有启动nginx服务,如果启动了nginx说明监听80端口 ,如果nginx服务启动了就要把它给关闭
# ps aux |grep nginx
root       10950.00.1459921180 ?      Ss   21:49   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   10970.00.3484803796 ?      S    21:49   0:00 nginx: worker process
nobody   10980.00.3484803808 ?      S    21:49   0:00 nginx: worker process
root       32000.00.0 112680   980 pts/0    R+   23:34   0:00 grep --color=auto nginx
#
# /etc/init.d/nginx stop
Stopping nginx (via systemctl):                            [确定]
#
# !psps aux |grep nginx
root       32220.00.0 112680   980 pts/0    R+   23:35   0:00 grep --color=auto nginx
# 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      -                  
#

[*]  看下有没有监听80端口,没有监听80端口就可以顺利的把httpd 服务启动起来,再来看有没有监听80端口
# systemctl start httpd
# !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      -                  
#

[*]  那么如果以后想要httpd开机启动,还有zabbix-server 还需要把它加入到服务的启动列表里面去
# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.
target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
# 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给它停掉
# systemctl disable nginx
nginx.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nginx off
#
# chkconfig nginx off
#

[*]  那服务端,咱们启动了起来了 看一看进程
# ps aux |grep zabbix
zabbix   31970.00.3 2560763448 ?      S    23:33   0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
root       33650.00.0 112680   980 pts/0    R+   23:40   0:00 grep --color=auto zabbix
#

[*]  还要看看zabbix有没有监听端口
# !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      -                  
#

[*]  进程还在,但是没有看到zabbix的监听的端口,说明有问题,下节来看下问题出在哪里
# !psps aux |grep zabbix
zabbix   31970.00.3 2560763448 ?      S    23:33   0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
root       33690.00.0 112680   980 pts/0    R+   23:42   0:00 grep --color=auto zabbix
#19.4 安装zabbix(中)

[*]  接着上面的问题,没有查到zabbix 监听的端口,可以查看下它的日志,
# less /var/log/zabbix/zabbix_server.log
to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)econnecting in 10 seconds
to database 'zabbix' failed: 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.-- 插入 --   
# vim /etc/zabbix/zabbix_server.conf
root@aming-01 ~]#

[*]  这个地方的DBPassword=aming-zabbix 是指的咱们授权的时候用的密码
[*]  更改完这几项就可以启动服务了,之前启动过,这里重启一下就ok
# systemctl restart zabbix-server
# !psps aux |grep zabbix
zabbix   34073.10.4 2562564136 ?      S    23:54   0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix   34100.00.2 2562562468 ?      S    23:54   0:00 /usr/sbin/zabbix_server: configuration syncer
zabbix   34110.00.2 2562562680 ?      S    23:54   0:00 /usr/sbin/zabbix_server: db watchdog
zabbix   34120.50.5 3632045200 ?      S    23:54   0:00 /usr/sbin/zabbix_server: poller
#1 zabbix   34130.40.5 3632045200 ?      S    23:54   0:00 /usr/sbin/zabbix_server: poller
#2 zabbix   34140.50.5 3632045200 ?      S    23:54   0:00 /usr/sbin/zabbix_server: poller
#3 zabbix   34150.50.5 3632045200 ?      S    23:54   0:00 /usr/sbin/zabbix_server: poller
#4 zabbix   34160.50.5 3632045200 ?      S    23:54   0:00 /usr/sbin/zabbix_server: poller
#5 zabbix   34170.40.5 3632045200 ?      S    23:54   0:00 /usr/sbin/zabbix_server: unreachable poller
#1 zabbix   34180.00.3 2562563584 ?      S    23:54   0:00 /usr/sbin/zabbix_server: trapper
#1 zabbix   34190.00.3 2562563584 ?      S    23:54   0:00 /usr/sbin/zabbix_server: trapper
#2 zabbix   34200.00.3 2562563584 ?      S    23:54   0:00 /usr/sbin/zabbix_server: trapper
#3 zabbix   34220.00.3 2562563584 ?      S    23:54   0:00 /usr/sbin/zabbix_server: trapper
#4 zabbix   34240.00.3 2562563584 ?      S    23:54   0:00 /usr/sbin/zabbix_server: trapper
#5 zabbix   34260.00.2 2588322620 ?      S    23:54   0:00 /usr/sbin/zabbix_server: icmp pinger
#1 zabbix   34270.00.2 2562562688 ?      S    23:54   0:00 /usr/sbin/zabbix_server: alerter
zabbix   34280.00.2 2562562468 ?      S    23:54   0:00 /usr/sbin/zabbix_server: housekeeper
zabbix   34290.00.2 2562562688 ?      S    23:54   0:00 /usr/sbin/zabbix_server: timer
#1 zabbix   34300.00.2 2562562840 ?      S    23:54   0:00 /usr/sbin/zabbix_server: http poller
#1 zabbix   34310.20.5 3606205040 ?      S    23:54   0:00 /usr/sbin/zabbix_server: discoverer
#1 zabbix   34320.00.2 2562562828 ?      S    23:54   0:00 /usr/sbin/zabbix_server: history syncer
#1 zabbix   34330.00.2 2562562828 ?      S    23:54   0:00 /usr/sbin/zabbix_server: history syncer
#2 zabbix   34340.00.2 2562562828 ?      S    23:54   0:00 /usr/sbin/zabbix_server: history syncer
#3 zabbix   34410.00.2 2562562828 ?      S    23:54   0:00 /usr/sbin/zabbix_server: history syncer
#4 zabbix   34420.00.3 2562563764 ?      S    23:54   0:00 /usr/sbin/zabbix_server: escalator
#1 zabbix   34430.00.3 2562563760 ?      S    23:54   0:00 /usr/sbin/zabbix_server: proxy poller
#1 zabbix   34440.00.2 2562562588 ?      S    23:54   0:00 /usr/sbin/zabbix_server: self-monitoring
zabbix   34450.00.2 2562562812 ?      S    23:54   0:00 /usr/sbin/zabbix_server: task manager
root       34580.00.0 112680   980 pts/0    R+   23:54   0:00 grep --color=auto zabbix
#

[*]  再来看下监听的端口,zabbix 应该监听10051端口
# !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
#

[*]  接下来需要配置web界面了,打开浏览器
[*]  输入你的ip地址也就是你的监控中心的ip地址 192.168.202.130/zabbix
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171115/235747236.png?imageslim
[*]  进入到这个安装界面点next step 就可以了
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171115/235844647.png?imageslim
[*]  这里会出现一个提示,ok的就不用管,fail的,显然需要你设置它的时区,date.timezone
[*]  date.timezone写 亚洲上海,或者亚洲北京、重庆 date.timezone = Asia/Shanghai
# vi /etc/php.ini

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

; Whether the CLI web server uses ANSI color coding in its terminal output.
cli_server.color = On

; 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 --
# vi /etc/php.ini
#

[*]  定义完之后,重新httpd服务,然后再去浏览器刷新
# systemctl restart httpd
#

[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001401877.png?imageslim
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001549100.png?imageslim
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001629248.png?imageslim
[*]  最终让你看看你填的信息
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001640899.png?imageslim
[*]  恭喜你已经成功安装了zabbix前端
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001705729.png?imageslim
[*]  然后点几finish 登录
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001735207.png?imageslim
[*]  默认的用户名 admin 密码 zabbix
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001823717.png?imageslim
[*]  登录进去之后首先要去更改密码,因为这个密码大家都知道,是默认的密码,如果以后线上的密码不更改,那就很危险,很有可能被别人那道权限,
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/001858826.png?imageslim
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/002021929.png?imageslim
[*]  进去点change password
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/002250959.png?imageslim
[*]  这时候密码改了,还没有变成中文,需要刷新下
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/002314890.png?imageslim
[*]  我们退出来重进下
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/002314890.png?imageslim
[*]  这个就是咱么的zabbix web界面了,这个时候因为你还么有加入任何的监控主机,所以也没有什么数据。
19.5 忘记Admin密码如何做

[*]  进入mysql的
[*]  mysql -uroot -paminglinux;
[*]  进入zabbix库
[*]  use zabbix;
[*]  查看所有表
[*]  show tables
# 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: 1Changed: 1Warnings: 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
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/200434433.png?imageslim
[*]http://oqxf7c508.bkt.clouddn.com/blog/20171116/200518398.png?imageslim
[*]  这就是怎么样去重置你的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 组件
# yum install -y zabbix-agent
已加载插件:fastestmirror
base                                                                            | 3.6 kB00:00:00   
extras                                                                        | 3.4 kB00:00:00   
updates                                                                         | 3.4 kB00:00:00   
zabbix                                                                        | 2.9 kB00:00:00   
zabbix-non-supported                                                            |951 B00:00:00   
(1/3): extras/7/x86_64/primary_db                                             | 130 kB00:00:00   
(2/3): zabbix/x86_64/primary_db                                                 |82 kB00:00:02   
(3/3): updates/7/x86_64/primary_db                                              | 3.6 MB00:00:08   
zabbix-non-supported/x86_64/primary                                             | 1.6 kB00: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 kB00: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                                                                  
完毕!
#

[*]安装好后,修改配置文件vim /etc/zabbix/zabbix_agentd.conf
[*]修改三个地方
[*]1.在客户端指定一个白名单 Hostname=aming-02 //方便服务中心识别客户端机器
[*]  


[*]  Server=192.168.202.130 //ip为监控中心的IP

[*]  ServerActive=192.168.202.130//这个涉及到一个主动和被动模式;如果这里不填写服务中心的IP,那么就只能使用被动模式;这个IP是主动模式时候用的
# 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
# vim /etc/zabbix/zabbix_agentd.conf
#

[*]  配置完成,启动服务,查看进程
# systemctl start zabbix-agent
# ps aux |grep zabbix
zabbix   23770.00.1806081256 ?      S    20:27   0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix   23780.00.1806081288 ?      S    20:27   0:00 /usr/sbin/zabbix_agentd: collector
zabbix   23790.00.1806081836 ?      S    20:27   0:00 /usr/sbin/zabbix_agentd: listener #1
zabbix   
23800.00.1806081836 ?      
S    20:27   0:00 /usr/sbin/zabbix_agentd: listener
2 zabbix   23810.00.1806081836 ?      S    20:27   0:00 /usr/sbin/zabbix_agentd: listener #3
zabbix   
23820.00.2806082180 ?      S    20:27   0:00 /usr/sbin/zabbix_agentd: active checks #1 root      
23840.00.0 112680   980 pts/0    R+   20:28   0:00 grep --color=auto zabbix
#

[*]  查看下监听的端口,这个端口是10050,客户端, 服务端端口是10051
# 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
#

[*]  到这里zabbix 客户端就安装结束了
  




页: [1]
查看完整版本: 19.1 Linux监控平台介绍 19.2 zabbix监控介绍 19.3/19.4/19.6 安装zabbix 19.5 忘记Admin密码如何做