rocky8.6安装部署zabbix6.4.0

一、环境准备与安装部署

1.1、配置zabbix yum源

# rpm -Uvh https://repo.zabbix.com/zabbix/6.3/rhel/8/x86_64/zabbix-release-6.3-1.el8.noarch.rpm
# dnf clean all

1.2、安装zabbix-server

# dnf module switch-to php:7.4
# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y
[root@zabbix-server-01 ~]# zabbix_server -V
zabbix_server (Zabbix) 6.4.0beta1
Revision a01f5df47bf 29 September 2022, compilation time: Sep 29 2022 12:52:41

Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/>.
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.1k  FIPS 25 Mar 2021
Running with OpenSSL 1.1.1k  FIPS 25 Mar 2021
[root@zabbix-server-01 ~]# 

1.3、安装mysql数据库

[root@zabbix-server-01 ~]# yum -y install mysql-server 

[root@zabbix-server-01 ~]# systemctl enable --now mysqld

1.4、配置mysql

[root@zabbix-server-01 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Source distribution

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>
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)

mysql> create user zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.03 sec)

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

mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@zabbix-server-01 ~]# 

如果mysql与zabbix-server不在同一台主机

mysql> create user zabbix@'172.16.88.%' identified by '123456';
mysql> grant all privileges on zabbix.* to zabbix@'172.16.88.%';
#注意: 如果使用MySQL8.0还需要执行下面 mysql
>ALTER USER zabbix@'172.16.88.%' IDENTIFIED WITH mysql_native_password BY '123456';
#或者执行下面 [root@zabbix
-server ~]#echo 'default-authentication-plugin=mysql_native_password' >> /etc/my.cnf.d/mysql-server.cnf [root@zabbix-server ~]#systemctl enable --now mysqld

1.5、导入zabbix数据表

vim 编辑server.sql.gz添加use zabbix;选项

[root@zabbix-server-01 ~]# vim /usr/share/zabbix-sql-scripts/mysql/server.sql.gz

不添加会报"No database selected"

[root@zabbix-server-01 mysql]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1046 (3D000) at line 1: No database selected
[root@zabbix-server-01 mysql]#
[root@zabbix-server-01 mysql]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-server-01 mysql]# 

导完数据库需要关闭log_bin_trust_function_creators

[root@zabbix-server-01 mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.26 Source distribution

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> SET GLOBAL log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)

mysql> 

1.6、配置zabbix-server数据库

[root@zabbix-server-01 ~]# vim /etc/zabbix/zabbix_server.conf

DBPassword=123456

启动服务

[root@zabbix-server-01 ~]# systemctl enable --now zabbix-server zabbix-agent nginx php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@zabbix-server-01 ~]# 

1.7、配置软链接

[root@zabbix-server-01 ~]# cd  /usr/share/nginx/html
[root@zabbix-server-01 html]# ln -s /usr/share/zabbix zabbix

否则nginx服务启动会报文件路径找不到

[root@zabbix-server-01 ~]# less /var/log/nginx/error.log

1.8、配置zabbix

 检查安装条件

 解决办法

[root@zabbix-server-01 php-fpm.d]# egrep -v "^;|^#|^$" www.conf 
[www]
user = apache
group = apache
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache
php_value[max_execution_time] = 300
php_value[post_max_size] = 32M
php_value[max_input_time] = 300
[root@zabbix-server-01 php-fpm.d]# 

[root@zabbix-server-01 php-fpm.d]# systemctl restart php-fpm.service

1.9、字符乱码

找到windows字体并上传到zabbix服务端

 

 导入并修改原有的字体

[root@zabbix-server-01 ~]# cd /usr/share/zabbix/assets/fonts
[root@zabbix-server-01 fonts]# ls
graphfont.ttf
[root@zabbix-server-01 fonts]# ll -h 
total 0
lrwxrwxrwx 1 root root 33 Oct  8 19:23 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@zabbix-server-01 fonts]# ls
graphfont.ttf
[root@zabbix-server-01 fonts]# ll -h /etc/alternatives/
total 0
lrwxrwxrwx. 1 root root 39 Jul 25 21:18 cifs-idmap-plugin -> /usr/lib64/cifs-utils/cifs_idmap_sss.so
lrwxrwxrwx. 1 root root 15 Jul 25 21:18 ld -> /usr/bin/ld.bfd
lrwxrwxrwx. 1 root root 34 Jul 25 21:17 libnssckbi.so.x86_64 -> /usr/lib64/pkcs11/p11-kit-trust.so
lrwxrwxrwx. 1 root root 45 Jul 25 21:22 libwbclient.so.0.15-64 -> /usr/lib64/samba/wbclient/libwbclient.so.0.15
lrwxrwxrwx. 1 root root 22 Jul 25 21:17 python -> /usr/libexec/no-python
lrwxrwxrwx. 1 root root 43 Jul 25 21:17 unversioned-python-man -> /usr/share/man/man1/unversioned-python.1.gz
lrwxrwxrwx  1 root root 29 Oct  8 19:23 zabbix-server -> /usr/sbin/zabbix_server_mysql
lrwxrwxrwx  1 root root 38 Oct  8 19:23 zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@zabbix-server-01 fonts]# ll -h
total 11M
lrwxrwxrwx 1 root root  33 Oct  8 19:23 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r-- 1 root root 11M Oct  8 21:32 STFANGSO.TTF #上传新的字体文件
[root@zabbix-server-01 fonts]# mv STFANGSO.TTF /usr/share/fonts/dejavu/ #把字体文件拷贝到zabbix字体路径
[root@zabbix-server-01 fonts]# cd /usr/share/fonts/dejavu/
[root@zabbix-server-01 dejavu]# ls
DejaVuSans-BoldOblique.ttf           DejaVuSansCondensed-Bold.ttf     DejaVuSans-ExtraLight.ttf       DejaVuSansMono-Oblique.ttf  DejaVuSans.ttf
DejaVuSans-Bold.ttf                  DejaVuSansCondensed-Oblique.ttf  DejaVuSansMono-BoldOblique.ttf  DejaVuSansMono.ttf          STFANGSO.TTF
DejaVuSansCondensed-BoldOblique.ttf  DejaVuSansCondensed.ttf          DejaVuSansMono-Bold.ttf         DejaVuSans-Oblique.ttf
[root@zabbix-server-01 dejavu]# ll -h
total 18M
-rw-r--r--  1 root root 627K May 17  2015 DejaVuSans-BoldOblique.ttf
-rw-r--r--  1 root root 688K May 17  2015 DejaVuSans-Bold.ttf
-rw-r--r--  1 root root 596K May 17  2015 DejaVuSansCondensed-BoldOblique.ttf
-rw-r--r--  1 root root 648K May 17  2015 DejaVuSansCondensed-Bold.ttf
-rw-r--r--  1 root root 584K May 17  2015 DejaVuSansCondensed-Oblique.ttf
-rw-r--r--  1 root root 664K May 17  2015 DejaVuSansCondensed.ttf
-rw-r--r--  1 root root 347K May 17  2015 DejaVuSans-ExtraLight.ttf
-rw-r--r--. 1 root root 248K May 17  2015 DejaVuSansMono-BoldOblique.ttf
-rw-r--r--. 1 root root 324K May 17  2015 DejaVuSansMono-Bold.ttf
-rw-r--r--. 1 root root 246K May 17  2015 DejaVuSansMono-Oblique.ttf
-rw-r--r--. 1 root root 333K May 17  2015 DejaVuSansMono.ttf
-rw-r--r--  1 root root 619K May 17  2015 DejaVuSans-Oblique.ttf
-rw-r--r--  1 root root 739K May 17  2015 DejaVuSans.ttf
-rw-r--r--  1 root root  11M Oct  8 21:32 STFANGSO.TTF
[root@zabbix-server-01 dejavu]# mv STFANGSO.TTF DejaVuSans.ttf #替换覆盖旧的字体
mv: overwrite 'DejaVuSans.ttf'? y
[root@zabbix-server-01 dejavu]# ll -h
total 17M
-rw-r--r--  1 root root 627K May 17  2015 DejaVuSans-BoldOblique.ttf
-rw-r--r--  1 root root 688K May 17  2015 DejaVuSans-Bold.ttf
-rw-r--r--  1 root root 596K May 17  2015 DejaVuSansCondensed-BoldOblique.ttf
-rw-r--r--  1 root root 648K May 17  2015 DejaVuSansCondensed-Bold.ttf
-rw-r--r--  1 root root 584K May 17  2015 DejaVuSansCondensed-Oblique.ttf
-rw-r--r--  1 root root 664K May 17  2015 DejaVuSansCondensed.ttf
-rw-r--r--  1 root root 347K May 17  2015 DejaVuSans-ExtraLight.ttf
-rw-r--r--. 1 root root 248K May 17  2015 DejaVuSansMono-BoldOblique.ttf
-rw-r--r--. 1 root root 324K May 17  2015 DejaVuSansMono-Bold.ttf
-rw-r--r--. 1 root root 246K May 17  2015 DejaVuSansMono-Oblique.ttf
-rw-r--r--. 1 root root 333K May 17  2015 DejaVuSansMono.ttf
-rw-r--r--  1 root root 619K May 17  2015 DejaVuSans-Oblique.ttf
-rw-r--r--  1 root root  11M Oct  8 21:32 DejaVuSans.ttf
[root@zabbix-server-01 dejavu]# 

二、zabbix对接grafana

2.1、准备一台机器并安装grafana

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.1.7-1.x86_64.rpm
sudo yum install grafana-enterprise-9.1.7-1.x86_64.rpm

[root@grafana-01 ~]# systemctl enable --now grafana-server

2.2、在grafana中安装zabbix插件

[root@grafana-01 ~]# grafana-cli plugins list-remote|grep zabbix
id: alexanderzobnin-zabbix-app version: 4.2.10
[root@grafana-01 ~]# grafana-cli plugins install alexanderzobnin-zabbix-app 4.2.10
✔ Downloaded and extracted alexanderzobnin-zabbix-app v4.2.10 zip successfully to /var/lib/grafana/plugins/alexanderzobnin-zabbix-app

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

[root@grafana-01 ~]# grafana-cli plugins ls
installed plugins:
alexanderzobnin-zabbix-app @ 4.2.10
Please restart Grafana after installing plugins. Refer to Grafana documentation for instructions if necessary.

[root@grafana-01 ~]# systemctl restart grafana-server.service
[root@grafana-01 ~]#

在grafana中启用zabbix

 添加zabbix数据源

导入自带模板

 

posted @ 2022-10-20 18:29  cyh00001  阅读(1323)  评论(0编辑  收藏  举报