zabbix监控——ZABBIX服务器配置过程

生产中的服务器几乎是无监控不上线,开源实现方案中,zabbix属于后起之秀,的确接合zabbix提供的自定义接口能够比较方便的实现高灵活性的监控自己的业务细节,今天就给大家分享一下zabbix监控的搭建过程。
??

第一部分:linux命令行的安装配置

[[email protected]_aodun network-scripts]# vim ifcfg-em2
[[email protected]_aodun network-scripts]# cat ifcfg-em2
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=em2
DEVICE=em2
ONBOOT=no
IPADDR=192.168.193.180
NETMASK=255.255.255.0
[[email protected]_aodun network-scripts]# systemctl restart network
[[email protected]_aodun network-scripts]# ifconfig
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 125.211.210.180 netmask 255.255.255.192 broadcast 125.211.210.191
inet6 fe80::d6ae:52ff:fea7:fe62 prefixlen 64 scopeid 0x20<link>
ether d4:ae:52:a7:fe:62 txqueuelen 1000 (Ethernet)
RX packets 41 bytes 8543 (8.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 51 bytes 4058 (3.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

em2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.193.180 netmask 255.255.255.0 broadcast 192.168.193.255
ether d4:ae:52:a7:fe:63 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 15204 bytes 4227698 (4.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15204 bytes 4227698 (4.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[[email protected]_aodun network-scripts]# cd

[[email protected]_aodun ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 50G 0 part /
└─sda3 8:3 0 875G 0 part
└─centos-data 253:0 0 875G 0 lvm
[[email protected]_aodun ~]# mkdir /data
[[email protected]_aodun ~]# vim /etc/fstab
[[email protected]_aodun ~]# grep -v ^# /etc/fstab

UUID=017db6f7-0eb3-4047-b55b-c440b37b7036 / xfs defaults 0 0
UUID=541fd7d5-6e18-4d61-a548-58ba6c26e47d /boot xfs defaults 0 0
/dev/centos/data /data xfs defaults 0 0
[[email protected]_aodun ~]# mount -a
[[email protected]_aodun ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 50G 0 part /
└─sda3 8:3 0 875G 0 part
└─centos-data 253:0 0 875G 0 lvm /data
[[email protected]_aodun ~]# mkdir -pv /data/{mysql,log/mariadb}
mkdir: created directory ‘/data/mysql’
mkdir: created directory ‘/data/log’
mkdir: created directory ‘/data/log/mariadb’
[[email protected]_aodun ~]# yum install -y mariadb-server
[[email protected]_aodun ~]# cp /etc/my.cnf{,.bak}
[[email protected]_aodun ~]# vim /etc/my.cnf
[[email protected]_aodun ~]# grep -v ^# /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

innodb_file_per_table
skip_name_resolve

event_scheduler=ON
max_allowed_packet=50M

open_files_limit=4096
max_connections=500

[mysqld_safe]
log-error=/data/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

!includedir /etc/my.cnf.d
[[email protected]_aodun ~]# chown mysql:mysql /data/mysql/
[[email protected]_aodun ~]# chown mysql:mysql /data/log/mariadb/
[[email protected]_aodun ~]# ll /data/
total 0
drwxr-xr-x. 3 root root 20 May 19 02:11 log
drwxr-xr-x. 2 mysql mysql 6 May 19 02:03 mysql
[[email protected]_aodun ~]# ll /data/log/
total 0
drwxr-xr-x. 2 mysql mysql 6 May 19 02:03 mariadb
[[email protected]_aodun ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 :3306 :
LISTEN 0 100 127.0.0.1:25
:
LISTEN 0 128
:22022 :
LISTEN 0 0 ::1:25 :::
LISTEN 0 128 :::22022 :::

[[email protected]_aodun ~]# mysql_secure_installation
[[email protected]_aodun ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> create database zabbix;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to [email protected] identified by ‘[email protected]‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show grants for [email protected];
+---------------------------------------------------------------------------------------------------------------+
| Grants for [email protected] |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON . TO ‘zabbix‘@‘localhost‘ IDENTIFIED BY PASSWORD ‘FD810B324C560D38EB7E4BF80CD5FE680BC507D8‘ |
| GRANT ALL PRIVILEGES ON zabbix.
TO ‘zabbix‘@‘localhost‘ |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]>
MariaDB [(none)]> quit
Bye
[[email protected]_aodun ~]# yum install -y zabbix-server-mysql.x86_64 zabbix-get.x86_64
[[email protected]_aodun ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.2.6
/usr/share/doc/zabbix-server-mysql-3.2.6/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.2.6/COPYING
/usr/share/doc/zabbix-server-mysql-3.2.6/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.2.6/NEWS
/usr/share/doc/zabbix-server-mysql-3.2.6/README
/usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
[[email protected]_aodun ~]# gunzip /usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz
[[email protected]_aodun ~]# ll /usr/share/doc/zabbix-server-mysql-3.2.6
total 3832
-rw-r--r--. 1 root root 98 May 5 10:50 AUTHORS
-rw-r--r--. 1 root root 752936 May 5 10:50 ChangeLog
-rw-r--r--. 1 root root 17990 May 5 10:50 COPYING
-rw-r--r--. 1 root root 3137133 May 5 20:23 create.sql
-rw-r--r--. 1 root root 52 May 5 10:50 NEWS
-rw-r--r--. 1 root root 188 May 5 10:50 README
[[email protected]_aodun ~]# mysql -h127.0.0.1 -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-3.2.6/create.sql
Enter password:
[[email protected]_aodun ~]# mysql -h127.0.0.1 -uzabbix -p zabbix -e ‘show tables‘
Enter password:
+----------------------------+
| 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 |
+----------------------------+
[[email protected]_aodun ~]# cp /etc/zabbix/zabbix_server.conf{,.bak}
[[email protected]_aodun ~]# vim /etc/zabbix/zabbix_server.conf
[[email protected]_aodun ~]# grep -v ^# /etc/zabbix/zabbix_server.conf | tr -s [[:space:]]

SourceIP=192.168.193.180br/>LogFile=/data/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
[email protected]
SNMPTrapperFile=/data/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/data/zabbix/alertscripts
ExternalScripts=/data/zabbix/externalscripts
LogSlowQueries=3000
[[email protected]_aodun ~]#
[[email protected]_aodun ~]# mkdir -pv /data/zabbix/{alertscripts,externalscripts}
mkdir: created directory ‘/data/zabbix’
mkdir: created directory ‘/data/zabbix/alertscripts’
mkdir: created directory ‘/data/zabbix/externalscripts’
[[email protected]_aodun ~]# chown -R zabbix:zabbix /data/zabbix
[[email protected]_aodun ~]# chown -R zabbix:zabbix /data/log/{zabbix,snmptrap}
[[email protected]_aodun ~]# ll /data/log/
total 0
drwxr-xr-x. 2 mysql mysql 24 May 19 02:12 mariadb
drwxr-xr-x. 2 zabbix zabbix 6 May 19 04:00 snmptrap
drwxr-xr-x. 2 zabbix zabbix 6 May 19 04:00 zabbix
[[email protected]_aodun ~]# yum install -y httpd php php-mysql php-mbstring php-gd php-xml php-ldap php-bcmath
[[email protected]_aodun ~]# vim /etc/php.ini
修改date.timezone = Asia/Shanghai
[[email protected]_aodun ~]# yum install -y zabbix-web.noarch zabbix-web-mysql.noarch
[[email protected]_aodun ~]# systemctl start httpd
[[email protected]_aodun ~]# systemctl start zabbix-server
[[email protected]_aodun ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 :3306 :
LISTEN 0 100 127.0.0.1:25
:
LISTEN 0 128
:10051 :
LISTEN 0 128 :22022 :
LISTEN 0 128 :::80 :::

LISTEN 0 100 ::1:25 :::
LISTEN 0 128 :::10051 :::

LISTEN 0 128 :::22022 :::*
[[email protected]_aodun ~]#
?

第二部分:浏览器安装部分

使用浏览器打开server_ip/zabbix/setup.php页面进行zabbix-web-gui安装

检查安装环境是否满足

填写对应配置


信息确认页

成功安装后的提示信息

使用系统默认账户admin以及密码zabbix登录zabbix-web-gui




至此,zabbix服务器端配置基本完成了,后续文章中将为大家分享如何创建监控项、如何定义触发器、如果使用报警功能、以及如何使用自写脚本实现定制业务项监控,直至实现一个完整的监控系统。
?? 
喜欢者请点赞加关注,错误之处,还请大家留言指正!

zabbix监控——ZABBIX服务器配置过程

原文地址:http://blog.51cto.com/183530300/2085790

时间: 2024-09-29 03:16:54

zabbix监控——ZABBIX服务器配置过程的相关文章

zabbix &nbsp; 监控平台搭建过程中的报错与解决方法总结

1.php    option  post_max_size 2.php    option  max_execution_time 3.php    option  max_input_time 4.php    time   zone 5.php     bcmath 6.php     mbstring 解决1-3的报错修改php文件 vim  /etc/php.ini 修改相应参数为Required值 解决4报错:修改date.timezone=/Asia/Shanghai  注意去掉该

Zabbix监控——zabbix触发器添加及设计

有了好的监控项,也还得有好的触发器,才能有效触发zabbix报警动作,杂乱无章的触发器只会增添zabbix报警系统的负担,同时也给运维人员带来的大量的垃圾信息,所以一个好的监控系统中,触发器的设计也是需要动脑子的.当然今天在这里也只不过抛砖引玉,给大家简单示范一下. 正常来说,比如磁盘使用率达到60%,可能就需要引起运维人员的关注了,达到80%时就必要及时进行报警处理了,否则可能因数爆盘带来的失误就不可容忍了.  当然,类似于这类的触发器添加起来,可能也就相对简单了,无碍乎60%定义为告警等级,

Zabbix监控——Zabbix自定义用户参数制作监控项

很多情况下,我们使用zabbix内建的监控项不足以监控企业的具体业务,这时就需要使用zabbix提供的自定义参数扩展接口,自己根据业务监控需求,开发相应的脚本作为数据获取途径,自定义参数又存在两种方式,一种是直接把脚本内容写在自定义参数配置文件里面,另一种是写成独立的脚本文件,自定义参数配置文件里面直接调用脚本. 接下来给大家展示一下使用自定义脚本方式(脚本内容直接写在配置文件里面)添加监控项第一步:确认zabbix_agent开启了扩展参数配置(客户端的操作)vim /etc/zabbix/z

zabbix监控——zabbix邮件报警配置

前面带着大家从搭建zabbix服务器开始一直到触发器设计完毕,这一系统本身已经可以运作起来了,只是需要有一个便捷的渠道及时告诉我们运维人员去处理一些存在问题,这里就需要我们去配置一下zabbix所提供的报警机制,zabbix的报警支持报警升级机制,这对我们运维人员来说是非常有用的,我们在让zabbix通知我们相关人员的时候就可以做一个简单的规划了,比如说前5次报警直接通知运维工程师,如果5次报警后报警问题没有得到修复,第6次报警就直接通知运维主管:或者我们可以让zabbix第一步执行对应脚本进行

通过zabbix 监控agent上的ping值

本文写的是通过zabbix监控zabbix客户端主机ping其他主机是否通. A主机是zabbix服务端 B主机是zabbix客户端 C主机是其他主机(知道IP或者网址(主机名)) 要求通过A监控B是否能够ping通C. 第一步:建立模板. 第二步:创建application用于存放item 第三步:创建Items 这里icmpping的第一个参数就是C主机的IP或者网址(C的主机名) 第四步:添加 trriges 第五步:为B主机添加模板.添加模板后,B主机就能够ping到C主机了. 点击"h

zabbix监控iptables防火墙状态之是否有丢弃的包(攻-击)

概述 之前有介绍通过saltstack统一管理线上防火墙规则,并且是在默认规则为DROP策略下,即意味着,如果没有明确允许开放或允许出去访问,则防火墙会拒绝请求;特别是在线上防火墙改造时,可能由于历史原因不知道开放了那些服务,也不知道机器上的服务是否有出去请求的情况下,此时需要记录防火墙访问日志,并查看是否有合法的请求被阻止了,这样会影响业务的,你懂滴,另外如果我们的机器被扫描,被***时,也会有大量的拒绝,因此不管出于什么目的,我们需要对防火墙是否有被阻止的请求做监控;做到有点放矢;有问题报警

源码安装zabbix(lnmp+zabbix)

源码安装zabbix 实验环境: [[email protected] ~]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m 环境要求: 需要准备好实验环境,配置好主机名称 , 网络源(这里我使用的是163网络源),查看并调整好自己的时区以及时间,关闭防火墙iptables   selinux. 安装nginx 需要软件有: nginx-1.8.0.tar.gz  pcre-8.34.tar.gz 安装步骤: 首选安装:

资源汇集:跟着ttlsa学习zabbix监控

从2009年开始接触zabbix,当时版本在1.8,经过差不多5年的时间,zabbix历经2.0,2.1,2.2数个版本,虽然大多数功能保持不变,但是还是有非常明显的改变. Zabbix VS Nagios指数 我们来看看zabbix的发展趋势,打开http://index.baidu.com/?tpl=trend&word=zabbix,可以看到这个月的日平均指数在258,整体同比增长928%,环比增长10%.nagios月平均指数在308,同比增长13%,环比24%,可以看出zabbix虽然

Zabbix监控系统

一.zabbix简介: zabbix是完全开源的工具,整合了cacti和nagios等特性 附:SNMP(udp 161  udp 162) 众多网络工具都支持此协议,比如常见路由交换,常见OS 其既可以做管理端也可以做被管理端 snmp协议大致有3个版本分别是v1 v2v3 无论是v1 和 v2 的安全性是比较差的,因为传输是明文的, V3的认证密码用MD5/SHA摘要算法加密 很多工具支持网络管理的功能,而对于非网络设备(操作系统),可以完全抛开snmp这种不安全的架构来实现监控的.所以很多