查看: 56|回覆: 1

[Ubuntu] Ubuntu 20.04 部署Zabbix 6.0

[複製鏈接]

1

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2011-6-14
發表於 2022-3-31 13:57:00 | 顯示全部樓層 |閲讀模式

一、Zabbix服务端部署

官网查看支持安装的版本

1.安装Zabbix存储库(按照官方步骤即可)

root@Zabbix-Server:~# wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
root@Zabbix-Server:~# dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
root@Zabbix-Server:~# apt update 

2.安装Zabbix依赖组件

root@Zabbix-Server:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y

二、数据库安装部署

1.安装MySQL

root@Zabbix-Server:~# apt install mysql-server -y

2.数据库初始化

root@Zabbix-Server:~# mysql_secure_installation 

3.登录数据库并创建用户

root@Zabbix-Server:~# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2022, 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;
Query OK, 1 row affected (0.01 sec)

mysql> create user zabbix@'%' identified by 'zabbix@123';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on zabbix.* to zabbix@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye

4.创建用户测试链接

root@Zabbix-Server:~# mysql -uzabbix -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2022, 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> 

5.启动数据库

root@Zabbix-Server:~# systemctl start mysql.service
root@Zabbix-Server:~# systemctl enable mysql
Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mysql
root@Zabbix-Server:~# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-03-31 02:50:44 UTC; 14min ago
   Main PID: 14658 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 4575)
     Memory: 361.2M
     CGroup: /system.slice/mysql.service
             └─14658 /usr/sbin/mysqld

Mar 31 02:50:43 Zabbix-Server systemd[1]: Starting MySQL Community Server...
Mar 31 02:50:44 Zabbix-Server systemd[1]: Started MySQL Community Server.

三、Zabbix配置

1.更改Zabbix时区

root@Zabbix-Server:~# vim /etc/zabbix/apache.conf
php_value date.timezone Asia/Shanghai

2.Zabbix数据库导入表

root@Zabbix-Server:~# zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix

3.修改zabbix-server配置文件

root@Zabbix-Server:~# vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix@123

4.启动Zabbix

root@Zabbix-Server:~# systemctl start zabbix-server zabbix-agent apache2
root@Zabbix-Server:~# systemctl enable zabbix-server zabbix-agent apache2
Synchronizing state of zabbix-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-server
Synchronizing state of zabbix-agent.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /lib/systemd/system/zabbix-agent.service.
root@Zabbix-Server:~# netstat -lnp |grep zabbix
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      7952/zabbix_agentd  
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      16950/zabbix_server 
tcp6       0      0 :::10050                :::*                    LISTEN      7952/zabbix_agentd  
tcp6       0      0 :::10051                :::*                    LISTEN      16950/zabbix_server 
unix  2      [ ACC ]     STREAM     LISTENING     65053    16950/zabbix_server  /run/zabbix/zabbix_server_rtc.sock
unix  2      [ ACC ]     STREAM     LISTENING     65064    16951/zabbix_server  /run/zabbix/zabbix_server_haservice.sock
unix  2      [ ACC ]     STREAM     LISTENING     75471    16956/zabbix_server  /run/zabbix/zabbix_server_alerter.sock
unix  2      [ ACC ]     STREAM     LISTENING     68123    16952/zabbix_server  /run/zabbix/zabbix_server_service.sock
unix  2      [ ACC ]     STREAM     LISTENING     65086    16964/zabbix_server  /run/zabbix/zabbix_server_lld.sock
unix  2      [ ACC ]     STREAM     LISTENING     75480    16960/zabbix_server  /run/zabbix/zabbix_server_preprocessing.sock
unix  2      [ ACC ]     STREAM     LISTENING     74733    17018/zabbix_server  /run/zabbix/zabbix_server_availability.sock

四、浏览器访问配置Zabbix

浏览器访问地址:http://IP/zabbix

1.安装语言无法选择,需要先在web服务器上安装语言包

root@Zabbix-Server:~# apt-get -y install language-pack-zh-hant language-pack-zh-hans
root@Zabbix-Server:~# vim /etc/environment
LANG=“zh_CN.UTF-8” LANGUAGE=“zh_CN:zh:en_US:en”


2.配置数据库链接


3.安装


4.登录访问,默认账号密码:Admin zabbix

五、解决浏览器中文乱码问题

1.去windows下控制面板-字体-复制(楷体-常规)

2.确认字体文件路径并进行替换

root@Zabbix-Server:~# find / -name defines.inc.php
/usr/share/zabbix/include/defines.inc.php
root@Zabbix-Server:~# cat /usr/share/zabbix/include/defines.inc.php |grep graphfont
define('ZBX_GRAPH_FONT_NAME',		'graphfont'); // font file name
define('ZBX_FONT_NAME', 'graphfont');
root@Zabbix-Server:~# cd /usr/share/zabbix/assets/fonts/
root@Zabbix-Server:/usr/share/zabbix/assets/fonts# ll
total 8
drwxr-xr-x 2 root root 4096 Mar 31 02:42 ./
drwxr-xr-x 5 root root 4096 Mar 31 02:41 ../
lrwxrwxrwx 1 root root   38 Mar 31 02:42 graphfont.ttf -> /etc/alternatives/zabbix-frontend-font
root@Zabbix-Server:/usr/share/zabbix/assets/fonts# rm -rf /etc/alternatives/zabbix-frontend-font 
root@Zabbix-Server:/usr/share/zabbix/assets/fonts# cd /etc/alternatives/
root@Zabbix-Server:/etc/alternatives# ln -s /usr/share/zabbix/assets/fonts/SIMKAI.TTF /etc/alternatives/zabbix-frontend-font



来源:https://www.cnblogs.com/studywen/p/16080460.html
回覆

使用道具 舉報

0

主題

720

回帖

4441

積分

琼殿精英

金币
3721
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2011-10-11
發表於 2026-5-10 06:53:57 | 顯示全部樓層
感谢楼主的详细教程!
太详细了,按照你的步骤一步步来居然一次就成功了!

补充几点小建议:


  • 关于数据库密码,建议生产环境使用更复杂的密码,不要用这种简单的组合
  • zabbix-server的配置文件里其实还可以调整一下DBHost,默认是localhost,如果需要远程连接数据库可以改一下
  • 防火墙记得开放10050和10051端口,否则客户端可能连不上:
    1. ufw allow 10050/tcp
    2. ufw allow 10051/tcp
    複製代碼
  • 如果后续要监控更多主机,记得在zabbix-web里把agent的自动注册配置好


另外想问下:楼主的这篇是部署服务端,那客户端的部署有计划出吗?期待后续的监控客户端安装教程!

点赞支持!  :
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部