1. 系统版本
Ubuntu VERSION=22.04.4 LTS
2. zabbix安装
2.1 zabbix官方
https://www.zabbix.com/cn/download?zabbix=7.0&os_distribution=ubuntu&os_version=22.04&components=server_frontend_agent&db=mysql&ws=apache
2.2 配置选择
2.3 使用Ubuntu的管理包工具(apt)部署zabbix
1.安装repo软件源
[root@zabbix-server ~]# wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-2%2Bubuntu22.04_all.deb
--2024-10-28 22:36:25-- https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-2%2Bubuntu22.04_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001
Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8288 (8.1K) [application/octet-stream]
Saving to: ‘zabbix-release_7.0-2+ubuntu22.04_all.deb’
zabbix-release_7.0-2+ubuntu22.0 100%[=====================================================>] 8.09K --.-KB/s in 0s
2024-10-28 22:36:26 (124 MB/s) - ‘zabbix-release_7.0-2+ubuntu22.04_all.deb’ saved [8288/8288]
[root@zabbix-server ~]# ll
total 64
drwx------ 5 root root 4096 Oct 28 22:36 ./
drwxr-xr-x 20 root root 4096 Jun 15 02:50 ../
-rw-r--r-- 1 root root 8288 Jul 4 19:55 zabbix-release_7.0-2+ubuntu22.04_all.deb
[root@zabbix-server ~]# dpkg -i zabbix-release_7.0-2+ubuntu22.04_all.deb
Selecting previously unselected package zabbix-release.
(Reading database ... 111110 files and directories currently installed.)
Preparing to unpack zabbix-release_7.0-2+ubuntu22.04_all.deb ...
Unpacking zabbix-release (1:7.0-2+ubuntu22.04) ...
Setting up zabbix-release (1:7.0-2+ubuntu22.04) ...
[root@zabbix-server ~]# apt update
.....
2.安装Zabbix server 数据库,Php Web前端,zabbix agent
[root@zabbix-server ~]# apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2 zabbix-agent2-plugin-*
3.数据库配置
3.1 安装
[root@zabbix-server ~]# apt install -y mariadb-server
3.2 启动 MySQL 数据库
[root@zabbix-server ~]# systemctl start mariadb
3.3 设置 MySQL 数据库开机自启
[root@zabbix-server ~]# systemctl enable mariadb
3.4 初始化 MySQL 数据库
[root@zabbix-server ~]# mysql_secure_installation
注:全部采用默认,“回车”即可。途中会设置登录密码,不可为空,实验采用 123。
当你看到 Thanks for using MariaDB! 的输出时,则表示你已经完成了 MariaDB 的配置。
- 创建初始数据库
[root@zabbix-server ~]# mysql -uroot -p
Enter password:
MariaDB [(none)]>
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'zabbix';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
- 导入初始架构和数据,系统将提示您输入新创建的zabbix数据库的密码。
# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
# mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
- 为Zabbix server配置数据库 编辑配置文件 /etc/zabbix/zabbix_server.conf
[root@zabbix-server ~]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf-`date +%F`
[root@zabbix-server ~]# sed -r -i 's@# (DBPassword=)@\1zabbix@' /etc/zabbix/zabbix_server.conf #配置连接MySQL数据库的密码
[root@zabbix-server ~]# egrep '^DBPassword' /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
[root@zabbix-server ~]# sed -r -i 's@# (DBPort=)@\13306@' /etc/zabbix/zabbix_server.conf #设置MySQL的端口号(此步骤可以省略,生产环境中如果你MySQL监听的不是3306端口的话你可以自行修改)
[root@zabbix-server ~]# sed -r -i 's@# (DBHost=)localhost@\110.0.0.6@' /etc/zabbix/zabbix_server.conf #配置MySQL的服务器地址
[root@zabbix-server ~]# egrep '^DB' /etc/zabbix/zabbix_server.conf #查看
DBHost=10.0.0.6
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
[root@zabbix-server ~]#
7.修改时区
[root@zabbix-server ~]# cp /etc/zabbix/apache.conf /etc/zabbix/apache.conf-`date +%F`
[root@zabbix-server ~]# sed -r -i "s@# (php_value date.timezone) Europe/Riga@\1 Asia/Shanghai@" /etc/zabbix/apache.conf
[root@zabbix-server ~]#
- 启动Zabbix server和agent进程 启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent2 apache2
# systemctl enable zabbix-server zabbix-agent2 apache2
标签:7.0,zabbix,apt,server,Zabbix,mysql,release,企业级,root
From: https://www.cnblogs.com/kyle-7Qc/p/18511912