zabbix/zabbix-安装.md
2025-03-17 13:41:52 +08:00

3.6 KiB
Raw Permalink Blame History

Zabbix


Zabbix 安装

备注:操作系统 centos stream 9 zabbix

修改静态IP

[root@zserver ~]# vim /etc/NetworkManager/system-connections/ens33.nmconnection
...
[ipv4]
method=manual
address=192.168.159.131/24,192.168.159.2
dns=114.114.114.114;8.8.8.8
...
[root@zserver ~]# nmcli connection reload
[root@zagent ~]# nmcli connection up ens33

1. Server 端安装配置

访问网站:Download and install Zabbix 6.0 LTS for CentOS 9 Stream, MySQL, Apache

下载

[root@zserver ~]# rpm -Uvh https://repo.zabbix.com/zabbix/7.0/centos/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm
[root@zserver ~]# yum clean all

安装 zabbix server、frontend、agent

[root@zserver ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

安装mysql

[root@zserver ~]# yum -y install mysql mysql-server
[root@zserver ~]# systemctl start mysqld
[root@zserver ~]# systemctl enable mysqld

配置数据库

[root@zserver ~]# mysql -uroot -p
Enter password:
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.00 sec)

mysql> create user zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

[root@zserver ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:

[root@zserver ~]# mysql -uroot -p
Enter password:
mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit;
Bye

设置服务配置文件

[root@zserver ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=123456

启动服务

[root@zserver ~]# systemctl restart zabbix-server zabbix-agent httpd php-fpm
[root@zserver ~]# systemctl enable zabbix-server zabbix-agent httpd php-fpm
[root@zserver ~]# systemctl stop firewalld
[root@zserver ~]# systemctl disable firewalld

访问:http://192.168.159.131/zabbix

默认登入:

账号Admin 密码zabbix

2. Agent 端安装配置

下载

[root@zagent ~]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-latest-6.0.el9.noarch.rpm
[root@zagent ~]# yum clean all

安装

[root@zagent ~]# yum -y install zabbix-agent

修改配置

[root@zagent ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.159.131        # 被动模式 zabbix-server-ip
ServerActive=192.168.159.131 # 主动模式 zabbix-server-ip
Hostname=zabbix agent1       # 客户端主机名称
UnsafeUserParameters=1       # 是否限制用户自定义 keys 使用特殊字符

启动服务

[root@zagent ~]# systemctl start zabbix-agent
[root@zagent ~]# systemctl enable zabbix-agent
[root@zagent ~]# systemctl stop firewalld
[root@zagent ~]# systemctl disable firewalld