Debian 12 部署 Zabbix 7.2
环境准备
- 系统:Debian 12
- 数据库:MySQL 8.0
- 网站服务器:Nginx
- Zabbix:Zabbix 7.2
一、前期准备
换镜像源
为加速软件包下载,建议更换国内源:
编辑文件:
nano /etc/apt/sources.list
阿里云源
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
清华源
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
保存退出后,更新源:
sudo apt update
二、安装依赖
apt install -y gnupg2 wget gnupg sudo
三、下载 MySQL
1. 安装 MySQL 仓库
Debian 12 默认不包含 MySQL 软件包(被 MariaDB 替换),需从 MySQL 官网下载安装:
wget https://repo.mysql.com/mysql-apt-config_0.8.29-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb
安装过程中:
- 默认回车选择 MySQL 8.0。
- 选择
ok
后回车,完成仓库安装。
2. 安装 MySQL 数据库
apt update apt install -y mysql-server
设置 MySQL 登录密码(本地环境可简单,公网环境需设置强密码)。
四、下载安装 Zabbix
1. 安装 Zabbix 仓库
wget https://repo.zabbix.com/zabbix/7.2/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian12_all.deb
dpkg -i zabbix-release_latest_7.2+debian12_all.deb
rm zabbix-release_latest_7.2+debian12_all.deb
apt update
2. 安装 Zabbix Server
apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
五、创建 Zabbix 相关库
1. 创建 Zabbix 数据库
登录 MySQL(使用安装时设置的密码):
mysql -uroot -p
执行以下 SQL 命令:
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by '12345678';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;
2. 导入数据
zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p12345678 zabbix
六、配置 Zabbix
1. 为 Zabbix Server 配置数据库
编辑 /etc/zabbix/zabbix_server.conf
:
nano /etc/zabbix/zabbix_server.conf
修改以下内容(将 password
替换为 Zabbix 用户密码):
DBPassword=12345678
若数据库名或用户名非默认(zabbix
),需相应修改 DBName
和 DBUser
。
2. 为 Zabbix 前端配置 PHP
编辑 /etc/zabbix/nginx.conf
:
nano /etc/zabbix/nginx.conf
取消以下内容的注释:
listen 8080;
server_name example.com;
3. 启动 Zabbix 相关进程
systemctl restart zabbix-server zabbix-agent nginx php8.2-fpm
systemctl enable zabbix-server zabbix-agent nginx php8.2-fpm
七、Web 访问
1. Web 界面配置
访问路径:http://<服务器IP>:8080
- 检查必要条件,确保全部为
OK
状态,否则根据提示修改参数。 - 输入创建数据库时的用户名和密码。
- 设置时区为
Asia/Shanghai (UTC +08:00)
。 - 主机名自定义,默认下一步完成安装。
2. Web 登录
默认用户:Admin
默认密码:zabbix
登录后,建议立即修改 Admin
账户密码(公网环境尤为重要)。
八、解决监控图形界面乱码
若监控图形界面出现乱码(如 XY 轴显示异常),可替换字体
下载字体文件替换默认字体:
wget https://console.yumesakura.com/down/0EKF7a5Hj7Eh.TTF -O /usr/share/zabbix/ui/assets/fonts/graphfont.ttf
九、部署完成
部署完成后,访问:
http://<服务器IP>:8080
默认用户:Admin
默认密码:zabbix