5
CentOS 部署Zabbix v5.0.6
source link: https://www.opsit.cn/6586.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
0x01 什么是Zabbix
zabbix([`zæbiks])是一个基于WEB接口的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,埠监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
0x02 如何部署?
基础环境准备
#修改计算机名为zabbix
[root@localhost]# hostnamectl set-hostname zabbix
#查看系统版本
[root@zabbix /]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
#修改网络配置 网卡编号以自己系统安装完成后显示为准,这边显示ens32
[root@zabbix ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
#BOOTPROTO=dhcp #直接在这改也可以,个人习惯问题,喜欢注释掉,另起写ip
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy #此行也注释掉
NAME=ens32
UUID=4f9c06a4-23a6-40a7-81d0-7c5010abb0ef
DEVICE=ens32
#ONBOOT=no #注释掉
IPV6_PRIVACY=no
BOOTPROTO=static #设置网卡静态IP模式
ONBOOT=yes #开机启动
IPADDR=172.16.252.100 #设置IP地址
NETMASK=255.255.255.0 #设置子网掩码
GATEWAY=172.16.252.2 #设置网关
DNS1=223.5.5.5 #设置DNS地址
#退出vi编辑模式,按esc,输入':wq!'保存退出
#重启网卡
[root@zabbix /]# systemctl restart network
#查看网卡IP配置是否成功
[root@zabbix /]# ifconfig ens32
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.252.100 netmask 255.255.255.0 broadcast 172.16.252.255
inet6 fe80::20c:29ff:fe13:39ff prefixlen 64 scopeid 0x20
ether 00:0c:29:13:39:ff txqueuelen 1000 (Ethernet)
RX packets 290 bytes 28350 (27.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 225 bytes 39888 (38.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@zabbix /]# vi /etc/selinux/config #修改SElinux配置文件,永久关闭SElinux,重启生效
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #将此行enabled修改为disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
#验证SElinux是否成功关闭
[root@zabbix]# setenforce 0
#重启后验证SElinux已成功关闭
[root@zabbix ~]# setenforce 0
setenforce: SELinux is disabled
#关闭防火墙
[root@zabbix ~]# systemctl stop firewalld
#永久关闭防火墙,禁止开机启动
[root@zabbix ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
#查看防火墙状态(此处演示,生产环境视情况而定,不建议直接关掉)
[root@zabbix ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
Dec 01 02:41:38 zabbix systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 01 02:42:01 zabbix systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 01 02:42:01 zabbix firewalld[591]: WARNING: ICMP type 'beyond-scope' is not supported by the ker...pv6.
Dec 01 02:42:01 zabbix firewalld[591]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP ty...ime.
Dec 01 02:42:01 zabbix firewalld[591]: WARNING: ICMP type 'failed-policy' is not supported by the ke...pv6.
Dec 01 02:42:01 zabbix firewalld[591]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP t...ime.
Dec 01 02:42:01 zabbix firewalld[591]: WARNING: ICMP type 'reject-route' is not supported by the ker...pv6.
Dec 01 02:42:01 zabbix firewalld[591]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP ty...ime.
Dec 01 03:07:06 zabbix systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 01 03:07:07 zabbix systemd[1]: Stopped firewalld - dynamic firewall daemon.
Zabbix 安装环境准备
#安装zabbix下载源
[root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.OHAfBE: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-5.0-1.el7 ################################# [100%]
#安装zabbix-server 与zabbix-agent
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-agent
Loaded plugins: fastestmirror, langpacks
http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
zabbix/x86_64/primary_db | 52 kB 00:00:02
zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
zabbix-non-supported 4/4
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 0:5.0.6-1.el7 will be installed
---> Package zabbix-server-mysql.x86_64 0:5.0.6-1.el7 will be installed
--> Processing Dependency: fping for package: zabbix-server-mysql-5.0.6-1.el7.x86_64
--> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: zabbix-server-mysql-5.0.6-1.el7.x86_64
--> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: zabbix-server-mysql-5.0.6-1.el7.x86_64
--> Processing Dependency: libodbc.so.2()(64bit) for package: zabbix-server-mysql-5.0.6-1.el7.x86_64
--> Running transaction check
---> Package OpenIPMI-libs.x86_64 0:2.0.27-1.el7 will be installed
--> Processing Dependency: OpenIPMI-modalias = 2.0.27-1.el7 for package: OpenIPMI-libs-2.0.27-1.el7.x86_64
---> Package fping.x86_64 0:3.10-1.el7 will be installed
---> Package unixODBC.x86_64 0:2.3.1-14.el7 will be installed
--> Running transaction check
---> Package OpenIPMI-modalias.x86_64 0:2.0.27-1.el7 will be installed
--> Processing Dependency: OpenIPMI for package: OpenIPMI-modalias-2.0.27-1.el7.x86_64
--> Running transaction check
---> Package OpenIPMI.x86_64 0:2.0.27-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
zabbix-agent x86_64 5.0.6-1.el7 zabbix 452 k
zabbix-server-mysql x86_64 5.0.6-1.el7 zabbix 2.7 M
Installing for dependencies:
OpenIPMI x86_64 2.0.27-1.el7 base 243 k
OpenIPMI-libs x86_64 2.0.27-1.el7 base 523 k
OpenIPMI-modalias x86_64 2.0.27-1.el7 base 16 k
fping x86_64 3.10-1.el7 zabbix-non-supported 40 k
unixODBC x86_64 2.3.1-14.el7 base 413 k
Transaction Summary
===========================================================================================================
Install 2 Packages (+5 Dependent packages)
Total download size: 4.4 M
Installed size: 12 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/OpenIPMI-modalias-2.0.27-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for OpenIPMI-modalias-2.0.27-1.el7.x86_64.rpm is not installed
(1/7): OpenIPMI-modalias-2.0.27-1.el7.x86_64.rpm | 16 kB 00:00:00
(2/7): OpenIPMI-2.0.27-1.el7.x86_64.rpm | 243 kB 00:00:00
(3/7): OpenIPMI-libs-2.0.27-1.el7.x86_64.rpm | 523 kB 00:00:00
(4/7): unixODBC-2.3.1-14.el7.x86_64.rpm | 413 kB 00:00:00
warning: /var/cache/yum/x86_64/7/zabbix-non-supported/packages/fping-3.10-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Public key for fping-3.10-1.el7.x86_64.rpm is not installed
(5/7): fping-3.10-1.el7.x86_64.rpm | 40 kB 00:00:02
warning: /var/cache/yum/x86_64/7/zabbix/packages/zabbix-server-mysql-5.0.6-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Public key for zabbix-server-mysql-5.0.6-1.el7.x86_64.rpm is not installed
(6/7): zabbix-server-mysql-5.0.6-1.el7.x86_64.rpm | 2.7 MB 00:00:20
(7/7): zabbix-agent-5.0.6-1.el7.x86_64.rpm | 452 kB 00:00:28
-----------------------------------------------------------------------------------------------------------
Total 155 kB/s | 4.4 MB 00:00:28
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Importing GPG key 0x79EA5ED4:
Userid : "Zabbix SIA <[email protected]>"
Fingerprint: fbab d5fb 2025 5eca b22e e194 d13d 58e4 79ea 5ed4
Package : zabbix-release-5.0-1.el7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Importing GPG key 0xA14FE591:
Userid : "Zabbix LLC <[email protected]>"
Fingerprint: a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
Package : zabbix-release-5.0-1.el7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : OpenIPMI-libs-2.0.27-1.el7.x86_64 1/7
Installing : OpenIPMI-2.0.27-1.el7.x86_64 2/7
Installing : OpenIPMI-modalias-2.0.27-1.el7.x86_64 3/7
Installing : unixODBC-2.3.1-14.el7.x86_64 4/7
Installing : fping-3.10-1.el7.x86_64 5/7
Installing : zabbix-server-mysql-5.0.6-1.el7.x86_64 6/7
Installing : zabbix-agent-5.0.6-1.el7.x86_64 7/7
WARNING: ipmi_devintf module isn't available.
WARNING: ipmi_msghandler module isn't available.
Verifying : fping-3.10-1.el7.x86_64 1/7
Verifying : zabbix-server-mysql-5.0.6-1.el7.x86_64 2/7
Verifying : OpenIPMI-2.0.27-1.el7.x86_64 3/7
Verifying : zabbix-agent-5.0.6-1.el7.x86_64 4/7
Verifying : unixODBC-2.3.1-14.el7.x86_64 5/7
Verifying : OpenIPMI-libs-2.0.27-1.el7.x86_64 6/7
Verifying : OpenIPMI-modalias-2.0.27-1.el7.x86_64 7/7
Installed:
zabbix-agent.x86_64 0:5.0.6-1.el7 zabbix-server-mysql.x86_64 0:5.0.6-1.el7
Dependency Installed:
OpenIPMI.x86_64 0:2.0.27-1.el7 OpenIPMI-libs.x86_64 0:2.0.27-1.el7
OpenIPMI-modalias.x86_64 0:2.0.27-1.el7 fping.x86_64 0:3.10-1.el7
unixODBC.x86_64 0:2.3.1-14.el7
Complete!
#安装zabbix前端启用收藏安装源
[root@zabbix ~]# yum install centos-release-scl -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package centos-release-scl.noarch 0:2-3.el7.centos will be installed
--> Processing Dependency: centos-release-scl-rh for package: centos-release-scl-2-3.el7.centos.noarch
--> Running transaction check
---> Package centos-release-scl-rh.noarch 0:2-3.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
centos-release-scl noarch 2-3.el7.centos extras 12 k
Installing for dependencies:
centos-release-scl-rh noarch 2-3.el7.centos extras 12 k
Transaction Summary
===========================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 24 k
Installed size: 39 k
Downloading packages:
(1/2): centos-release-scl-2-3.el7.centos.noarch.rpm | 12 kB 00:00:00
(2/2): centos-release-scl-rh-2-3.el7.centos.noarch.rpm | 12 kB 00:00:00
-----------------------------------------------------------------------------------------------------------
Total 77 kB/s | 24 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : centos-release-scl-rh-2-3.el7.centos.noarch 1/2
Installing : centos-release-scl-2-3.el7.centos.noarch 2/2
Verifying : centos-release-scl-2-3.el7.centos.noarch 1/2
Verifying : centos-release-scl-rh-2-3.el7.centos.noarch 2/2
Installed:
centos-release-scl.noarch 0:2-3.el7.centos
Dependency Installed:
centos-release-scl-rh.noarch 0:2-3.el7.centos
Complete!
#编辑zabbix前端安装源
[root@zabbix ~]# vim /etc/yum.repos.d/zabbix.repo
...
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1 #此处修改为1 启用
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
...
#安装zabbix环境依赖包
[root@zabbix ~]# yum -y install zabbix-web-mysql-scl zabbix-nginx-conf-scl
Loaded plugins: fastestmirror, langpacks
centos-sclo-rh | 3.0 kB 00:00:00
centos-sclo-sclo | 3.0 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-frontend | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
(1/3): centos-sclo-sclo/x86_64/primary_db | 300 kB 00:00:00
(2/3): centos-sclo-rh/x86_64/primary_db | 2.9 MB 00:00:01
(3/3): zabbix-frontend/x86_64/primary_db | 13 kB 00:00:03
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* centos-sclo-rh: mirrors.163.com
* centos-sclo-sclo: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package zabbix-nginx-conf-scl.noarch 0:5.0.6-1.el7 will be installed
--> Processing Dependency: zabbix-web-deps-scl = 5.0.6-1.el7 for package: zabbix-nginx-conf-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-nginx116-nginx for package: zabbix-nginx-conf-scl-5.0.6-1.el7.noarch
---> Package zabbix-web-mysql-scl.noarch 0:5.0.6-1.el7 will be installed
--> Processing Dependency: zabbix-web = 5.0.6-1.el7 for package: zabbix-web-mysql-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72-php-mysqlnd for package: zabbix-web-mysql-scl-5.0.6-1.el7.noarch
--> Running transaction check
---> Package rh-nginx116-nginx.x86_64 1:1.16.1-4.el7.1 will be installed
--> Processing Dependency: rh-nginx116-runtime for package: 1:rh-nginx116-nginx-1.16.1-4.el7.1.x86_64
---> Package rh-php72-php-mysqlnd.x86_64 0:7.2.24-1.el7 will be installed
--> Processing Dependency: rh-php72-php-pdo(x86-64) = 7.2.24-1.el7 for package: rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64
---> Package zabbix-web.noarch 0:5.0.6-1.el7 will be installed
---> Package zabbix-web-deps-scl.noarch 0:5.0.6-1.el7 will be installed
--> Processing Dependency: rh-php72-php-mbstring for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72-php-xml for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72-php-bcmath for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72-php-ldap for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72-php-fpm for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72 for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Processing Dependency: rh-php72-php-gd for package: zabbix-web-deps-scl-5.0.6-1.el7.noarch
--> Running transaction check
---> Package rh-nginx116-runtime.x86_64 0:1.16-1.el7 will be installed
---> Package rh-php72.x86_64 0:1-2.el7 will be installed
--> Processing Dependency: rh-php72-runtime(x86-64) = 1-2.el7 for package: rh-php72-1-2.el7.x86_64
--> Processing Dependency: rh-php72-runtime for package: rh-php72-1-2.el7.x86_64
--> Processing Dependency: rh-php72-php-common(x86-64) for package: rh-php72-1-2.el7.x86_64
--> Processing Dependency: rh-php72-php-cli(x86-64) for package: rh-php72-1-2.el7.x86_64
--> Processing Dependency: rh-php72-php-pear for package: rh-php72-1-2.el7.x86_64
---> Package rh-php72-php-bcmath.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-fpm.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-gd.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-ldap.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-mbstring.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-pdo.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-xml.x86_64 0:7.2.24-1.el7 will be installed
--> Running transaction check
---> Package rh-php72-php-cli.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-common.x86_64 0:7.2.24-1.el7 will be installed
--> Processing Dependency: rh-php72-php-json(x86-64) = 7.2.24-1.el7 for package: rh-php72-php-common-7.2.24-1.el7.x86_64
--> Processing Dependency: rh-php72-php-zip(x86-64) = 7.2.24-1.el7 for package: rh-php72-php-common-7.2.24-1.el7.x86_64
---> Package rh-php72-php-pear.noarch 1:1.10.5-1.el7 will be installed
--> Processing Dependency: rh-php72-php-posix for package: 1:rh-php72-php-pear-1.10.5-1.el7.noarch
---> Package rh-php72-runtime.x86_64 0:1-2.el7 will be installed
--> Running transaction check
---> Package rh-php72-php-json.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-process.x86_64 0:7.2.24-1.el7 will be installed
---> Package rh-php72-php-zip.x86_64 0:7.2.24-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
zabbix-nginx-conf-scl noarch 5.0.6-1.el7 zabbix-frontend 14 k
zabbix-web-mysql-scl noarch 5.0.6-1.el7 zabbix-frontend 13 k
Installing for dependencies:
rh-nginx116-nginx x86_64 1:1.16.1-4.el7.1 centos-sclo-rh 548 k
rh-nginx116-runtime x86_64 1.16-1.el7 centos-sclo-rh 26 k
rh-php72 x86_64 1-2.el7 centos-sclo-rh 4.3 k
rh-php72-php-bcmath x86_64 7.2.24-1.el7 centos-sclo-rh 60 k
rh-php72-php-cli x86_64 7.2.24-1.el7 centos-sclo-rh 2.9 M
rh-php72-php-common x86_64 7.2.24-1.el7 centos-sclo-rh 680 k
rh-php72-php-fpm x86_64 7.2.24-1.el7 centos-sclo-rh 1.5 M
rh-php72-php-gd x86_64 7.2.24-1.el7 centos-sclo-rh 151 k
rh-php72-php-json x86_64 7.2.24-1.el7 centos-sclo-rh 54 k
rh-php72-php-ldap x86_64 7.2.24-1.el7 centos-sclo-rh 59 k
rh-php72-php-mbstring x86_64 7.2.24-1.el7 centos-sclo-rh 553 k
rh-php72-php-mysqlnd x86_64 7.2.24-1.el7 centos-sclo-rh 166 k
rh-php72-php-pdo x86_64 7.2.24-1.el7 centos-sclo-rh 101 k
rh-php72-php-pear noarch 1:1.10.5-1.el7 centos-sclo-rh 357 k
rh-php72-php-process x86_64 7.2.24-1.el7 centos-sclo-rh 62 k
rh-php72-php-xml x86_64 7.2.24-1.el7 centos-sclo-rh 160 k
rh-php72-php-zip x86_64 7.2.24-1.el7 centos-sclo-rh 90 k
rh-php72-runtime x86_64 1-2.el7 centos-sclo-rh 1.1 M
zabbix-web noarch 5.0.6-1.el7 zabbix-frontend 3.2 M
zabbix-web-deps-scl noarch 5.0.6-1.el7 zabbix-frontend 14 k
Transaction Summary
===========================================================================================================
Install 2 Packages (+20 Dependent packages)
Total download size: 12 M
Installed size: 46 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/centos-sclo-rh/packages/rh-nginx116-runtime-1.16-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f2ee9d55: NOKEY
Public key for rh-nginx116-runtime-1.16-1.el7.x86_64.rpm is not installed
(1/22): rh-nginx116-runtime-1.16-1.el7.x86_64.rpm | 26 kB 00:00:00
(2/22): rh-nginx116-nginx-1.16.1-4.el7.1.x86_64.rpm | 548 kB 00:00:00
(3/22): rh-php72-1-2.el7.x86_64.rpm | 4.3 kB 00:00:00
(4/22): rh-php72-php-bcmath-7.2.24-1.el7.x86_64.rpm | 60 kB 00:00:00
(5/22): rh-php72-php-gd-7.2.24-1.el7.x86_64.rpm | 151 kB 00:00:00
(6/22): rh-php72-php-json-7.2.24-1.el7.x86_64.rpm | 54 kB 00:00:00
(7/22): rh-php72-php-common-7.2.24-1.el7.x86_64.rpm | 680 kB 00:00:00
(8/22): rh-php72-php-fpm-7.2.24-1.el7.x86_64.rpm | 1.5 MB 00:00:00
(9/22): rh-php72-php-ldap-7.2.24-1.el7.x86_64.rpm | 59 kB 00:00:00
(10/22): rh-php72-php-pdo-7.2.24-1.el7.x86_64.rpm | 101 kB 00:00:00
(11/22): rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64.rpm | 166 kB 00:00:00
(12/22): rh-php72-php-process-7.2.24-1.el7.x86_64.rpm | 62 kB 00:00:00
(13/22): rh-php72-php-mbstring-7.2.24-1.el7.x86_64.rpm | 553 kB 00:00:00
(14/22): rh-php72-php-xml-7.2.24-1.el7.x86_64.rpm | 160 kB 00:00:00
(15/22): rh-php72-php-pear-1.10.5-1.el7.noarch.rpm | 357 kB 00:00:00
(16/22): rh-php72-php-zip-7.2.24-1.el7.x86_64.rpm | 90 kB 00:00:00
(17/22): zabbix-nginx-conf-scl-5.0.6-1.el7.noarch.rpm | 14 kB 00:00:00
(18/22): rh-php72-runtime-1-2.el7.x86_64.rpm | 1.1 MB 00:00:00
(19/22): zabbix-web-deps-scl-5.0.6-1.el7.noarch.rpm | 14 kB 00:00:00
(20/22): zabbix-web-mysql-scl-5.0.6-1.el7.noarch.rpm | 13 kB 00:00:00
(21/22): rh-php72-php-cli-7.2.24-1.el7.x86_64.rpm | 2.9 MB 00:00:02
(22/22): zabbix-web-5.0.6-1.el7.noarch.rpm | 3.2 MB 00:03:17
-----------------------------------------------------------------------------------------------------------
Total 60 kB/s | 12 MB 00:03:19
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Importing GPG key 0xF2EE9D55:
Userid : "CentOS SoftwareCollections SIG (https://wiki.centos.org/SpecialInterestGroup/SCLo) <[email protected]>"
Fingerprint: c4db d535 b1fb ba14 f8ba 64a8 4eb8 4e71 f2ee 9d55
Package : centos-release-scl-rh-2-3.el7.centos.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : rh-php72-runtime-1-2.el7.x86_64 1/22
Installing : rh-php72-php-zip-7.2.24-1.el7.x86_64 2/22
Installing : rh-php72-php-json-7.2.24-1.el7.x86_64 3/22
Installing : rh-php72-php-common-7.2.24-1.el7.x86_64 4/22
Installing : rh-php72-php-xml-7.2.24-1.el7.x86_64 5/22
Installing : rh-php72-php-cli-7.2.24-1.el7.x86_64 6/22
Installing : rh-php72-php-fpm-7.2.24-1.el7.x86_64 7/22
Installing : rh-php72-php-bcmath-7.2.24-1.el7.x86_64 8/22
Installing : rh-php72-php-gd-7.2.24-1.el7.x86_64 9/22
Installing : rh-php72-php-process-7.2.24-1.el7.x86_64 10/22
Installing : 1:rh-php72-php-pear-1.10.5-1.el7.noarch 11/22
Installing : rh-php72-1-2.el7.x86_64 12/22
Installing : rh-php72-php-pdo-7.2.24-1.el7.x86_64 13/22
Installing : rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64 14/22
Installing : rh-php72-php-ldap-7.2.24-1.el7.x86_64 15/22
Installing : rh-php72-php-mbstring-7.2.24-1.el7.x86_64 16/22
Installing : zabbix-web-5.0.6-1.el7.noarch 17/22
Installing : zabbix-web-mysql-scl-5.0.6-1.el7.noarch 18/22
Installing : zabbix-web-deps-scl-5.0.6-1.el7.noarch 19/22
Installing : rh-nginx116-runtime-1.16-1.el7.x86_64 20/22
Installing : 1:rh-nginx116-nginx-1.16.1-4.el7.1.x86_64 21/22
Installing : zabbix-nginx-conf-scl-5.0.6-1.el7.noarch 22/22
Verifying : rh-php72-php-xml-7.2.24-1.el7.x86_64 1/22
Verifying : zabbix-web-mysql-scl-5.0.6-1.el7.noarch 2/22
Verifying : rh-php72-php-fpm-7.2.24-1.el7.x86_64 3/22
Verifying : 1:rh-nginx116-nginx-1.16.1-4.el7.1.x86_64 4/22
Verifying : zabbix-nginx-conf-scl-5.0.6-1.el7.noarch 5/22
Verifying : rh-php72-runtime-1-2.el7.x86_64 6/22
Verifying : rh-php72-php-common-7.2.24-1.el7.x86_64 7/22
Verifying : rh-php72-php-zip-7.2.24-1.el7.x86_64 8/22
Verifying : rh-php72-php-bcmath-7.2.24-1.el7.x86_64 9/22
Verifying : rh-php72-php-gd-7.2.24-1.el7.x86_64 10/22
Verifying : rh-php72-php-json-7.2.24-1.el7.x86_64 11/22
Verifying : rh-php72-php-process-7.2.24-1.el7.x86_64 12/22
Verifying : rh-php72-php-pdo-7.2.24-1.el7.x86_64 13/22
Verifying : rh-php72-php-ldap-7.2.24-1.el7.x86_64 14/22
Verifying : zabbix-web-deps-scl-5.0.6-1.el7.noarch 15/22
Verifying : rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64 16/22
Verifying : rh-php72-php-mbstring-7.2.24-1.el7.x86_64 17/22
Verifying : 1:rh-php72-php-pear-1.10.5-1.el7.noarch 18/22
Verifying : rh-php72-1-2.el7.x86_64 19/22
Verifying : rh-nginx116-runtime-1.16-1.el7.x86_64 20/22
Verifying : rh-php72-php-cli-7.2.24-1.el7.x86_64 21/22
Verifying : zabbix-web-5.0.6-1.el7.noarch 22/22
Installed:
zabbix-nginx-conf-scl.noarch 0:5.0.6-1.el7 zabbix-web-mysql-scl.noarch 0:5.0.6-1.el7
Dependency Installed:
rh-nginx116-nginx.x86_64 1:1.16.1-4.el7.1 rh-nginx116-runtime.x86_64 0:1.16-1.el7
rh-php72.x86_64 0:1-2.el7 rh-php72-php-bcmath.x86_64 0:7.2.24-1.el7
rh-php72-php-cli.x86_64 0:7.2.24-1.el7 rh-php72-php-common.x86_64 0:7.2.24-1.el7
rh-php72-php-fpm.x86_64 0:7.2.24-1.el7 rh-php72-php-gd.x86_64 0:7.2.24-1.el7
rh-php72-php-json.x86_64 0:7.2.24-1.el7 rh-php72-php-ldap.x86_64 0:7.2.24-1.el7
rh-php72-php-mbstring.x86_64 0:7.2.24-1.el7 rh-php72-php-mysqlnd.x86_64 0:7.2.24-1.el7
rh-php72-php-pdo.x86_64 0:7.2.24-1.el7 rh-php72-php-pear.noarch 1:1.10.5-1.el7
rh-php72-php-process.x86_64 0:7.2.24-1.el7 rh-php72-php-xml.x86_64 0:7.2.24-1.el7
rh-php72-php-zip.x86_64 0:7.2.24-1.el7 rh-php72-runtime.x86_64 0:1-2.el7
zabbix-web.noarch 0:5.0.6-1.el7 zabbix-web-deps-scl.noarch 0:5.0.6-1.el7
Complete!
数据库准备
#MySQL安装准备
[root@zabbix ~]# vi /etc/yum.repos.d/mysql-community.repo #编辑MySQL安装源
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1 #此处改为1,其他版本则改为0
gpgcheck=0 #此处改为0,不检查gpg-key
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
#安装MySQL 5.7
[root@zabbix ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror, langpacks
mysql57-community | 2.6 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* centos-sclo-rh: mirrors.cn99.com
* centos-sclo-sclo: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.32-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.32-1.el7 for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.32-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.32-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.32-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: zabbix-server-mysql-5.0.6-1.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: zabbix-server-mysql-5.0.6-1.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.32-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.32-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-6.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
mysql-community-libs x86_64 5.7.32-1.el7 mysql57-community 2.3 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-libs-compat x86_64 5.7.32-1.el7 mysql57-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 5.7.32-1.el7 mysql57-community 173 M
Installing for dependencies:
mysql-community-client x86_64 5.7.32-1.el7 mysql57-community 25 M
mysql-community-common x86_64 5.7.32-1.el7 mysql57-community 308 k
Updating for dependencies:
postfix x86_64 2:2.10.1-9.el7 base 2.4 M
Transaction Summary
===========================================================================================================
Install 3 Packages (+2 Dependent packages)
Upgrade ( 1 Dependent package)
Total size: 205 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-5.7.32-1.el7.x86_64 1/8
Installing : mysql-community-libs-5.7.32-1.el7.x86_64 2/8
Installing : mysql-community-client-5.7.32-1.el7.x86_64 3/8
Installing : mysql-community-libs-compat-5.7.32-1.el7.x86_64 4/8
Updating : 2:postfix-2.10.1-9.el7.x86_64 5/8
Installing : mysql-community-server-5.7.32-1.el7.x86_64 6/8
Cleanup : 2:postfix-2.10.1-6.el7.x86_64 7/8
Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 8/8
Verifying : 2:postfix-2.10.1-9.el7.x86_64 1/8
Verifying : mysql-community-client-5.7.32-1.el7.x86_64 2/8
Verifying : mysql-community-libs-compat-5.7.32-1.el7.x86_64 3/8
Verifying : mysql-community-libs-5.7.32-1.el7.x86_64 4/8
Verifying : mysql-community-server-5.7.32-1.el7.x86_64 5/8
Verifying : mysql-community-common-5.7.32-1.el7.x86_64 6/8
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 7/8
Verifying : 2:postfix-2.10.1-6.el7.x86_64 8/8
Installed:
mysql-community-libs.x86_64 0:5.7.32-1.el7 mysql-community-libs-compat.x86_64 0:5.7.32-1.el7
mysql-community-server.x86_64 0:5.7.32-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.32-1.el7 mysql-community-common.x86_64 0:5.7.32-1.el7
Dependency Updated:
postfix.x86_64 2:2.10.1-9.el7
Replaced:
mariadb-libs.x86_64 1:5.5.56-2.el7
Complete!
#启动MySQL数据库
[root@zabbix ~]#systemctl start mysqld
#设为开机启动
[root@zabbix ~]#systemctl enable mysqld
#设置MySQL数据库root密码
[root@zabbix ~]# grep 'temporary password' /var/log/mysqld.log #MySQL安装完成后,默认在/var/log/mysqld.log中会有默认密码
2020-12-07T00:31:45.104451Z 1 [Note] A temporary password is generated for root@localhost: wv,fe76Re:pg
#将密码修改为'passwd1!'提示不满足当前安全策略
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwd1!';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
[root@zabbix ~]# vim /etc/my.cnf #修改默认密码策略
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
validate_password_policy=0 #添加此行
# #Mysql默认的密码策略
validate_password_policy:密码策略,默认为MEDIUM策略
validate_password_dictionary_file:密码策略文件,策略为STRONG才需要
validate_password_length:密码最少长度
validate_password_mixed_case_count:大小写字符长度,至少1个
validate_password_number_count :数字至少1个
validate_password_special_char_count:特殊字符至少1个
#修改密码策略后需重启Mysql服务后,方可修改密码
[root@zabbix ~]# systemctl restart mysqld
[root@zabbix ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.32
Copyright (c) 2000, 2020, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwd1!';
Query OK, 0 rows affected (0.00 sec)
#创建zabbix数据库,设置字符集为uft-8
mysql> create database zabbix character set utf8 collate utf8_bin;
#创建zabbix用户,密码为'passwd1!'
mysql> create user zabbix@localhost identified by 'passsd1!';
#允许zabbix访问zabbix*数据库
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
#导入初始架构和数据,系统将提示您输入新创建zabbix用户的密码
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
为Zabbix server配置数据库
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
# Database user.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbix
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=passwd1! #修改此行,将zabbix用户数据库密码填上
### Option: DBSocket
# Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=
nginx环境配置
[root@zabbix ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
server {
listen 80; #去掉注释,监听80端口
server_name example.com; #去掉此行注释
root /usr/share/zabbix;
index index.php;
location = /favicon.ico {
log_not_found off;
}
location / {
try_files $uri $uri/ =404;
}
location /assets {
access_log off;
expires 10d;
}
location ~ /.ht {
deny all;
}
location ~ /(api/|conf[^.]|include|locale) {
deny all;
return 404;
}
#修改nginx配置
[root@zabbix zabbix]# vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf
... ...
server {
listen 8080 default_server; #因zabbix server占用80端口,此处改为8080
listen [::]:80 default_server;
server_name _;
root /opt/rh/rh-nginx116/root/usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/opt/rh/rh-nginx116/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
......
#为Zabbix前端配置PHP
[root@zabbix ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[zabbix]
user = apache
group = apache
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache,nginx #修改此行,添加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
php_value[session.save_handler] = files
php_value[session.save_path] = /var/opt/rh/rh-php72/lib/php/session/
php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai #修改此处时区,改为亚洲/上海
#启动Zabbix server和agent进程
[root@zabbix ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
#设为开机启动
[root@zabbix ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-nginx116-nginx.service to /usr/lib/systemd/system/rh-nginx116-nginx.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.
前端准备安装
打开浏览器进入http://你的zabbix服务器ip
下一步,环境检查,全部ok后,下一步
确认数据库配置,输入之前新建的zabbix数据库用户密码,下一步继续安装
确认Zabbix服务端信息,命名,下一步安装
确认配置,下一步继续安装
使用默认账号Admin密码zabbix,登录提示
修改时区为UTC
[root@zabbix zabbix]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
...
php_value[date.timezone] = UTC
...
#修改配置后重启服务
[root@zabbix zabbix]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK