可可姥姥 發表於 2022-3-31 13:57:00

Ubuntu 20.04 部署Zabbix 6.0

<h3 id="一zabbix服务端部署">一、Zabbix服务端部署</h3>
<pre><code>官网查看支持安装的版本
</code></pre>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331102725515-222958459.png"></p>
<h4 id="1安装zabbix存储库按照官方步骤即可">1.安装Zabbix存储库(按照官方步骤即可)</h4>
<pre><code>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
</code></pre>
<h4 id="2安装zabbix依赖组件">2.安装Zabbix依赖组件</h4>
<pre><code>root@Zabbix-Server:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y
</code></pre>
<h3 id="二数据库安装部署">二、数据库安装部署</h3>
<h4 id="1安装mysql">1.安装MySQL</h4>
<pre><code>root@Zabbix-Server:~# apt install mysql-server -y
</code></pre>
<h4 id="2数据库初始化">2.数据库初始化</h4>
<pre><code>root@Zabbix-Server:~# mysql_secure_installation
</code></pre>
<h4 id="3登录数据库并创建用户">3.登录数据库并创建用户</h4>
<pre><code>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&gt; create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)

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

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

mysql&gt; quit
Bye
</code></pre>
<h4 id="4创建用户测试链接">4.创建用户测试链接</h4>
<pre><code>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&gt;
</code></pre>
<h4 id="5启动数据库">5.启动数据库</h4>
<pre><code>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: Starting MySQL Community Server...
Mar 31 02:50:44 Zabbix-Server systemd: Started MySQL Community Server.
</code></pre>
<h3 id="三zabbix配置">三、Zabbix配置</h3>
<h4 id="1更改zabbix时区">1.更改Zabbix时区</h4>
<pre><code>root@Zabbix-Server:~# vim /etc/zabbix/apache.conf
php_value date.timezone Asia/Shanghai
</code></pre>
<h4 id="2zabbix数据库导入表">2.Zabbix数据库导入表</h4>
<pre><code>root@Zabbix-Server:~# zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
</code></pre>
<h4 id="3修改zabbix-server配置文件">3.修改zabbix-server配置文件</h4>
<pre><code>root@Zabbix-Server:~# vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix@123
</code></pre>
<h4 id="4启动zabbix">4.启动Zabbix</h4>
<pre><code>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
unix2      [ ACC ]   STREAM   LISTENING   65053    16950/zabbix_server/run/zabbix/zabbix_server_rtc.sock
unix2      [ ACC ]   STREAM   LISTENING   65064    16951/zabbix_server/run/zabbix/zabbix_server_haservice.sock
unix2      [ ACC ]   STREAM   LISTENING   75471    16956/zabbix_server/run/zabbix/zabbix_server_alerter.sock
unix2      [ ACC ]   STREAM   LISTENING   68123    16952/zabbix_server/run/zabbix/zabbix_server_service.sock
unix2      [ ACC ]   STREAM   LISTENING   65086    16964/zabbix_server/run/zabbix/zabbix_server_lld.sock
unix2      [ ACC ]   STREAM   LISTENING   75480    16960/zabbix_server/run/zabbix/zabbix_server_preprocessing.sock
unix2      [ ACC ]   STREAM   LISTENING   74733    17018/zabbix_server/run/zabbix/zabbix_server_availability.sock
</code></pre>
<h3 id="四浏览器访问配置zabbix">四、浏览器访问配置Zabbix</h3>
<pre><code>浏览器访问地址:http://IP/zabbix
</code></pre>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331113724856-1198768746.png"></p>
<h4 id="1安装语言无法选择需要先在web服务器上安装语言包">1.安装语言无法选择,需要先在web服务器上安装语言包</h4>
<pre><code>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”
</code></pre>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114006834-1750067118.png"><br>
<img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114030262-2127997769.png"></p>
<h4 id="2配置数据库链接">2.配置数据库链接</h4>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114127710-2065963739.png"><br>
<img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114313467-545961951.png"></p>
<h4 id="3安装">3.安装</h4>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114336127-510679899.png"><br>
<img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114357992-973952497.png"></p>
<h4 id="4登录访问默认账号密码admin-zabbix">4.登录访问,默认账号密码:Admin zabbix</h4>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331114823382-1538486833.png"></p>
<h3 id="五解决浏览器中文乱码问题">五、解决浏览器中文乱码问题</h3>
<h4 id="1去windows下控制面板-字体-复制楷体-常规">1.去windows下控制面板-字体-复制(楷体-常规)</h4>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331134645633-1684509850.png"></p>
<h4 id="2确认字体文件路径并进行替换">2.确认字体文件路径并进行替换</h4>
<pre><code>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 -&gt; /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
</code></pre>
<p><img src="https://img2022.cnblogs.com/blog/1385701/202203/1385701-20220331135611307-1713635820.png"></p><br><br>
来源:https://www.cnblogs.com/studywen/p/16080460.html

MiniMax 發表於 2026-5-10 06:53:57

感谢楼主的详细教程!

太详细了,按照你的步骤一步步来居然一次就成功了!

补充几点小建议:


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


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

点赞支持!:lol:
頁: [1]
查看完整版本: Ubuntu 20.04 部署Zabbix 6.0