Zabbix软件包下载地址:
https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/
fping.rpm 下载地址:https://repo.zabbix.com/non-supported/rhel/8/x86_64/
系统环境(建议最小化安装):
[root@bogon fonts]# cat /etc/redhat-release
CentOS Linux release 8.4.2105
主机IP信息:
inet 192.168.254.84/24 brd 192.168.254.255 scope global noprefixroute ens33
设置主机名:
hostnamectl set-hostname Zabbix_server5
#设置完成后,reboot一次主机。
临时关闭防火墙和selinux:
[root@Zabbix_server5 ~]# systemctl stop firewalld
[root@Zabbix_server5 ~]# getenforce
Enforcing
[root@Zabbix_server5 ~]# setenforce 0
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]# getenforce
Permissive
[root@Zabbix_server5 ~]#
本地yum源搭建:
挂载光盘:
[root@Zabbix_server5 ~]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@Zabbix_server5 ~]# mount | grep mnt
/dev/sr0 on /mnt type iso9660 (ro,relatime,nojoliet,check=s,map=n,blocksize=2048)
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]# cd /etc/yum.repos.d/
[root@Zabbix_server5 yum.repos.d]# ls
CentOS-Linux-AppStream.repo CentOS-Linux-Debuginfo.repo CentOS-Linux-FastTrack.repo CentOS-Linux-Plus.repo
CentOS-Linux-BaseOS.repo CentOS-Linux-Devel.repo CentOS-Linux-HighAvailability.repo CentOS-Linux-PowerTools.repo
CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Extras.repo CentOS-Linux-Media.repo CentOS-Linux-Sources.repo
[root@Zabbix_server5 yum.repos.d]# mkdir bak
[root@Zabbix_server5 yum.repos.d]# mv * bak
mv: cannot move 'bak' to a subdirectory of itself, 'bak/bak'
[root@Zabbix_server5 yum.repos.d]# ls
bak
[root@Zabbix_server5 yum.repos.d]# vi local.repo
在文件local.repo中粘贴以下内容:
[local-baseos]
name=CentOS Linux BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0
enabled=1
[local-appstream]
name=CentOS Linux AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0
enabled=1
[root@Zabbix_server5 yum.repos.d]# ls
bak local.repo
[root@Zabbix_server5 yum.repos.d]#
[root@Zabbix_server5 yum.repos.d]# yum clean all && yum makecache
[root@Zabbix_server5 yum.repos.d]# yum list all
测试yum源:
[root@Zabbix_server5 ~]# yum install bash-completion.noarch
安装bash-completion.noarch包之后,tab键可以多级补齐;
搭建lamp环境:
[root@Zabbix_server5 ~]# yum install httpd mariadb-server php
查看安装的包:
[root@Zabbix_server5 ~]# rpm -qa | grep -E 'httpd|mariadb-server|php'
centos-logos-httpd-85.5-1.el8.noarch
php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64
php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
mariadb-server-10.3.27-3.module_el8.3.0+599+c587b2e7.x86_64
php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch
php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
mariadb-server-utils-10.3.27-3.module_el8.3.0+599+c587b2e7.x86_64
httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64
[root@Zabbix_server5 ~]#
启动服务并配置开机自启
systemctl start httpd; systemctl start mariadb
systemctl enable httpd mariadb
将下载的rpm包上传到/tmp目录:
[root@Zabbix_server5 tmp]# ls *.rpm
zabbix-agent2-5.0.15-1.el8.x86_64.rpm zabbix-js-5.0.15-1.el8.x86_64.rpm zabbix-sender-5.0.15-1.el8.x86_64.rpm
zabbix-agent-5.0.15-1.el8.x86_64.rpm zabbix-nginx-conf-5.0.15-1.el8.noarch.rpm zabbix-server-mysql-5.0.15-1.el8.x86_64.rpm
zabbix-apache-conf-5.0.15-1.el8.noarch.rpm zabbix-proxy-mysql-5.0.15-1.el8.x86_64.rpm zabbix-web-5.0.15-1.el8.noarch.rpm
zabbix-get-5.0.15-1.el8.x86_64.rpm zabbix-proxy-pgsql-5.0.15-1.el8.x86_64.rpm zabbix-web-deps-5.0.15-1.el8.x86_64.rpm
zabbix-java-gateway-5.0.15-1.el8.x86_64.rpm zabbix-proxy-sqlite3-5.0.15-1.el8.x86_64.rpm fping-3.16-1.el8.x86_64.rpm zabbix-web-mysql-5.0.15-1.el8.noarch.rpm
[root@Zabbix_server5 tmp]# 执行安装命令
[root@Zabbix_server5 tmp]# yum localinstall zabbix-server-mysql-5.0.15-1.el8.x86_64.rpm zabbix-web-mysql-5.0.15-1.el8.noarch.rpm zabbix-apache-conf-5.0.15-1.el8.noarch.rpm zabbix-agent-5.0.15-1.el8.x86_64.rpm zabbix-web-5.0.15-1.el8.noarch.rpm zabbix-web-deps-5.0.15-1.el8.x86_64.rpm fping-3.16-1.el8.x86_64.rpm
Installed:
OpenIPMI-libs-2.0.29-1.el8.x86_64 dejavu-fonts-common-2.35-7.el8.noarch dejavu-sans-fonts-2.35-7.el8.noarch
fontconfig-2.13.1-3.el8.x86_64 fontpackages-filesystem-1.44-22.el8.noarch fping-3.16-1.el8.x86_64
gd-2.2.5-7.el8.x86_64 jbigkit-libs-2.1-14.el8.x86_64 libX11-1.6.8-4.el8.x86_64
libX11-common-1.6.8-4.el8.noarch libXau-1.0.9-3.el8.x86_64 libXpm-3.5.12-8.el8.x86_64
libjpeg-turbo-1.5.3-10.el8.x86_64 libtiff-4.0.9-18.el8.x86_64 libwebp-1.0.0-1.el8.x86_64
libxcb-1.13.1-1.el8.x86_64 net-snmp-libs-1:5.8-20.el8.x86_64 php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 unixODBC-2.3.7-1.el8.x86_64 zabbix-agent-5.0.15-1.el8.x86_64
zabbix-apache-conf-5.0.15-1.el8.noarch zabbix-server-mysql-5.0.15-1.el8.x86_64 zabbix-web-5.0.15-1.el8.noarch
zabbix-web-deps-5.0.15-1.el8.x86_64 zabbix-web-mysql-5.0.15-1.el8.noarch
Complete!
[root@Zabbix_server5 tmp]#
在数据库主机上运行以下代码。
#数据库默认情况下root账户的密码为空。
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
#将下行命令中的“1wdc!WDC”修改为你设定的密码;
mysql> create user zabbix@localhost identified by '1wdc!WDC';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=1wdc!WDC
为Zabbix前端配置PHP
编辑配置文件 /etc/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.
; php_value[date.timezone] = Europe/Riga
php_value[date.timezone] = Asia/Shanghai
启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm
浏览器上进行初始化操作
浏览器访问http://192.168.254.84/zabbix/,开始初始化操作。
重点关注时区是否已正确修改。
Congratulations! You have successfully installed Zabbix frontend.
到这里安装完成!
再次访问http://192.168.254.84/zabbix/;打开登陆界面
默认账户密码:
Admin zabbix
selinux放行:
暂未测试
防火墙放行web端口:
firewall-cmd --add-port=80/tcp
firewall-cmd --add-port=80/tcp --permanent
问题一、web界面汉化:
#1、查看是否存在zh_CN语言包:
locale -a | grep "zh_CN"
#2、yum检查相关语言包
yum search langpacks
#3、安装语言包:
yum install langpacks-zh_CN.noarch
本代码块为**“web界面汉化”**完整执行过程
[root@Zabbix_server5 ~]# 本代码块为完整执行过程
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]# locale -a | grep "zh_CN"
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]# yum search langpacks | grep zh_CN
Last metadata expiration check: 2:04:44 ago on Mon 27 Sep 2021 11:40:27 PM CST.
langpacks-zh_CN.noarch : Simplified Chinese langpacks meta-package
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]#
[root@Zabbix_server5 ~]# yum install langpacks-zh_CN.noarch
Last metadata expiration check: 2:04:55 ago on Mon 27 Sep 2021 11:40:27 PM CST.
Dependencies resolved.
===================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================
Installing:
langpacks-zh_CN noarch 1.0-12.el8 local-appstream 9.6 k
Installing weak dependencies:
glibc-langpack-zh x86_64 2.28-151.el8 local-baseos 2.2 M
Transaction Summary
===================================================================================================================================================================================
Install 2 Packages
Total size: 2.2 M
Installed size: 15 M
Is this ok [y/N]: Y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : glibc-langpack-zh-2.28-151.el8.x86_64 1/2
Installing : langpacks-zh_CN-1.0-12.el8.noarch 2/2
Running scriptlet: langpacks-zh_CN-1.0-12.el8.noarch 2/2
Verifying : glibc-langpack-zh-2.28-151.el8.x86_64 1/2
Verifying : langpacks-zh_CN-1.0-12.el8.noarch 2/2
Installed:
glibc-langpack-zh-2.28-151.el8.x86_64 langpacks-zh_CN-1.0-12.el8.noarch
Complete!
[root@Zabbix_server5 ~]# locale -a | grep "zh_CN"
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
[root@Zabbix_server5 ~]#
#4、刷新web页面选中zh_CN
修改Admin账户的密码也是这里
问题二、汉化后乱码
从Windows系统的C:\Windows\Fonts中找到微软雅黑字体
上传到/usr/share/zabbix/assets/fonts下面后,将雅黑字体MSYH.TTF改名为graphfont.ttf
# mv graphfont.ttf graphfont.ttf.bak
# mv MSYH.TTF graphfont.ttf