kvm(CentOS8)+yum在线安装Zabbix6.0

1. 环境(这个地方根据业务和硬件资源而定)

  • Windows10上安装VMWare WorkStation Pro15
  • VMWare WorkStation Pro15安装CentOS8
  • CentOS8通过KVM创建一个嵌套虚拟化的CentOS8

2. 安装虚拟化的CentOS8

qemu-img create -f qcow2 /vm/zabbixserver-disk0.qcow2 30G

virt-install \
--name=zabbixserver \
--vcpus=2 \
--ram=1024 \
--cdrom=/iso/CentOS-Stream-8-x86_64-latest-dvd1.iso \
--disk path=/vm/zabbixserver-disk0.qcow2,size=30,format=qcow2 \
--network network=default \
--graphics vnc,listen=0.0.0.0 \
--os-type=linux \
--os-variant=rhl8.0

3. 配置虚拟机(语言:英语)

kvm(CentOS8)+yum在线安装Zabbix6.0_第1张图片

4. 关闭防火墙和Selinux、修改主机名

#关闭防火墙和 selinux 并重启
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
 
#查看firewall服务状态
systemctl status firewalld

#修改主机名,方面后面操作
hostnamectl set-hostname zabbix_server

5. 部署底层环境LAMP

注意: zabbix 6.0 需要 安装10.6.5以上的Mariadb,而系统自带的为10.5,所以需要安装额外源

cat < /etc/yum.repos.d/mariadb.repo
# MariaDB 10.6 CentOS repository list - created 2022-01-16 15:10 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.cloud.tencent.com/mariadb/yum/10.6/centos8-amd64
module_hotfixes=1
gpgkey=https://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

开始安装 底层环境

dnf install mariadb mariadb-server httpd httpd-tools php php-cli php-json php-gd php-mbstring php-pdo php-xml php-mysqlnd php-pecl-zip wget -y

6. 添加zabbix源并修改为清华源

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

7. 安装zabbix

dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 -y
上面安装zabbix的时候可能会告知没有fping,这时候需要我们安装一下epel再执行安装语句就可以了!

yum install gcc -y
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

yum clean all
yum makecache

yum install epel-release

8. 配置MySQL

systemctl start mariadb && systemctl enable mariadb

设置 数据库名: zabbix
用户名:zabbix
密码: 123456

让用户zabbix,能够通过本地访问数据库zabbix,使用123456作为密码

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by '123456';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit
Bye

9. 导入初始架构和数据

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix

输入密码:123456

10. 为zabbix-server配置数据库

vim /etc/zabbix/zabbix_server.conf 
DBPassword=123456

grep DBPassword /etc/zabbix/zabbix_server.conf |grep -v ^#
DBPassword=123456

11. 为Zabbix前端配置PHP文件里的时区

#为Zabbix前端配置PHP文件里的时区
vim /etc/php-fpm.d/zabbix.conf
 
#增加内容
php_value[date.timezone] = Asia/Shanghai

12. 启动zabbix-server和zabbix-agent2进程并开机自启动

systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
systemctl enable zabbix-server zabbix-agent2 httpd php-fpm

13. 使用ip/zabbix访问前端页面进行配置

kvm(CentOS8)+yum在线安装Zabbix6.0_第2张图片

kvm(CentOS8)+yum在线安装Zabbix6.0_第3张图片

kvm(CentOS8)+yum在线安装Zabbix6.0_第4张图片kvm(CentOS8)+yum在线安装Zabbix6.0_第5张图片kvm(CentOS8)+yum在线安装Zabbix6.0_第6张图片kvm(CentOS8)+yum在线安装Zabbix6.0_第7张图片kvm(CentOS8)+yum在线安装Zabbix6.0_第8张图片kvm(CentOS8)+yum在线安装Zabbix6.0_第9张图片

至此zabbix6.0就已经在CentOS8上面安装成功了! 

你可能感兴趣的:(集群维护,集群监控,虚拟化,zabbix,监控,经验分享)