CentOS7.3内网二进制包安装Zabbix4.4

环境概要:服务器部署在内网环境,无法连通互联网。

[root@centos7 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@centos7 ~]# ping www.baidu.com
^C

事前准备

在内网环境下配置好本地yum源,解决zabbix安装包的依赖包问题。

安装步骤详情如下:

1、查看SELINUX状态

若是没有关闭的时候,状态为enabled。

[root@centos7 ~]# sestatus -v | grep 'SELinux status'
SELinux status:                 disabled

2、临时关闭,重启后失效

[root@centos7 ~]# setenforce 0

3、永久关闭,重启后生效

[root@centos7 ~]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
备注:生产环境未启动可以步骤2、3一起执行,已启用则执行步骤2,看具体情况操作

4、生产环境不关闭防火墙,开启防火墙指定端口

[root@centos7 ~]# firewall-cmd --zone=public --add-port=15531/tcp --permanent
success
[root@centos7 ~]# firewall-cmd --reload
success

5、创建zabbix安装包存放目录,并搜寻zabbix4.4相关包上传

[root@centos7 ~]# mkdir -p /opt/zabbixPackage
[root@centos7 ~]# ll /opt/zabbixPackage/
total 2924
-rw-r--r-- 1 root root  428624 Apr  9 16:07 zabbix-agent-4.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2550236 Apr  9 16:07 zabbix-server-mysql-4.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root    9660 Apr  9 16:07 zabbix-web-mysql-4.4.0-1.el7.noarch.rpm
备注:zabbix4.4官网下载地址:https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/

6、安装zabbix的服务器、前端、代理

[root@centos7 ~]# cd /opt/zabbix_installPackage/
[root@centos7 zabbixPackage]# yum install zabbix-server-mysql-4.4.0-1.el7.x86_64.rpm #安装顺利
[root@centos7 zabbixPackage]# yum install zabbix-web-mysql-4.4.0-1.el7.noarch.rpm #安装报错
[root@centos7 zabbixPackage]# yum install zabbix-agent-4.4.0-1.el7.x86_64.rpm #安装顺利

zabbix-web-mysql-4.4.0-1.el7.noarch.rpm包在安装的时候报错,报错信息如下:

Error: Package: zabbix-web-mysql-4.4.0-1.el7.noarch (/zabbix-web-mysql-4.4.0-1.el7.noarch)
          Requires: zabbix-web = 4.4.0-1.el7
 You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
git-1.8.3.1-20.el7.x86_64 has missing requires of openssh-clients

根据报错,分别执行如下命令

yum install openssh-clients
yum install libzip php-common php-mysql php-pdo
yum install zabbix-web-mysql-4.4.0-1.el7.noarch.rpm --skip-broken

解决部分问题,最后报错信息如下:

Packages skipped because of dependency problems:
    zabbix-web-mysql-4.4.0-1.el7.noarch from /zabbix-web-mysql-4.4.0-1.el7.noarch

尝试其他方法未果,后来在使用rpm命令而不是yum命令的时候,发现如下报错提示信息:

[root@centos7 zabbixPackage]# rpm -ivh zabbix-web-mysql-4.4.0-1.el7.noarch.rpm 
error: Failed dependencies:
	zabbix-web = 4.4.0-1.el7 is needed by zabbix-web-mysql-4.4.0-1.el7.noarch

遂知道还要再下载一个zabbix-web安装包,上传后整体安装,信息如下:

[root@centos7 zabbix_installPackage]# ll
total 5904
-rw-r--r-- 1 root root  428624 Apr  9 16:07 zabbix-agent-4.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2550236 Apr  9 16:07 zabbix-server-mysql-4.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 3049336 Apr  9 17:14 zabbix-web-4.4.0-1.el7.noarch.rpm
-rw-r--r-- 1 root root    9660 Apr  9 17:06 zabbix-web-mysql-4.4.0-1.el7.noarch.rpm

[root@centos7 zabbixPackage]# yum zabbix-web-4.4.0-1.el7.noarch.rpm zabbix-web-mysql-4.4.0-1.el7.noarch.rpm #安装成功

7、搜寻mysql5.7相关rpm包上传安装

在安装之前,先把服务器自带的mariadb包进行卸载。

[root@centos7 zabbixlPackage]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@centos7 zabbixPackage]# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps

上传相关软件包并一并进行安装。

[root@centos7 zabbixPackage]# ll mysql*
-rw-r--r-- 1 root root  45109364 Apr  9 17:39 mysql-community-client-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root    318768 Apr  9 17:39 mysql-community-common-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root   4374364 Apr  9 17:45 mysql-community-libs-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 208694824 Apr  9 17:35 mysql-community-server-5.7.28-1.el7.x86_64.rpm

[root@centos7 zabbixPackage]# rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm mysql-community-common-5.7.28-1.el7.x86_64.rpm mysql-community-client-5.7.28-1.el7.x86_64.rpm mysql-community-server-5.7.28-1.el7.x86_64.rpm 
warning: mysql-community-libs-5.7.28-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.28-1.e################################# [ 25%]
   2:mysql-community-libs-5.7.28-1.el7################################# [ 50%]
   3:mysql-community-client-5.7.28-1.e################################# [ 75%]
   4:mysql-community-server-5.7.28-1.e################################# [100%]
备注:mysql5.7官网下载地址:http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/

8、登录mysql,创建Zabbix数据库

启动mysql服务

[root@centos7 zabbixPackage]# systemctl start mysqld

mysql5.7的密码在/var/log/mysqld.log文件中查看.
按照实际情况筛选,本次密码为szvYBMN?#2XZ,如下所示:

[root@out-172-46-32-11 zabbixPackage]# grep "password" /var/log/mysqld.log
2020-04-09T11:23:12.168509Z 1 [Note] A temporary password is generated for root@localhost: szvYBMN?#2XZ

输入查询得到的密码,登录mysql。
登录后首先需要重设密码,注意密码复杂度(这是mysql5.7版的默认要求)

[root@out-172-46-32-11 zabbixPackage]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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 password=password("Gdsy07!#");
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> 

创建zabbix的用户与数据库(注意创建用户时的密码复杂度),以下命令在mysql中执行:

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'Gdsy07!#';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

9、导入Zabbix的初始化数据

在导入的过程中,要输入自定的密码,密码输入正确后,会等待一段时间,若是没有报错则说明导入成功。

[root@centos7 zabbixPackage]# zcat /usr/share/doc/zabbix-server-mysql-4.4.0/create.sql.gz | mysql -u zabbix -p zabbix
Enter password: 
[root@out-172-46-32-11 zabbixPackage]# 

10、配置server端配置文件,设置httpd服务端口,zabbix密码、时区

[root@centos7 zabbixPackage]# vi /etc/httpd/conf/httpd.conf

进入vi编辑模式,先搜索,格式为/Listen,光标跳过去后,再修改Listen的值为自己在防火墙所开通的指定端口,最后键入:wq保存退出。如下图所示:
CentOS7.3内网二进制包安装Zabbix4.4_第1张图片

[root@centos7 zabbixPackage]# vi /etc/zabbix/zabbix_server.conf

进入vi编辑模式,先搜索,格式为/DBPassword,光标跳过去后,再修改DBPassword的值为自己设置的密码,最后键入:wq保存退出。如下图所示:
CentOS7.3内网二进制包安装Zabbix4.4_第2张图片

[root@centos7 zabbixPackage]# vi /etc/httpd/conf.d/zabbix.conf

进入vi编辑模式,先搜索,格式为/timezone,光标跳过去后,去掉注释,修改timezone的值为Asia/Shanghai(国人一般也是设置该时区,可根据需要设置其他国家时区),最后键入:wq保存退出。如下图所示:
CentOS7.3内网二进制包安装Zabbix4.4_第3张图片

11、重启Zabbix相关服务,并进行页面端配置

[root@out-172-46-32-11 zabbixPackage]# systemctl restart zabbix-server zabbix-agent
Job for zabbix-server.service failed because the control process exited with error code. See "systemctl status zabbix-server.service" and "journalctl -xe" for details.

在重启zabbix相关服务的时候提示报错信息,根据提示键入journalctl -xe,发现如下报错信息:

Apr 09 20:04:50 out-172-46-32-11 zabbix_server[895]: /usr/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
Apr 09 20:04:50 out-172-46-32-11 systemd[1]: zabbix-server.service: control process exited, code=exited status=127
Apr 09 20:04:50 out-172-46-32-11 systemd[1]: Failed to start Zabbix Server.

根据提示可知是zabbix在启动的时候没有找到libmysqlclient.so.18文件。查看资料发现,该文件是由mysql-community-libs-compat包提供,遂在前文所提mysql5.7官网下载该rpm包上传安装。

[root@out-172-46-32-11 zabbixPackage]# rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm 
warning: mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-compat-5.7.2################################# [100%]
[root@out-172-46-32-11 zabbixPackage]# systemctl restart httpd

在重启httpd服务时发现响应速度很慢,根据提示键入journalctl -xe,发现如下报错信息:

Apr 09 21:01:36 out-172-46-32-11 systemd[1]: httpd.service start operation timed out. Terminating.
Apr 09 21:03:06 out-172-46-32-11 systemd[1]: httpd.service stop-final-sigterm timed out. Killing.
Apr 09 21:03:06 out-172-46-32-11 systemd[1]: httpd.service: main process exited, code=killed, status=9/KILL
Apr 09 21:03:06 out-172-46-32-11 systemd[1]: Failed to start The Apache HTTP Server.
Apr 09 21:03:06 out-172-46-32-11 systemd[1]: Unit httpd.service entered failed state.
Apr 09 21:03:06 out-172-46-32-11 systemd[1]: httpd.service failed.

根据提示出现超时问题,查找相关资料,其中一个处理方法是对于DNS配置的调整。遂改动本内网服务器的相关配置后重启,vim /etc/resolv.conf,启动正常。

访问ip地址:port/zabbix,本例子为http://xx.xx.xx.69:15531/zabbix,即可进入zabbix配置页面,如下图:
CentOS7.3内网二进制包安装Zabbix4.4_第4张图片
CentOS7.3内网二进制包安装Zabbix4.4_第5张图片
CentOS7.3内网二进制包安装Zabbix4.4_第6张图片
CentOS7.3内网二进制包安装Zabbix4.4_第7张图片
CentOS7.3内网二进制包安装Zabbix4.4_第8张图片
CentOS7.3内网二进制包安装Zabbix4.4_第9张图片
CentOS7.3内网二进制包安装Zabbix4.4_第10张图片
CentOS7.3内网二进制包安装Zabbix4.4_第11张图片
CentOS7.3内网二进制包安装Zabbix4.4_第12张图片

至此,CentOS7.3 内网环境 二进制包安装Zabbix4.4已完成。

你可能感兴趣的:(CentOS7.3内网二进制包安装Zabbix4.4)