要完成离线安装需要先准备一台与离线服务器装有相同操作系统的电脑联网下载安装包。
1、登陆zabbix官网,选择要安装的zabbix版本。地址:https://www.zabbix.com/cn/download?zabbix=4.4&os_distribution=centos&os_version=8&db=mysql&ws=nginx。这里我们选择zabbix4.4版本, CentOS8、mysql数据库、Nignx。

2、用能上网的主机下载安装包
参考官网安装步骤:

用能上网的主机安装zabbix-release-4.4-1.el8.noarch.rpm,下载对应的安装包。在执行rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm进行安装时如果碰上网络不好会出现以下情况:

这时我们可以考虑使用国内的镜像进行安装,这里采用阿里云的镜像。步骤如下:
1)rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm

2)因为我们是通过阿里云镜像进行下载,此处需要修改此次下载使用的软件仓库文件,地址/etc/yum.repos.d路径下zabbix.repo文件,需要修改为阿里云的镜像地址,具体修改如下:

3)在/root目录下创建zabbix目录(因为我使用的root用户进行安装,如果选用其它用户可以自己定义下载路径),存放下载的安装包。
mkdir zabbix
通过dnf命令下载对应的安装包,此处只下载不安装,指定的下载路径为/root/zabbix
dnf install --downloadonly --downloaddir=/root/zabbix zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-agent


4)执行成功后zabbix目录下会下载27个.rpm结尾的安装文件,把这些文件拷贝到需要离网的服务器。
5)在最终的离网服务器上安装zabbix4.4.登录到安装文件目录执行安装命令。
rpm -Uvh ***.rpm #其中U表示更新,v表示显示安装过程,h表示显示进度

6)在mysql数据库上创建zabbix用户和zabbix数据库并导入数据。
创建zabbix用户
create user 'zabbix'@'localhost' identified by '123456zabbix';
为zabbix用户赋权,zabbix用户对所有数据库中文件可以做任何操作
grant all privileges on *.* to "zabbix"@'localhost';
创建zabbix数据库,此处一定要指定utf8字符集,而且必须是utf8字符集,如果是别的字符集在配置zabbix的时候肯定要报错。
create database zabbix character set utf8 collate utf8_bin;
向zabbix数据库导入数据,执行以下命令:
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbix -p
此处肯定会出现以下错误:

这里需要通过vim命令修改create.sql.gz文件。执行以下命令:
vim /usr/share/doc/zabbix-server-mysql/create.sql.gz
在打开的文件中点击"i"键,在文件的最上面插入use zabbix;。然后点击esc键,:wq!保存退出。此处就是在加载数据文件的时候首先切换到zabbix数据库。然后再执行zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbix -p命令,加载数据。最后会在zabbix数据库离创建149个表的数据。
导入数据时如果出现以下错误:
ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)
需要登录数据库执行:
ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456zabbix';
赋予本地访问权限。

参考官网安装步骤:

7)为Zabbix server配置数据库。执行以下命令
vi /etc/zabbix/zabbix_server.conf

8)修改nginx配置文件,为Zabbix前端配置PHP
修改/etc/nginx目录下的nginx.conf文件,修改方法就是用/etc/nginx/conf.d/zabbix.conf文件中的内容替换/etc/nginx/nginx.conf文件中server括号内的内容。
vi /etc/nginx/nginx.conf
要将listen和server_name前面的注释删掉。

9)编辑配置文件 /etc/php-fpm.d/zabbix.conf,修改时区,前面的“;”一定要去掉。中国只能改为Asia/Shanghai,不能是Asia/Beijing。 😊


10)关闭SElinux,firewalld,具体的执行命令参考以下信息:
#查看selinux状态
[root@localhost zabbix]# getenforce
Enforcing #开启状态
#设置selinux为被动模式
[root@localhost zabbix]# setenforce 0
[root@localhost zabbix]# getenforce
Permissive #被动模式
[root@localhost zabbix]# vi /etc/selinux/config
SELINUX=disable
#查看firewall是否开机启动
[root@localhost zabbix]# systemctl list-unit-files | grep fire
firewalld.service enabled
#查看firewall是否正在运行
[root@localhost zabbix]# systemctl status firewalld.service
[root@localhost zabbix]# systemctl list-units | grep fire
#停掉firewall,并禁止开机启动
[root@localhost zabbix]# systemctl stop firewalld.service
[root@localhost zabbix]# systemctl disable firewalld.service



11)启动zabbix进程
systemctl restart zabbix-server zabbix-agent nginx php-fpm
设置为开机启动
systemctl enable zabbix-server zabbix-agent nginx php-fpm
如果启动失败肯定是SElinux,firewalld没有关闭的原因,检查是否关闭。
12)通过前端页面进行zabbix设置,访问http://localhost/setup.php地址。

数据库设置界面需要输入zabbix用户的密码,同时容易出现字符集错误,所以创建的zabbix数据库必须使用SET utf8 COLLATE utf8_bin;如果设置错误,数据导入后再修改字符集也会报错,只能删除数据库重新创建。所以一定要保证使用的字符集正确。

数据库设置时还需要在数据库中执行以下ALTER USER 'zabbix_username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'zabbix_password';(需要修改对应的用户名和密码),这样zabbix服务才能在本地访问mysql数据库。
数据库配置可能出现以下问题,如果日志/var/log/zabbix/zabbix_server.log中看到以下错误

肯定是导入数据表有问题,实际操作中出现过导入表数量没问题,但是表无法打开的问题。需要重新执行表导入操作。
以下错误可以通过再次修改密码解决
query failed: [1053] Server shutdown in progress [select taskid,type,clock,ttl from task where status in (1,2) order by taskid]
7039:20200915:204305.347 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

通过Admin/zabbix 用户名/密码登录系统。
安装完成!
问题:
10258:20201105:044732.399 __mem_malloc: skipped 4 asked 6296 skip_min 352 skip_max 5840
10258:20201105:044732.399 [file:dbconfig.c,line:94] __zbx_mem_realloc(): out of memory (requested 6296 bytes)
10258:20201105:044732.399 [file:dbconfig.c,line:94] __zbx_mem_realloc(): please increase CacheSize configuration parameter
10258:20201105:044732.399 === memory statistics for configuration cache ===
解决方法:
找到zabbix_server.conf文件
在zabbix_server.conf文件搜索CacheSize=8M或者VMwareCacheSize=8M,将其修改为CacheSize=1024M
重启:
systemctl restart zabbix-server zabbix-agent nginx php-fpm
参考摘录文档:
https://www.zabbix.com/download?zabbix=4.4&os_distribution=centos&os_version=8&db=mysql&ws=nginx
https://www.cnblogs.com/forlive/p/9358605.html
https://blog.csdn.net/yulei_qq/article/details/83713472
https://www.cnblogs.com/opsprobe/p/10812274.html
https://www.cnblogs.com/wangyueping/p/11258028.html
https://blog.csdn.net/u013948852/article/details/99842484
https://blog.csdn.net/zhaowenzhong/article/details/83753946
https://www.cnblogs.com/wangyueping/p/11258028.html
https://www.cnblogs.com/will--1213/p/11824550.html
https://blog.csdn.net/abcdu1/article/details/89471790
zabbix图形展现中文乱码解决方法
https://blog.csdn.net/qq43748322/article/details/85676511
上传的字体可以随便放一个目录内,指定的位置正确就可以
网友评论