Zabbix Server搭建

环境准备

Linux Server: Ubuntu 22.04
Zabbix Server: 6.0 LTS
MySQL Server:8.0.36

1. Ubuntu配置阿里源

1.1 备份原始源

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak

1.2 新建源文件

sudo vim /etc/apt/sources.list

1.3 添加以下源链接
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
1.4 更新源

sudo apt-get update -y

2. 部署MySQL服务器

2.1 安装MySQL服务器

sudo apt-get install -y mysql-server

2.2 使能MySQL服务并使能开机自启动:

sudo systemctl start mysql && sudo systemctl enable mysql

2.3 初始化MySQL服务器

sudo systemctl start mysql

2.4 查看MySQL服务器状态

sudo systemctl status mysql

3. 配置Zabbix Server

3.1 安装Zabbix仓库
sudo wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_6.0-4+ubuntu22.04_all.deb
sudo apt update
3.2 安装Zabbix server,Web前端,agent

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent

3.3 创建初始数据库
sudo 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;
3.4 导入初始架构和数据,系统将提示您输入新创建的密码

sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

3.5 导入数据库架构后禁用log_bin_trust_function_creators选项
sudo mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
3.6 为Zabbix server配置数据库
sudo vim /etc/zabbix/zabbix_server.conf
# change 
DBPassword=password
3.7 启动Zabbix server和agent进程

sudo systemctl restart zabbix-server zabbix-agent apache2 && sudo systemctl enable zabbix-server zabbix-agent apache2

3.8 浏览器访问Zabix UI界面

http://host/zabbix

备注:Zabbix默认账号"Admin",密码"zabbix"
posted on 2024-03-16 16:43  debug_all  阅读(147)  评论(0编辑  收藏  举报