Ubuntu22.04 LTS 部署zabbix7.0
环境准备
IP | 主机名 | 配置 |
---|---|---|
10.0.0.50 | zabbix-01 | 2c4G |
10.0.0.52 | db | 2c4G |
1. 添加zabbix仓库
[root@zabbix-01:~]# wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu22.04_all.deb
[root@zabbix-01:~]# dpkg -i zabbix-release_latest_7.0+ubuntu22.04_all.deb
[root@zabbix-01:~]# apt update
2. 安装Zabbix server,Web前端,agent
[root@zabbix-01:~]# apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
3. 安装MySQL
[root@db:~]# apt install -y mysql-server-8.0
[root@db:~]# netstat -tnulp | grep 3306
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN 1974/mysqld
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1974/mysqld
4. 创建初始数据库
[root@db:~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.40-0ubuntu0.22.04.1 (Ubuntu)
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@'%' identified by 'zabbix';
mysql> grant all privileges on zabbix.* to zabbix@'%';
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码
[root@zabbix-01:~]# scp /usr/share/zabbix-sql-scripts/mysql/server.sql.gz 10.0.0.52:/root
[root@db:~]# zcat server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password: # 输密码的时候不显示字符,此处我输入了 zabbix
[root@db:~]# mysql
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
5. 为Zabbix server配置数据库
[root@zabbix-01:~]# egrep '^DBHost|^DBName|^DBUser|^DBPassword' /etc/zabbix/zabbix_server.conf
DBHost=10.0.0.52
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
6. 为Zabbix前端配置PHP
[root@zabbix-01:~]# cat /etc/zabbix/nginx.conf
server {
listen 8080;
server_name 10.0.0.50;
...
7. 启动Zabbix server和agent进程
[root@zabbix-01:~]# systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
[root@zabbix-01:~]# systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm
8. 设置中文web界面
10.0.0.50:8080
# 列出所有已安装的语言
[root@zabbix-01:~]# locale -a
C
C.utf8
POSIX
en_US.utf8
[root@zabbix-01:~]# sed -n '/zh_CN.UTF-8 UTF-8/p' /etc/locale.gen
# zh_CN.UTF-8 UTF-8
[root@zabbix-01:~]# sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen
[root@zabbix-01:~]# sed -n '/zh_CN.UTF-8 UTF-8/p' /etc/locale.gen
zh_CN.UTF-8 UTF-8
[root@zabbix-01:~]# locale-gen
[root@zabbix-01:~]# systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
9. web界面安装zabbix
10.访问web界面
10.0.0.50:8080
账号:Admin
密码:zabbix