文章

ubuntu22.04安装zabbix6.2

ubuntu22.04安装zabbix6.2

官方文档

65.1.png

sudo passwd root      //修改root密码
su root               //切换到root用户

安装Zabbix

安装Zabbix存储库

wget https://repo.zabbix.com/zabbix/6.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.2-1+ubuntu22.04_all.deb
dpkg -i zabbix-release_6.2-1+ubuntu22.04_all.deb
apt update

安装Zabbix server,Web前端,agent

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

如果安装报错,那就需要更换镜像源 更换镜像源方法 先备份

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

编辑

vim /etc/apt/sources.list
# 注释掉原来的,加上新的
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

更新源

apt-get update
apt-get upgrade

安装myql

apt install -y mysql-server

如果报错:

The following packages have unmet dependencies:
 libevent-core-2.1-7a : Conflicts: libevent-core-2.1-7 but 2.1.12-stable-1build3 is to be installed

则运行如下命令

apt-get install aptitude
aptitude instal mysql-server

初始化数据库

mysql_secure_installation

在设置root密码的时候会报错,报错内容:

Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

解决办法:
进入mysql

mysql

修改root密码

alter user 'root'@'localhost' identified with mysql_native_password by 'newpassword';

然后再初始化数据库。所有的问题全部填n

创建初始数据库

mysql -uroot -p
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'password';
grant all privileges on zabbix.* to zabbix@localhost;
quit;

导入初始架构和数据,系统将提示您输入新创建的密码。

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix

报错

ERROR 1419 (HY000) at line 2119: You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)

解决办法:先执行下面这条语句

mysql -u root -p
set global log_bin_trust_function_creators = 1;

为Zabbix server配置数据库 编辑配置文件 vim /etc/zabbix/zabbix_server.conf

DBPassword=password

65.2.png

为Zabbix前端配置PHP 编辑配置文件 vim /etc/zabbix/nginx.conf

listen 80
server_name ip地址

65.3.png

启动Zabbix server和agent进程 启动Zabbix server和agent进程,并为它们设置开机自启:

systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm

访问IP

65.4.png

65.5.png

65.6.png

65.7.png

65.8.png

默认账号:Admin,密码:zabbix

安装中文

sudo apt-get install language-pack-zh-han*

然后重启zabbix,选择中文

65.9.png

解决图标乱码问题

cd /usr/share/zabbix/assets/fonts/

下载字体

wget https://www.xxshell.com/download/sh/zabbix/ttf/msyh.ttf
mv graphfont.ttf graphfont.ttf.bak
mv msyh.ttf graphfont.ttf

刷新浏览器

后续问题 打开网页显示Apache2 Ubuntu Default Page 解决办法:

systemctl disable apache2
systemctl stop apache2
reboot
License:  CC BY 4.0