@Ubuntu20.04部署安裝zabbix6.0版本(Grafana Dashboard展示)


Ubuntu部署安裝zabbix6.0

1.zabbix服務端部署

【zabbix安裝包下載】

官網查看支持安裝的版本

在這里插入圖片描述

#安裝源下載獲取
root@UBUNTU:~# wget https://repo.zabbix.com/zabbix/5.5/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.5-1%2Bubuntu20.04_all.deb




#安裝zabbix官方倉庫源
root@UBUNTU:~# dpkg -i zabbix-release_5.5-1+ubuntu20.04_all.deb 
Selecting previously unselected package zabbix-release.
(Reading database ... 59747 files and directories currently installed.)
Preparing to unpack zabbix-release_5.5-1+ubuntu20.04_all.deb ...
Unpacking zabbix-release (1:5.5-1+ubuntu20.04) ...
Setting up zabbix-release (1:5.5-1+ubuntu20.04) ...
root@UBUNTU:~# 



#更新Ubuntu系統
root@UBUNTU:~# apt update
Hit:1 http://azure.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]         
Get:3 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]       
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]             
Get:5 https://repo.zabbix.com/zabbix/5.5/ubuntu focal InRelease [4958 B]           
....





#zabbix相關組件安裝
root@UBUNTU:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fping libapache2-mod-php
  libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libjansson4 libjbig0 libjpeg-turbo8 libjpeg8
  liblua5.2-0 libmodbus5 libmysqlclient21 libodbc1 libonig5 libopenipmi0 libsensors-config libsensors5 libsnmp-base libsnmp35 libtiff5 libwebp6 libxpm4
  mysql-client mysql-client-8.0 mysql-client-core-8.0 mysql-common php-bcmath php-common php-gd php-ldap php-mbstring php-mysql php-xml php7.4-bcmath php7.4-cli
  php7.4-common php7.4-gd php7.4-json php7.4-ldap php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml snmpd ssl-cert
 .......

2.數據庫安裝

#mysql數據庫安裝
root@UBUNTU:~# apt install -y mysql-server




#數據庫初始化
root@UBUNTU:~# mysql_secure_installation





#登錄數據庫創建用戶(zabbix使用用戶)
root@UBUNTU:~# mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, 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 utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.02 sec)

mysql>  create user zabbix@"%" identified by 'Zabbix@2022';
Query OK, 0 rows affected (0.02 sec)

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

mysql> quit;



#創建用戶測試連接
root@UBUNTU:~# mysql -uzabbix -pZabbix@2022
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 186
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, 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> quit
Bye




#遠程測試連接
root@UBUNTU:~# mysql -h172.0.0.1 -uzabbix -pZabbix@2022
mysql: [Warning] Using a password on the command line interface can be insecure.
^C
root@UBUNTU:~# mysql -hlocalhost -uzabbix -pZabbix@2022
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 189
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, 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> quit 
Bye




#mysql配置修改(指遠程IP,可忽略)
root@UBUNTU:~# vim /etc/mysql/my.cnf
#bind-address = 192.168.10.10




#啟動數據庫
root@UBUNTU:~# systemctl start mysql.service




#查看mysql狀態
root@UBUNTU:~# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-01-15 09:13:51 UTC; 18s ago
    Process: 26930 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 26938 (mysqld)
     Status: "Server is operational"
      Tasks: 54 (limit: 4711)
     Memory: 445.8M
     CGroup: /system.slice/mysql.service
             └─26938 /usr/sbin/mysqld

Jan 15 09:13:49 UBUNTU systemd[1]: Starting MySQL Community Server...
Jan 15 09:13:51 UBUNTU systemd[1]: Started MySQL Community Server.



#查看當前mysql版本
root@UBUNTU:~# mysql -V
mysql  Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
root@UBUNTU:~# mysql -hlocalhost -uzabbix -pZabbix@2022
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, 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> status 
--------------
mysql  Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

Connection id:		31
Current database:	
Current user:		zabbix@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.27-0ubuntu0.20.04.1 (Ubuntu)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/run/mysqld/mysqld.sock
Binary data as:		Hexadecimal
Uptime:			4 min 13 sec

Threads: 20  Questions: 3725  Slow queries: 0  Opens: 384  Flush tables: 3  Open tables: 303  Queries per second avg: 14.723
--------------

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 8.0.27-0ubuntu0.20.04.1 |
+-------------------------+
1 row in set (0.00 sec)

mysql> quit
Bye

3.zabbix配置

#更改zabbix時區
root@UBUNTU:~# vim /etc/zabbix/apache.conf 
php_value date.timezone Asia/Shanghai




#zabbix數據庫導入表
root@UBUNTU:~# zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -pZabbix@2022 -Dzabbix
mysql: [Warning] Using a password on the command line interface can be insecure.




#zabbix-server配置文件修改
root@UBUNTU:~# egrep "^[^#]" /etc/zabbix/zabbix_server.conf 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbix/zabbix_server.pid
SocketDir=/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix@2022
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1




#啟動zabbix相關服務(加入開機自啟動)
root@UBUNTU:~# systemctl restart zabbix-server zabbix-agent apache2
root@UBUNTU:~# systemctl enable zabbix-server zabbix-agent apache2




#查看端口
root@UBUNTU:~# netstat -lntp |grep zabbix
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      23641/zabbix_agentd 
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      23643/zabbix_server 
tcp6       0      0 :::10050                :::*                    LISTEN      23641/zabbix_agentd 
tcp6       0      0 :::10051                :::*                    LISTEN      23643/zabbix_server 

4.版本查看

#zabbix-server版本
root@UBUNTU:~# zabbix_server -V
zabbix_server (Zabbix) 6.0.0beta2
Revision 1ff76345b1 11 January 2022, compilation time: Dec 14 2021 16:13:04

Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.1.1f  31 Mar 2020
Running with OpenSSL 1.1.1f  31 Mar 2020




#zabbix-agent版本
root@UBUNTU:~# zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 6.0.0beta2
Revision 1ff76345b1 11 January 2022, compilation time: Dec 14 2021 16:13:04

Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.1.1f  31 Mar 2020
Running with OpenSSL 1.1.1f  31 Mar 2020




#apache版本
root@UBUNTU:~# apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2022-01-05T14:49:56



#php版本
root@UBUNTU:~# php -v
PHP 7.4.3 (cli) (built: Nov 25 2021 23:16:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies




#mysql版本
root@UBUNTU:~# mysql -V
mysql  Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

5.zabbix-web

#web登錄使用
http://192.168.10.10/zabbix/setup.php

user:Admin
passwd:zabbix







#語言包安裝(web選擇語言)
root@UBUNTU:~# apt-get -y install language-pack-zh-hant language-pack-zh-hans
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  language-pack-zh-hans-base language-pack-zh-hant-base
The following NEW packages will be installed:
  language-pack-zh-hans language-pack-zh-hans-base language-pack-zh-hant language-pack-zh-hant-base
 ......
 

選擇語言(以上安裝可忽略)

在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

以下狀態表示安裝完成

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

6.解決web中文字體亂碼

可以選擇windows中的字符:C:\Windows\Fonts

#當前web使用的字符文件
root@UBUNTU:~# cd /usr/share/zabbix/assets/fonts/
root@UBUNTU:/usr/share/zabbix/assets/fonts# ls -l
total 0
lrwxrwxrwx 1 root root 38 Jan 15 05:53 graphfont.ttf -> /etc/alternatives/zabbix-frontend-font




#刪除原來的軟鏈接
root@UBUNTU:/usr/share/zabbix/assets/fonts# rm -rf /etc/alternatives/zabbix-frontend-font



#新創建軟鏈接即可
root@UBUNTU:/etc/alternatives# ln -s /usr/share/zabbix/assets/fonts/graphfont.ttf /etc/alternatives/zabbix-frontend-font

7.zabbix使用grafana

#下載grafana
root@UBUNTU:~# wget https://mirrors.tuna.tsinghua.edu.cn/grafana/apt/pool/main/g/grafana/grafana_8.3.1_amd64.deb



#安裝grafana
root@UBUNTU:~# dpkg -i grafana_8.3.1_amd64.deb 
Selecting previously unselected package grafana.
(Reading database ... 63910 files and directories currently installed.)
Preparing to unpack grafana_8.3.1_amd64.deb ...
Unpacking grafana (8.3.1) ...
Setting up grafana (8.3.1) ...
Adding system user `grafana' (UID 116) ... Adding new user `grafana' (UID 116) with group `grafana' ... Not creating home directory `/usr/share/grafana'.
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
 sudo /bin/systemctl daemon-reload
 sudo /bin/systemctl enable grafana-server
### You can start grafana-server by executing
 sudo /bin/systemctl start grafana-server
Processing triggers for systemd (245.4-4ubuntu3.15) ...



#啟動並設置開機自啟
root@UBUNTU:~# systemctl start grafana-server.service
root@UBUNTU:~# systemctl enable grafana-server.service
Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /lib/systemd/system/grafana-server.service.




#查看grafana端口
root@UBUNTU:~# netstat -lntp |grep grafana
tcp6       0      0 :::3000                 :::*                    LISTEN      31868/grafana-serve 





#web訪問登錄grafana
http://192.168.10.10:3000/  
#zabbix服務端IP地址+端口號(新用戶登錄改密碼,可以跳過)



#檢查zabbix插件
root@UBUNTU:~# grafana-cli plugins list-remote | grep zabbix
id: alexanderzobnin-zabbix-app version: 4.2.4




#安裝zabbix
root@UBUNTU:~# grafana-cli plugins install alexanderzobnin-zabbix-app
✔ Downloaded alexanderzobnin-zabbix-app v4.2.4 zip successfully

Please restart Grafana after installing plugins. Refer to Grafana documentation for instructions if necessary.





#啟動grafana服務
root@UBUNTU:~# systemctl restart grafana-server.service




#web選擇zabbix插件

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述

【Grafana Dashboard】

在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM