diff --git a/zabbix-安装.md b/zabbix-安装.md new file mode 100644 index 0000000..27c495a --- /dev/null +++ b/zabbix-安装.md @@ -0,0 +1,152 @@ +

Zabbix

+ +------ + +## 一:Zabbix 安装 + +备注:操作系统 centos stream 9 zabbix + +修改静态IP + +```bash +[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](https://www.zabbix.com/download) + +![](accents\image-202503160002.png) + +下载 + +```bash +[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 + +```bash +[root@zserver ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent +``` + +安装mysql + +```bash +[root@zserver ~]# yum -y install mysql mysql-server +[root@zserver ~]# systemctl start mysqld +[root@zserver ~]# systemctl enable mysqld +``` + +配置数据库 + +```SQL +[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 +``` + +设置服务配置文件 + +```bash +[root@zserver ~]# vim /etc/zabbix/zabbix_server.conf +DBPassword=123456 +``` + +启动服务 + +```bash +[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 + +![](accents\image-202503160003.png) + +![](accents\image-202503160004.png) + +![](accents\image-202503160005.png) + +![](accents\image-202503160006.png) + +![](accents\image-202503160007.png) + +![](accents\image-202503160008.png) + +默认登入: + +账号:Admin 密码:zabbix + +![](accents\image-202503160009.png) + +![](accents\image-202503160010.png) + +### 2. Agent 端安装配置 + +下载 + +```bash +[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 +``` + +安装 + +```bash +[root@zagent ~]# yum -y install zabbix-agent +``` + +修改配置 + +```bash +[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 使用特殊字符 +``` + +启动服务 + +```bash +[root@zagent ~]# systemctl start zabbix-agent +[root@zagent ~]# systemctl enable zabbix-agent +[root@zagent ~]# systemctl stop firewalld +[root@zagent ~]# systemctl disable firewalld +``` \ No newline at end of file