Centos7.9安装Zabbix4.2

缥帙各舒散,前后互相逾。这篇文章主要讲述Centos7.9安装Zabbix4.2相关的知识,希望能为你提供帮助。
Centos7.9安装Zabbix4.2查看系统信息:

[root@localhost opt]# uname -r
3.10.0-1160.el7.x86_64
[root@localhost opt]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

关闭系统防火墙


[root@shell ~]# systemctl stopfirewalld
[root@shell ~]# systemctl disablefirewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

查看selinux是否关闭


[root@shell ~]# grep -Ev "SELINUXTYPE=|^#" /etc/selinux/config
SELINUX=disabled

一、下载安装所需文件
1.1下载zabbix库文件
[root@shell ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm

1.2下载阿里镜像包
[root@shell ~]# yum -y install wget

[root@shell ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

1.3安装fedora存储库
[root@shell ~]# yum install -y epel-release

二、安装Zabbix-server
(自动安装依赖的httpd和php)
[root@shell ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

Installed:
zabbix-agent.x86_64 0:4.2.8-1.el7zabbix-server-mysql.x86_64 0:4.2.8-1.el7zabbix-web-mysql.noarch 0:4.2.8-1.el7

Dependency Installed:
OpenIPMI.x86_64 0:2.0.27-1.el7OpenIPMI-libs.x86_64 0:2.0.27-1.el7OpenIPMI-modalias.x86_64 0:2.0.27-1.el7apr.x86_64 0:1.4.8-7.el7
apr-util.x86_64 0:1.5.2-6.el7dejavu-fonts-common.noarch 0:2.33-6.el7dejavu-sans-fonts.noarch 0:2.33-6.el7fontpackages-filesystem.noarch 0:1.44-8.el7
fping.x86_64 0:3.16-1.el7httpd.x86_64 0:2.4.6-97.el7.centoshttpd-tools.x86_64 0:2.4.6-97.el7.centoslibX11.x86_64 0:1.6.7-4.el7_9
libX11-common.noarch 0:1.6.7-4.el7_9libXau.x86_64 0:1.0.8-2.1.el7libXpm.x86_64 0:3.5.12-1.el7libevent.x86_64 0:2.0.21-4.el7
libjpeg-turbo.x86_64 0:1.2.90-8.el7libxcb.x86_64 0:1.13-1.el7libzip.x86_64 0:0.10.1-8.el7mailcap.noarch 0:2.1.41-2.el7
net-snmp-libs.x86_64 1:5.7.2-49.el7_9.1php.x86_64 0:5.4.16-48.el7php-bcmath.x86_64 0:5.4.16-48.el7php-cli.x86_64 0:5.4.16-48.el7
php-common.x86_64 0:5.4.16-48.el7php-gd.x86_64 0:5.4.16-48.el7php-ldap.x86_64 0:5.4.16-48.el7php-mbstring.x86_64 0:5.4.16-48.el7
php-mysql.x86_64 0:5.4.16-48.el7php-pdo.x86_64 0:5.4.16-48.el7php-xml.x86_64 0:5.4.16-48.el7t1lib.x86_64 0:5.1.2-14.el7
unixODBC.x86_64 0:2.3.1-14.el7zabbix-web.noarch 0:4.2.8-1.el7

Complete!

三、安装mysql数据库
3.1安装依赖包
[root@shell ~]# yum -y install gcc gcc-c++ ncurses bison libgcrypt perl cmake ncurses-devel

3.2下载mysql5.7整合包(可以其他方式安装mysql数据库)
[root@shell ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar

3.3解压整合包,再安装依赖包
[root@shell ~]# tar xvf mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
mysql-community-common-5.7.24-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.24-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.24-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.24-1.el7.x86_64.rpm
mysql-community-embedded-5.7.24-1.el7.x86_64.rpm
mysql-community-libs-5.7.24-1.el7.x86_64.rpm
mysql-community-devel-5.7.24-1.el7.x86_64.rpm
mysql-community-server-5.7.24-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.24-1.el7.x86_64.rpm
mysql-community-client-5.7.24-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.24-1.el7.x86_64.rpm
mysql-community-test-5.7.24-1.el7.x86_64.rpm
[root@shell ~]# yum -y install mysql-community-{client,common,libs}-*

3.4安装mysql服务
[root@shell ~]# rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.24-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
net-tools is needed by mysql-community-server-5.7.24-1.el7.x86_64

报错,无法安装。这是由于yum安装了旧版本的GPG keys造成的,因为从 RPM 版本 4.1 开始,在安装或升级软件包时会检查软件包的签名。如果签名校验失败,你就会看到如下所示的错误消息:


解决方法:在安装命令后面加上 --force --nodeps,进行强制安装。
[root@shell ~]# rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm--force --nodeps
warning: mysql-community-server-5.7.24-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.24-1.e################################# [100%]
[root@shell ~]#



3.4.1启动mysql服务并设置开机启动
[root@shell ~]# systemctl start mysqld
[root@shell ~]# systemctl enable mysqld



3.4.2获取mysql生成的root密码
[root@shell ~]# grep \'temporary password\' /var/log/mysqld.log | awk \'{print $NF}\'
Z3,+y3aQx& oI



3.4.3进入数据库并修改root密码
[root@shell ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.Commands end with ; or \\g.
Your MySQL connection id is 4
Server version: 5.7.24

Copyright (c) 2000, 2018, 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>
mysql> ALTER USER \'root\'@\'localhost\' IDENTIFIED BY \'yH!2J4KiK193\';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

3.4.4创建zabbix数据库mysql5.7数据库对密码要求很严格,密码复杂度必须符合要求才行
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)

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

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)



3.4.5导入zabbix数据库

[root@shell ~]# zcat /usr/share/doc/zabbix-server-mysql-4.2.8/create.sql.gz | mysql -uzabbix -peqwOP@OF2kzR34 --database zabbix
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@shell ~]#



四、修改Zabbix-server配置


[root@shell ~]# vim /etc/zabbix/zabbix_server.conf



ListenPort=10051
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=eqwOP@OF2kzR34
#DBSocket路径根据mysql的配置文件/etc/my.cnf设置
DBSocket=/var/run/mysqld/mysql.socket
DBPort=3306

4.1修改zabbix时区
[root@shell ~]# sed -i "s/# php_value date.timezone Europe\\/Riga/php_value date.timezone Asia\\/Shanghai/" /etc/httpd/conf.d/zabbix.conf
[root@shell ~]# grep date /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai



4.2修改php.ini配置参数
[root@shell ~]# sed -i "s/post_max_size = 8M/post_max_size = 16M/" /etc/php.ini
[root@shell ~]# sed -i "s/max_execution_time = 30/max_execution_time = 300/" /etc/php.ini
[root@shell ~]# sed -i "s/max_input_time = 60/max_input_time = 300/" /etc/php.ini
[root@shell ~]# sed -i \'s/; date.timezone =/date.timezone = "Asia\\/Shanghai"/\' /etc/php.ini

?4.3修改系统时间,安装ntp服务
[root@shell ~]# yum -y install ntpdate
[root@shell ~]#ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@shell ~]# ntpdate us.pool.ntp.org
11 Oct 18:09:51 ntpdate[13560]: adjust time server 159.89.86.140 offset 0.033812 sec
[root@shell ~]#



4.4修改访问Zabbix默认URL
[root@shell ~]# sed -i \'s/DocumentRoot "\\/var\\/www\\/html"/DocumentRoot "\\/usr\\/share\\/zabbix"/\' /etc/httpd/conf/httpd.conf
[root@shell ~]# cat /etc/httpd/conf/httpd.conf |grep "DocumentRoot "
DocumentRoot "/usr/share/zabbix"
[root@shell ~]#



4.5修改中文显示乱码问题在win10上的C:\\Windows\\Fonts找一个字体拷贝到服务器
[root@shell ~]# yum -y install lrzsz
[root@shell ~]# rz
rz waiting to receive.
zmodem trl+C ?

100%11511 KB639 KB/s 00:00:180 Errors

[root@shell ~]# ll simkai.ttf
-rw-r--r-- 1 root root 11787328 Oct 152019 simkai.ttf
[root@shell ~]# mv simkai.ttf /usr/share/zabbix/assets/fonts/graphfont.ttf
mv: overwrite ‘/usr/share/zabbix/assets/fonts/graphfont.ttf’? y
[root@shell ~]#

?
4.6启动并设置开机启动 httpd、zabbix-server、zabbix-agent
[root@shell ~]# systemctl start httpd
[root@shell ~]# systemctl start zabbix-server
[root@shell ~]# systemctl start zabbix-agent
[root@shell ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@shell ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@shell ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@shell ~]#



4.6.1查看端口是否正常
[root@shell ~]# ss -ant
StateRecv-Q Send-QLocal Address:PortPeer Address:Port
LISTEN0128*:10050*:*
LISTEN0128*:10051*:*
LISTEN0128*:22*:*
LISTEN0100127.0.0.1:25*:*
TIME-WAIT00127.0.0.1:10050127.0.0.1:43982
TIME-WAIT00127.0.0.1:10050127.0.0.1:44010
TIME-WAIT00127.0.0.1:10050127.0.0.1:43994
TIME-WAIT00127.0.0.1:10050127.0.0.1:43986
TIME-WAIT00127.0.0.1:10050127.0.0.1:43980
TIME-WAIT00127.0.0.1:10051127.0.0.1:40214
TIME-WAIT00127.0.0.1:10050127.0.0.1:44014
TIME-WAIT00127.0.0.1:10050127.0.0.1:44004
TIME-WAIT00127.0.0.1:10050127.0.0.1:43976
TIME-WAIT00127.0.0.1:10050127.0.0.1:43978
ESTAB00192.168.43.201:22192.168.43.147:56193
TIME-WAIT00127.0.0.1:10050127.0.0.1:44000
TIME-WAIT00127.0.0.1:10050127.0.0.1:43974
TIME-WAIT00127.0.0.1:10050127.0.0.1:43990
TIME-WAIT00127.0.0.1:10050127.0.0.1:43984
TIME-WAIT00127.0.0.1:10050127.0.0.1:44016
TIME-WAIT00127.0.0.1:10050127.0.0.1:44008
TIME-WAIT00127.0.0.1:10050127.0.0.1:43996
TIME-WAIT00127.0.0.1:10050127.0.0.1:44012
TIME-WAIT00127.0.0.1:10050127.0.0.1:43972
TIME-WAIT00127.0.0.1:10050127.0.0.1:43992
TIME-WAIT00127.0.0.1:10050127.0.0.1:44002
ESTAB00192.168.43.201:22192.168.43.147:64774
TIME-WAIT00127.0.0.1:10050127.0.0.1:44006
ESTAB052192.168.43.201:22192.168.43.147:55904
TIME-WAIT00127.0.0.1:10050127.0.0.1:43998
TIME-WAIT00127.0.0.1:10050127.0.0.1:43988
LISTEN0128[::]:10050[::]:*
LISTEN0128[::]:10051[::]:*
LISTEN080[::]:3306[::]:*
LISTEN0128[::]:80[::]:*
LISTEN0128[::]:22[::]:*
LISTEN0100[::1]:25[::]:*
[root@shell ~]#



五、打开WEB页面设置
Centos7.9安装Zabbix4.2

文章图片

Centos7.9安装Zabbix4.2

文章图片

Centos7.9安装Zabbix4.2

文章图片

Centos7.9安装Zabbix4.2

文章图片

Centos7.9安装Zabbix4.2

文章图片

Centos7.9安装Zabbix4.2

文章图片

初始化账户密码:Admin/zabbix
【Centos7.9安装Zabbix4.2】
Centos7.9安装Zabbix4.2

文章图片

5.1设置中文界面
Centos7.9安装Zabbix4.2

文章图片

Centos7.9安装Zabbix4.2

文章图片




    推荐阅读