Zabbix 6.0 监控部署与配置
一、Zabbix安装
# 安装Zabbix仓库 rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm # 安装Zabbix服务器和Agent dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf # 安装数据库 dnf install mariadb-server systemctl enable mariadb --now # 创建数据库 mysql -uroot -p CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'zabbix_password'; GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost'; FLUSH PRIVILEGES;
二、配置Zabbix服务器
# 导入数据库 zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix # 配置Zabbix服务器 vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix_password # 启动服务 systemctl enable zabbix-server --now systemctl enable httpd --now systemctl enable php-fpm --now
三、添加被监控主机
# 1. 在被监控主机安装Agent dnf install zabbix-agent # 2. 配置Agent vim /etc/zabbix/zabbix_agentd.conf Server=192.168.1.100 # Zabbix服务器IP ServerActive=192.168.1.100 Hostname=web-server-1 # 3. 启动Agent systemctl enable zabbix-agent --now # 4. 在Web界面添加主机 # Configuration -> Hosts -> Create host # Host name: web-server-1 # Groups: Linux servers # Agent interfaces: 192.168.1.10:10050
四、创建监控项和触发器
# 创建监控项 (Item) # Configuration -> Hosts -> Items -> Create item # Name: CPU Usage # Key: system.cpu.util # Type: Zabbix agent # Update interval: 30s # 创建触发器 (Trigger) # Configuration -> Hosts -> Triggers -> Create trigger # Name: CPU High Usage # Expression: avg(/Linux server/system.cpu.util,5m)>80 # Severity: Warning # 创建图形 (Graph) # Configuration -> Hosts -> Graphs -> Create graph # Add Items: CPU Usage
五、报警配置
# 配置媒介类型 # Administration -> Media types -> Email # SMTP server: smtp.example.com # SMTP helo: example.com # SMTP email: zabbix@example.com # 配置用户报警媒介 # Administration -> Users -> Media # Add: Email: admin@example.com # 创建动作 # Configuration -> Actions -> Trigger actions -> Create action # Conditions: Trigger = CPU High Usage # Operations: Send message to Admin