Zabbix介绍

为什么要监控

我们的职责

1. 保障企业数据的安全可靠。

2. 为客户提供7*24小时服务

3. 不断提升用户体验

在关键时刻,提前提醒我们服务器要出问题了

当出问题之后,可以便于找到问题的根源

怎么来监控

远程管理服务器有远程管理卡,比如Dell idRAC,HP ILO,IBM IMM

查看硬件的温度/风扇转速,电脑有鲁大师,服务器就有opmitool。使用ipmitool实现对服务器的命令行远程管理

ü  yum -y install OpenIPMI ipmitool  àIPMI在物理机可以成功,虚拟机不行

CPU性能好不好、忙不忙可以用lscpu、uptime、top、htop。

内存够不够可以用free

磁盘剩多少写的快不快可以用df、dd、iotop

网络太卡找iftop,nethogs

监控工具总览

mrtg     流量监控出图

nagios   监控

cacti    流量监控出图

zabbix   监控+出图,所有监控范畴,都可以整合到Zabbix中。

硬件监控:Zabbix  IPMI  Interface

系统监控:Zabbix  Agent  Interface

Java监控:Zabbix  JMX  Interfaca

网络设备监控:Zabbix  SNMP  Interface

应用服务监控:Zabbix  Agent  UserParameter

MySQL数据库监控:percona-monitoring-plulgins

URL监控:Zabbix Web 监控


初体验

环境检查

[root@m01 ~]# getenforce
Disabled
[root@m01 ~]# systemctl status firewalld.service
●
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@m01 ~]# hostname -I
10.0.0.61 172.16.1.61
安装zabbix服务端

安装zabbix官方源
[root@m01 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.pYOCq8: 头V4 DSA/SHA1 Signature, 密钥
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.0-1.el7         ################################# [100%]
[root@m01 ~]# yum install zabbix-server-mysql zabbix-web-mysql
作为依赖被安装:
  OpenIPMI-libs.x86_64 0:2.0.19-15.el7                  OpenIPMI-modalias.x86_64 0:2.0.19-15.el7               
  dejavu-fonts-common.noarch 0:2.33-6.el7                  dejavu-sans-fonts.noarch 0:2.33-6.el7                 
  fontpackages-filesystem.noarch 0:1.44-8.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                               libX11.x86_64 0:1.6.5-1.el7                           
  libX11-common.noarch 0:1.6.5-1.el7                       libXau.x86_64 0:1.0.8-2.1.el7                         
  libXpm.x86_64 0:3.5.12-1.el7                             libpng.x86_64 2:1.5.13-7.el7_2                        
  libxcb.x86_64 0:1.12-1.el7                               libzip.x86_64 0:0.10.1-8.el7                          
  mailcap.noarch 0:2.1.41-2.el7                            net-snmp-libs.x86_64 1:5.7.2-28.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                        
  zabbix-web.noarch 0:3.0.13-2.el7
Yum安装数据库

数据库安装
[root@m01 ~]# yum -y install mariadb-server
[root@m01 ~]# systemctl start mariadb.service
[root@m01 ~]# ls /var/lib/mysql/
aria_log.00000001  ibdata1      ib_logfile1  mysql.sock          test
aria_log_control   ib_logfile0  mysql        performance_schema
创建数据库,权限
[root@m01 ~]# mysql
 
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
 
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> exit
Bye
导入数据库sql文件
[root@m01 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz|mysql -uzabbix -pzabbix zabbix


配置zabbix-server

配置zabbix server连接mysql
[root@m01 ~]# sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
[root@m01 ~]# grep  "^[a-Z]" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
修改默认时区
[root@m01 ~]# sed -i.ori '18a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
启动服务
[root@m01 ~]# systemctl start zabbix-server
[root@m01 ~]# systemctl start httpd
查看是否启动
[root@m01 ~]# tailf /var/log/zabbix/zabbix_server.log
 17821:20180112:105043.229 server #17 started [timer #1]
 17822:20180112:105043.242 server #18 started [http poller #1]
 17823:20180112:105043.243 server #19 started [discoverer #1]
 17826:20180112:105043.254 server #21 started [history syncer #2]
 17827:20180112:105043.255 server #22 started [history syncer #3]
 17825:20180112:105043.257 server #20 started [history syncer #1]
 17833:20180112:105043.282 server #24 started [escalator #1]
 17832:20180112:105043.286 server #23 started [history syncer #4]
 17834:20180112:105043.288 server #25 started [proxy poller #1]
 17838:20180112:105043.303 server #26 started [self-monitoring #1]
开机自启
[root@m01 ~]# systemctl enable zabbix-server.service httpd.service mariadb.service
网页操作

打开网页

zabbix起不来_zabbix起不来

加上端口与密码   

密码zabbix

zabbix起不来_php_02

取名

zabbix起不来_数据库_03

登录

zabbix起不来_java_04


翻译成中文

zabbix起不来_运维_05

zabbix起不来_php_06

客户端部署

服务端客户端都要装,都要监控

[root@cache01 ~]# echo "192.168.11.200 repo.zabbix.com" >> /etc/hosts
[root@cache01 ~]#  rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.bs0Ggb: 头V4 DSA/SHA1 Signature, 密钥
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.0-1.el7         ################################# [100%]
客户端软件
[root@cache01 ~]# yum -y install zabbix-agent
修改配置文件
[root@cache01 ~]# sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf
启动
[root@cache01 ~]# systemctl start zabbix-agent.service
测试客户端是否可用
服务端
[root@m01 ~]# yum install -y zabbix-get
[root@m01 ~]# zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]"
0.060000
[root@m01 ~]# zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000

Web添加服务端

zabbix起不来_php_07

点进原有的zabbix-server主机

zabbix起不来_运维_08

zabbix起不来_数据库_09

zabbix起不来_运维_10

刷新出绿色就好了、

zabbix起不来_php_11

zabbix起不来_运维_12

zabbix起不来_zabbix起不来_13

zabbix起不来_zabbix起不来_14

zabbix起不来_zabbix起不来_15

zabbix起不来_php_16

解决乱码

[root@m01 ~]# yum -y install wqy-microhei-fonts

[root@m01 ~]# \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

zabbix起不来_数据库_17

zabbix起不来_php_18

监控的时间越长,东西显示的更多


转载于:https://blog.51cto.com/13554498/2060555