Zabbix
简介
部署Server+agent2
添加主机
自定义监控
邮件报警
自动发现
自动注册
分布式监控
SNMP监控
本文档使用 MrDoc 发布
-
+
home page
部署Server+agent2
# 安装zabbix-server ## 统一时区 ```asp mv /etc/localtime{,.back} ``` ```asp ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ``` ## 安装 获取Zabbix安装源(centos),其它系统参考:[官方文档](https://www.zabbix.com/cn/download "官方文档") ```asp rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm ``` 国内更换aliyun镜像源 ```asp sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo ``` 开启zabbix-frontend前端源 ```asp sed -i '11s/enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo ``` 安装scl软件集 ```asp yum -y install centos-release-scl ``` 安装zabbix前端环境至scl环境(软件包与系统其他软件包共存且不会影响系统的稳定性)下 ```asp yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl ``` 安装zabbix前端环境 ```asp yum -y install zabbix-server-mysql zabbix-agent ``` 安装mariadb数据库 ```asp yum -y install mariadb-server ``` ## 配置 启动数据库 ```asp systemctl enable --now mariadb ``` 初始化数据库 ```asp mysql_secure_installation ``` 登陆数据库 ```asp mysql -uroot -p ``` 创建zabbix用户授权 ```asp create user zabbix@localhost identified by 'done666'; ``` 创建zabbix库指定字符集 ```asp create database zabbix character set utf8 collate utf8_bin; ``` 授权zabbix用户权限 ```asp grant all privileges on zabbix.* to zabbix@localhost; ``` 导入zabbix库模板 ```asp zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix ``` 修改zabbix配置文件,添加数据库密码 ```asp vim /etc/zabbix/zabbix_server.conf ``` ```asp DBPassword=done666 ``` 修改php配置文件,添加时区 ```asp vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf ``` ```asp php_value[date.timezone] = Asia/shanghai ``` ## 启动 开启zabbix及相关服务, ```asp systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm ``` 设置开机自启 ```asp systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm ``` ## 修改字体 安装字体包 ```asp yum -y install wqy-microhei-fonts ``` 复制字体包 ```asp \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf ``` ## 网页配置 网页输入地址登陆zabbix页面 http://192.168.1.51/zabbix 显示初始页面 ![](/media/202405/2024-05-15_161833_3960480.48442730757887653.png) 下一步,检查环境状态均为OK ![](/media/202405/2024-05-15_162003_4845900.9349403054861292.png) 下一步,配置数据库信息 ![](/media/202405/2024-05-15_162135_3523680.567925945924344.png) 下一步,zabbix端口信息(默认即可) ![](/media/202405/2024-05-15_162315_1154720.44108098776828986.png) 下一步,zabbix更多信息 ![](/media/202405/2024-05-15_162344_6566340.5096989476914663.png) 下一步,安装成功 ![](/media/202405/2024-05-15_162414_1716410.978165696840003.png) ## 网页登陆 默认账号:Admin 密码:zabbix ![](/media/202405/2024-05-15_162515_6989890.1882596915679946.png) # 安装zabbix-agent2 zabbix客户端agent2新版采用golang语言开发,默认端口10050 ## 统一时区 ```asp mv /etc/localtime{,.back} ``` ```asp ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ``` ## 关闭防火墙 关闭防火墙 ```asp systemctl stop iptables systemctl disable iptables systemctl stop ufw systemctl disable ufw nft flush ruleset nft list ruleset systemctl stop nftables systemctl status nftables systemctl disable nftables iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X ``` 再清除一次所有规则 ```asp nft flush ruleset nft list ruleset systemctl status nftables systemctl stop nftables systemctl disable nftables iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X ``` ## 安装 获取安装源(系统:Ubuntu-arm64)其它系统参考:[官方文档](https://www.zabbix.com/cn/download "官方文档") ### Ubuntu-22.04-jammy-amd ```asp wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-2+ubuntu22.04_all.deb ``` ### Ubuntu-22.04-jammy-arm64 ```asp wget https://repo.zabbix.com/zabbix/7.0/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_7.0-2+ubuntu22.04_all.deb ``` ### Ubuntu-22.04-focal-arm64 ```asp wget https://repo.zabbix.com/zabbix/7.0/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_7.0-2+ubuntu20.04_all.deb ``` ### 安装 安装仓库发布软件包 ```asp dpkg -i zabbix-release_7.0-2+ubuntu22.04_all.deb ``` 更新仓库 ```asp apt update ``` 安装 ```asp apt install zabbix-agent2 zabbix-agent2-plugin-* ``` ## 配置 修改主配置文件 ```asp vim /etc/zabbix/zabbix_agent2.conf ``` 主配置文件说明 ```asp grep -Ev '^#|^$' /etc/zabbix/zabbix_agent2.conf ``` ```asp PidFile=/var/run/zabbix/zabbix_agent2.pid #进程号 LogFile=/var/log/zabbix/zabbix_agent2.log #日志文件 LogFileSize=0 #日志文件大小 Server=127.0.0.1 #发送数据地址(修改为服务端IP) ServerActive=127.0.0.1 #主动链接地址(修改为服务端IP) Hostname=Zabbix server #主机名 (修改为自己的主机名) Include=/etc/zabbix/zabbix_agent2.d/*.conf #配置文件路径 ControlSocket=/tmp/agent.sock #通信套接字 ``` ## 启动 ```asp systemctl enable --now zabbix-agent2 ``` # 客户端测试 ## 命令行测试 客户端安装zabbix_get ```asp yum -y install zabbix-get ``` 测试56联通性,输出结果为1为联通状态 ```asp zabbix_get -s '192.168.1.56' -p 10050 -k 'agent.ping' ``` 测试抓取监控设备主机名称 ```asp zabbix_get -s '192.168.1.56' -p 10050 -k 'agent.hostname' ```
done
Aug. 25, 2024, 4:27 p.m.
转发文档
Collection documents
Last
Next
手机扫码
Copy link
手机扫一扫转发分享
Copy link
Markdown文件
share
link
type
password
Update password