zabbix-server 监控中心,接收客户端上报信息,负责配置、统计、操作数据
数据存储 存放数据,比如mysql
web界面 也叫web UI,在web界面下操作配置是zabbix简单易用的主要原因
zabbix-proxy 可选组件,它可以代替zabbix-server的功能,减轻server的压力
zabbix-agent 客户端软件,负责采集各个监控服务或项目的数据,并上报
zabbix-server-mysql 提供zabbix-server服务
zabbix-proxy-mysql 提供zabbix的代理服务,可以实现分布式监控,减轻zabbix-server的压力
zabbix-web-mysql 提供httpd服务
zabbix-get 提供检查是否能正确获取到zabbix的监控脚本key的监控值
zabbix-agent 提供zabbix-agent服务
[root@VM-0-17-centos ~]# /usr/sbin/sestatus -v
SELinux status: disabled
[root@VM-0-17-centos ~]# getenforce
Disabled
systemctl stop firewalld.service
setenforce 0
注:局域网安装,本例首先配置CentOS-7-x86_64-DVD-2003.iso镜像为yum源
yum install fping-3.10-4.el7.x86_64.rpm php-common-5.4.16-48.el7.x86_64.rpm php-bcmath-5.4.16-48.el7.x86_64.rpm php-mbstring-5.4.16-48.el7.x86_64.rpm php-pdo-5.4.16-48.el7.x86_64.rpm php-mysql-5.4.16-48.el7.x86_64.rpm openssl11-libs-1.1.1c-2.el7.x86_64.rpm -y
yum install zabbix-server-mysql-4.4.8-1.el7.x86_64.rpm -y
yum install zabbix-web-mysql-4.4.8-1.el7.noarch.rpm zabbix-web-4.4.8-1.el7.noarch.rpm zabbix-web-4.4.8-1.el7.noarch.rpm -y
#安装这个前先安装配置java环境
yum install zabbix-java-gateway-4.4.9-1.el7.x86_64.rpm -y
阿里或网易yum源二选一
#阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#163源
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
#查看源多出zabbix.repo文件
ls /etc/yum.repos.d/
yum clean all
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
互联网装agent(客户端)无需配置CentOS-7-x86_64-DVD-2003.iso镜像为yum源,只需配置阿里源或网易yum源
yum install mariadb-server -y
启动数据库&加入开机自启动
systemctl start mariadb
systemctl enable mariadb
#创建Zabbix的数据库名为zabbix,注意字符集的选择
mysql -uroot -e "CREATE DATABASE zabbix CHARSET utf8 COLLATE utf8_bin"
#创建Zabbix的用户名为zabbixadmin,密码为123456
mysql -uroot -e "GRANT ALL ON zabbix.* TO zabbixadmin@localhost IDENTIFIED BY '123456'"
#查看新建都数据库
[root@VM-0-17-centos ~]# mysql -uroot -e "show databases"
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
#查看到数据目录/usr/share/doc/zabbix-server-mysql-4.4.8/create.sql.gz
rpm -ql zabbix-server-mysql
zcat /usr/share/doc/zabbix-server-mysql-4.4.8/create.sql.gz | mysql -uzabbixadmin -p123456 zabbix
注:数据目录以上一步查看的数据目录为准
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbixadmin
DBPassword=123456
DBPort=3306
ListenIP=192.168.1.100
注:ListenIP不要写为localhost,写数据库所在ip
systemctl start zabbix-server
systemctl enable zabbix-server
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
systemctl start httpd
systemctl enable httpd
rpm -vhi zabbix-agent-4.4.8-1.el7.x86_64.rpm
#备份
sudo cp -a /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_init
#修改zabbix服务端ip
sudo sed -i "s/^ServerActive=127.0.0.1/ServerActive=192.168.1.100/" /etc/zabbix/zabbix_agentd.conf
# Hostname=zhbaspmj-101改为对应的客户端IP
sudo sed -i "s/Hostname=Zabbix server/Hostname=zhbaspmj-101/" /etc/zabbix/zabbix_agentd.conf
#重启客户端并设置开启自启动
sudo systemctl restart zabbix-agent && sudo systemctl enable zabbix-agent
#查看开机自启动服务
systemctl list-unit-files
zabbix_agent-4.4.5-windows-amd64-openssl.msi
双击“zabbix_agent-4.4.5-windows-amd64-openssl.msi”,下一步
host name:zabbix客户端机器名 zabbix server ip/server or proxy…都填zabbix服务器ip,一直下一步直到完成
1、浏览器登录Zabbix
http://192.168.1.100/zabbix
系统默认的用户名:Admin
系统默认密码:zabbix
服务器端安装字体
# yum install wqy-microhei-fonts -y
修改字体链接,链接到新安装的字体
# rm /usr/share/zabbix/assets/fonts/graphfont.ttf
# ln -sv /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/zabbix/assets/fonts/graphfont.ttf
配置-主机-创建主机
输入主机名称:自定义,群组:自定义,agent代理程序的接口ip地址:客户端ip
添加之后,10分钟左右变绿则表示成功添加
linux 选择Template OS Linux by Zabbix agent active Windows系统选择: Template OS Windows by Zabbix agent active ,选择这个active被动模型客户端往服务端推数据
配置监控项
#自定义监控项的目录是/etc/zabbix/zabbix_agentd.d,在里面创建以.conf结尾的文件即可
vim /etc/zabbix/zabbix_agentd.d/tomcat8080.conf
#tomcat.port8080:监控自定义名称,监控8080端口是否启用:ss -tnl | awk '{print $4}' | grep -o '8080'
UserParameter=tomcat.port8080, ss -tnl | awk '{print $4}' | grep -o '8080'
重启服务
# systemctl restart zabbix-agent
1.配置-主机-监控项
2.创建监控项
3.输入名称、键值(配置监控项文件的UserParameter值),信息类型(此处监控8080为数字),新的应用集,勾选已启用,点击添加
添加成功入下图
1.配置-主机-选择要创建触发器的主机,点击触发器-创建触发器
2.设置名称,点击表达式右侧的添加按钮选择自定义监控项,选择功能,输入最后一个时间,输入结果,点击插入,选择严重级别,点击页面底部的添加按钮,完成触发器的配置。
下图为添加表达式
下图为创建触发器
服务器关闭tomcat( systemctl stop tomcat),查看结果
管理-报警媒介类型-选择邮件-输入邮件信息
选择右侧小人像-报警媒介-添加-选择emall,输入收件人信息-点击添加
配置动作
配置操作
问题描述: 登录zabbix,弹出如上图zabbix server is not running的警告
解决方案:
关闭selinux
修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
如果不想重启系统,使用命令setenforce 0 或 selinux=0,也可以关闭selinux
解决后的正确截图
[Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbixadmin'@'localhost' (using password: NO)
25222:20200820:100845.180 database is down: reconnecting in 10 seconds
DBHost=localhost
DBName=zabbix
DBUser=zabbixadmin
DBPassword=123456
DBPort=3306
#ListenIP=192.168.1.100 --注意不要写为localhost,写数据库所在ip,# 开启的话,只监听IPV4,不开启,IPV4/IPV6都监听。
**问题描述:**重启报错如下
Job for zabbix-agent.service failed because the control process exited with error code. See “systemctl status zabbix-agent.service” and “journalctl -xe” for details.
解决方法:
根据提示执行:systemctl status zabbix-agent.service
[root@VM-0-17-centos zabbix_agentd.d]# systemctl status zabbix-agent.service
zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since 五 2020-08-21 10:37:16 CST; 464ms ago
Process: 27067 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 13325 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=1/FAILURE)
Main PID: 26247 (code=exited, status=0/SUCCESS)
8月 21 10:37:16 VM-0-17-centos systemd[1]: zabbix-agent.service: control process exited, code=exited status=1
8月 21 10:37:16 VM-0-17-centos systemd[1]: Failed to start Zabbix Agent.
8月 21 10:37:16 VM-0-17-centos systemd[1]: Unit zabbix-agent.service entered failed state.
8月 21 10:37:16 VM-0-17-centos systemd[1]: zabbix-agent.service failed.
再次执行:journalctl -xe
可以从结果看出是因为参数错误把vim /etc/zabbix/zabbix_server.conf
erParameter=httpd.port80, ss -tnl | awk ‘{print $4}’ | grep -o ‘80’
改为
UserParameter=httpd.port80, ss -tnl | awk ‘{print $4}’ | grep -o ‘80’
Not Found
The requested URL /zabbix was not found on this server.
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/ShangHai
Order deny,allow
Deny from all
Order deny,allow
Deny from all
Order deny,allow
Deny from all
Order deny,allow
Deny from all
Order deny,allow
Deny from all
Order deny,allow
Deny from all
Order deny,allow
Deny from all
Order deny,allow
Deny from all
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
Options FollowSymLinks
AllowOverride None
Require all granted
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/ShangHai
Require all denied
Require all denied
Require all denied
Require all denied
service httpd restart