参考资料
zabbix server安装部署参考
zabbix agent软件安装
Zabbix server安装
安装yum源
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
安装软件包
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y
安装mysql yum源
wget https://dev.mysql.com/get/mysql80-community-release-el9-3.noarch.rpm
安装MySQL
dnf install mysql-community-server -y
启动MySQL
systemctl enable --now mysqld.service # 开机自启并立即启动
mysql systemctl status mysqld.service # 查看mysql状态
查看初始密码
grep "password" /var/log/mysqld.log
2024-05-25T14:47:51.412987Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9y.kJy7!jwlw
修改root密码
mysql -u root -p
alter user "root"@"localhost" identified by "Test@xxxx5";
配置可远程连接
use mysql;
update user set host="%" where user="root"; # 将host修改为所有ip均可以访问
flush privileges; # 刷新
新建zabbix数据库和授权
mysql -uroot -p<password>
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'zabbix'@'localhost' identified by '<password>';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
mysql> quit;
导入zabbix server数据
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
禁用log_bin_trust_function_creators
mysql -uroot -p
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
配置Zabbix server使用的数据库密码
Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password
启动 Zabbix server and agent
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
登录zabbix server管理页面
浏览器打开链接http://192.168.40.200/zabbix
默认用户名:Admin 密码:zabbix, 默认语音没有中文,后续安装语言包后,可以使用中文显示
点击下一步
Database host 配置localhost, 同一台机器安装
password 配置数据库安装时配置的用户zabbix的密码
Zabbix server name 随意配置即可
选择时区
配置总结,选择下一步
完成安装
输入用户名密码登录
登录成功界面
配置页面支持中文
yum install glibc-langpack-zh.x86_64 -y
localectl list-locales | grep zh
登录管理页面,选择 User settings - Profile - User - Language 选择 Chinese(zh_CN)
页面内容变成中文显示,默认添加1个监控终端(zabbix server)
Zabbix agent安装
找一台空闲的需要监控的linux服务器
安装yum源
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm
安装zabbix-agent
yum install zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agent
修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.40.200
ServerActive=192.168.40.200
Hostname=logstash
网页管理端添加主机
配置-主机-创建主机
主机名称: 与zabbix_agentd.conf 中定义的Hostname相同
模板: 如图配置
群组: 如图配置
Interfaces: 配置zabbix agent IP
点击更新
监测-最新数据 选择logstash主机,可以看到最新收集到的数据