zabbix监控原理:
1.生产环境安装zabbix
#安装zabbix前提,关闭selinux
2
3
1:配置zabbix的yum源
4
#下载zabbix-release
5
wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
6
#安装zabbix-release
7
rpm -ivh zabbix-release-4.0-1.el7.noarch.rpm
8
#将官方仓库地址替换为清华仓库地址
9
sed -i 's#http://repo.zabbix.com#https://mirror.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
10
11
2:安装zabbix服务端和zabbix-web前端
12
yum install zabbix-server-mysql zabbix-web-mysql -y
13
14
3:安装mariadb,创建zabbix库,授权zabbix用户
15
yum install mariadb-server -y
16
systemctl start mariadb
17
systemctl enable mariadb
18
mysql_secure_installation
19
先回车
20
再n
21
然后一路y
22
23
mysql
24
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
25
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
26
27
导入zabbix表结构和初始数据
28
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix
29
30
检查zabbix库是否导入成功
31
mysql -uroot zabbix -e 'show tables'
32
33
4:配置启动zabbix-server
34
vi /etc/zabbix/zabbix_server.conf
35
DBHost=localhost
36
DBName=zabbix
37
DBUser=zabbix
38
DBPassword=123456
39
40
启动zabbix-server
41
systemctl start zabbix-server
42
systemctl enable zabbix-server
43
44
检查:
45
netstat -lntup|grep 10051
46
47
5:修改Zabbix前端的PHP配置,并启动httpd
48
vi /etc/httpd/conf.d/zabbix.conf
49
php_value date.timezone Asia/Shanghai
50
51
systemctl start httpd
52
systemctl enable httpd
53
54
6:前端zabbix-web的安装
55
浏览器:http://192.168.96.128/zabbix
56
57
后期修改zabbix数据库密码的时候,需要修改的配置文件:
58
/etc/zabbix/web/zabbix.conf.php
59
60
http://192.168.96.128/zabbix/zabbix.php
61
登录的账号密码;
62
Admin
63
zabbix
过程简单就不截图了。
启动zabbix 进入web界面:
systemctl enable zabbix-server
systemctl start zabbix-server
netstat -anpt | grep zabbix
systemctl restart httpd.service
访问:http://192.168.96.128/zabbix/
设置中文模式:
2.监控一台主机服务器
监控zabbix-server自己(192.168.96.128)
xxxxxxxxxx
3
1
yum install zabbix-agent.x86_64 -y
2
systemctl enable zabbix-agent.service
3
systemctl start zabbix-agent.service
使用zabbix-agent监控其他主机(192.168.96.131)
1
wget https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.16-1.el7.x86_64.rpm
2
rpm -ivh zabbix-agent-4.0.16-1.el7.x86_64.rpm
3
vim /etc/zabbix/zabbix_agentd.conf
4
Server=192.168.96.128
5
systemctl enable zabbix-agent.service
6
systemctl start zabbix-agent.service
可视化界面操作:
发现主机:
用自带的模板添加主机监控项:
查看监控的数据
或者
3.自定义监控项
监控用户登陆数
修改zabbix-agent配置文件
xxxxxxxxxx
4
1
vim /etc/zabbix/zabbix_agentd.conf
2
UserParameter=login_users
3
systemctl restart zabbix-agent.service
在web界面上添加监控项
4.邮件报警
1:配置发件人
2.配置收件人:
3:启动报警发消息的动作
4.查看报警信息
163发送端的发件箱
我的qq邮箱收件箱: