【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
.......
#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
#更改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
#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))
#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
......
选择语言(以上安装可忽略)
以下状态表示安装完成
可以选择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
#下载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】