zabbix系列(2)部署zabbix5.0之一

上一节搭建了环境,打开虚拟机,xshell连接虚拟机,接下来咱们一起部署zabbix5.0吧。

  • 关闭防火墙
    上节已经操作完毕
  • 检查网络环境
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             192.168.122.0/24     ctstate RELATED,ESTABLISHED
ACCEPT     all  --  192.168.122.0/24     anywhere            
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc
[root@localhost ~]# 

均为accept即可
付iptables命令介绍http://cnzhx.net/blog/common-iptables-cli/#2l

  • 服务端配置
[root@localhost ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            972         606          62          10         303         216
Swap:          2047           5        2042

mem:内存
内存尽量大一些,4G为好,显然我们目前虚拟机的内存约1G比较小,需要改大一点。怎么改呢?

这里我采用的是一个图形化界面的修改方式,方便快捷:

右键虚拟机,点击设置:
在这里插入图片描述
直接在页面上修改:
在这里插入图片描述
上图可以看到,我已经把内存修改成了2G。

这里要说明一点,开机状态下,虚拟机的内存可以从小往大改,但是不支持从大往小改。若想往小了改,需要关机操作。

修改后,在命令行看结果:

[root@localhost ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1996         647        1081          10         267        1304
Swap:          2047           5        2042

  • 获取zabbix官方源
[root@localhost ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.MUCMU1: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]
[root@localhost ~]# 

这个时候我们已经有了zabbix源,下图中zabbix.repo这个仓库文件:

[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo          zabbix.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo

打开仓库文件,可以发现里面的源都是国外的网站http://repo.zabbix.com/,这样下载起来会非常慢:

[root@localhost ~]# vim  /etc/yum.repos.d/zabbix.repo 

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
"/etc/yum.repos.d/zabbix.repo" 27L, 853C  
  • 更换国外源为国内阿里源,加快下载速度
[root@localhost ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
[root@localhost ~]# vim  /etc/yum.repos.d/zabbix.repo 

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
"/etc/yum.repos.d/zabbix.repo" 27L, 897C

更换成功

  • 清空缓存
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 50834.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  48 M RSS (391 MB VSZ)
    Started: Thu Mar 17 22:14:33 2022 - 00:05 ago
    State  : Sleeping, pid: 50834
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  48 M RSS (391 MB VSZ)
    Started: Thu Mar 17 22:14:33 2022 - 00:07 ago
    State  : Sleeping, pid: 50834
Cleaning repos: base extras updates zabbix zabbix-non-supported
Cleaning up list of fastest mirrors

  • 安装zabbix server 和 agent
[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent -y

中间步骤挺多,耐心稍等一小会儿,就成功啦!截个完成的图吧!

Installed:
  zabbix-agent.x86_64 0:5.0.21-1.el7                  zabbix-server-mysql.x86_64 0:5.0.21-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.16-1.el7       unixODBC.x86_64 0:2.3.1-14.el7      

Complete!

太晚了,今天就先到这儿吧,明天继续~~


版权声明:本文为snow_iscas原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。