天天看點

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

Zabbix 5.0 及 web 界面 centos7 yum 安裝

  • 前言
  • 一、配置 yum 源
    • 1. 更換 yum 阿裡源
    • 2. 配置 epel 倉庫
      • 1)安裝 epel-release
      • 2)添加wlnmp一鍵包源
      • 3)強制更換清華鏡像(可選)
    • 3. 配置 remi 倉庫 (清華鏡像)
      • 1)下載下傳 wget
      • 2)下載下傳并安裝 remi 倉庫
      • 3) 更改 remi 配置
      • 4)更新 yum
  • 二、php 7.2 安裝
    • 1.配置 remi
    • 2.安裝 php 7.2
  • 三、Zabbix 5.0 安裝
    • 1. 添加 Zabbix 阿裡鏡像源
    • 2. 關閉防火牆 和 SElinux
    • 3. 安裝 Zabbix server 和 agent
    • 4. 安裝 Software Collections
    • 5. 安裝 Zabbix 前端和相關環境
    • 6. 安裝并配置 centos7 預設的 mariadb 資料庫
    • 7. 使用 root 使用者進入 mysql,并建立 zabbix 資料庫
    • 8. 導入 zabbix 資料庫
    • 9. 修改 zabbix server 配置檔案
    • 10. 修改 zabbix 的 php 時區配置
    • 11. 啟動相關服務,并配置開機自動啟動
  • 四、Zabbix web 前端 安裝
    • 1. 使用浏覽器通路 http://ip/zabbix 通路 Zabbix 的 web 頁面
    • 2. 確定滿足所有軟體先決條件
    • 3. 輸入用于連接配接資料庫的詳細資訊(Zabbix 資料庫必須已經建立)
    • 4. 輸入 Zabbix 伺服器詳細資訊
    • 5. 檢視設定摘要
    • 6. 下載下傳并放置配置檔案
    • 7. 完成安裝
    • 8. 登入
    • 9. 更多(java 網關,前端的使用)
  • 參考資料

前言

本文所安裝的系統是純淨的新系統。

本文中所有操作都經過本人親自操作,當中可能走了彎路,新人請諒解。

安裝 zabbix 的目的為學習和熟悉,是以采用了yum的快速安裝方式。

如果想要穩定,可控 請使用編譯安裝

提示:所有步驟均使用 root 使用者

一、配置 yum 源

1. 更換 yum 阿裡源

#備份本地yum源
[[email protected] ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
#擷取阿裡yum源配置檔案
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清除yum緩存
[[email protected] ~]# yum clean all
#更新yum緩存
[[email protected] ~]# yum makecache
           

2. 配置 epel 倉庫

1)安裝 epel-release

[[email protected] ~]# yum install epel-release
           

2)添加wlnmp一鍵包源

rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
           

3)強制更換清華鏡像(可選)

PS:這一步請自行選擇。在清華的鏡像幫助中寫道:“目前tuna已經在epel的官方鏡像清單裡,是以不需要其他配置,mirrorlist機制就能讓你的伺服器就近使用tuna的鏡像。”。 本人是因為原本的官方太慢是以強制清華。各位可以先體驗一下官方的,如果感覺可以接受就不要強制換。

以下摘自清華鏡像網站的幫助(https://mirrors.tuna.tsinghua.edu.cn/help/epel/)

如果你想強制 你的伺服器使用tuna的鏡像,可以修改/etc/yum.repos.d/epel.repo,将mirrorlist和metalink開頭的行注釋掉。

接下來,取消注釋這個檔案裡baseurl開頭的行,并将其中的http://download.fedoraproject.org/pub替換成https://mirrors.tuna.tsinghua.edu.cn。

可以用如下指令自動替換:(來自 https://github.com/tuna/issues/issues/687)

sed -e 's!^metalink=!#metalink=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
    -e 's!http://mirrors\.tuna!https://mirrors.tuna!g' \
    -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
           

3. 配置 remi 倉庫 (清華鏡像)

PS: 除去清華鏡像 其他國内各大鏡像網站也可以 本次使用的是清華鏡像

1)下載下傳 wget

提示:執行防止未安裝 wegt

[[email protected] ~]# yum install -y  wget
           

2)下載下傳并安裝 remi 倉庫

[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
[[email protected] ~]# rpm -Uvh remi-release-7.rpm
[[email protected] ~]# rm -rf remi-release-7.rpm
           

3) 更改 remi 配置

PS:使用 nano 隻是玩樹莓派留下的習慣。 vim 也是不錯的

[[email protected] ~]# nano /etc/yum.repos.d/remi.repo
           

在檔案中尋找這一段

[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=0 #把這裡的0 改成 1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
           

修改後的這段文本是這樣的

[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
           

4)更新 yum

[[email protected] ~]# yum clean all
[[email protected] ~]# yum makecache
           

二、php 7.2 安裝

1.配置 remi

PS:如果想要安裝更高版本的隻要将 “72” 改為 “73” 或 “74” 就可以了

[[email protected] ~]# nano /etc/yum.repos.d/remi-php72.repo
           

修改 [remi-php72]代碼段中的”enabled = 0“

修改後的代碼如下:

[remi-php72]
name=Remi's PHP 7.2 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php72/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php72/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php72/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
           

2.安裝 php 7.2

[[email protected] ~]# yum install php72
           

三、Zabbix 5.0 安裝

1. 添加 Zabbix 阿裡鏡像源

[[email protected] ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[[email protected] ~]# nano /etc/yum.repos.d/zabbix.repo
           

将檔案修改為以下内容:

注意 baseurl 改為國内 Zabbix 源

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=0
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=1
gpgcheck=0
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=0
 
[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
gpgcheck=0
           

2. 關閉防火牆 和 SElinux

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# nano /etc/selinux/config
           

将檔案修改為以下内容

# 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
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are pr$
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
           

3. 安裝 Zabbix server 和 agent

[[email protected] ~]# yum install zabbix-server-mysql zabbix-agent -y
           

4. 安裝 Software Collections

[[email protected] ~]# yum install centos-release-scl -y
           

5. 安裝 Zabbix 前端和相關環境

[[email protected] ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
           

6. 安裝并配置 centos7 預設的 mariadb 資料庫

#安裝 mariadb 資料庫
[[email protected] ~]# yum install mariadb-server -y
#啟動資料庫,并配置開機自動啟動
[[email protected] ~]# systemctl enable --now mariadb
初始化 mariadb 并配置 root 密碼
[[email protected] ~]# mysql_secure_installation
           

7. 使用 root 使用者進入 mysql,并建立 zabbix 資料庫

此處 使用者 zabbix 的密碼為 “password” 可根據需要自己修改

[[email protected] ~]# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user [email protected] identified by 'password';
MariaDB [(none)]> grant all privileges on zabbix.* to [email protected];quit;
           

8. 導入 zabbix 資料庫

此處需要注意版本号

#請使用以下代碼檢查版本号 
[[email protected] ~]# cd  /usr/share/doc/
[[email protected] doc]# ll

#請在 ll 所得結果 中找到與 以下文字 相似的内容 (如未找到請重新安裝 zabbix-server)
drwxr-xr-x.  2 root root  118 Aug 20 09:05 zabbix-server-mysql-5.0.2

#運作下一條指令時 請注意修改版本号 與上方查找的版本号對應 
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql.gz | mysql -uzabbix -p zabbix
#密碼為 sql 中 上一步中 zabbix 使用者 所設的密碼 
           

9. 修改 zabbix server 配置檔案

[[email protected] ~]# nano /etc/zabbix/zabbix_server.conf

#在檔案中尋找 DBPassword =
#在其後方輸入資料庫 zabbix 使用者的密碼 并取消注釋
# 舉例:DBPassword=password
           

10. 修改 zabbix 的 php 時區配置

[[email protected] ~]# nano /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 

#在檔案中尋找 php_value[date.timezone] 修改為
php_value[date.timezone] = Asia/Shanghai
           

11. 啟動相關服務,并配置開機自動啟動

[[email protected] ~]# systemctl start zabbix-server zabbix-agent httpd
[[email protected] ~]# systemctl restart rh-php72-php-fpm
[[email protected] ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
           

四、Zabbix web 前端 安裝

PS:以下内容均摘自 zabbix 官方手冊 (https://www.zabbix.com/documentation/current/manual/installation/install)

1. 使用浏覽器通路 http://ip/zabbix 通路 Zabbix 的 web 頁面

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

2. 確定滿足所有軟體先決條件

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

清單中還可能包含可選的先決條件。失敗的可選前提條件以橙色顯示,并且具有警告狀态。如果可選的先決條件失敗,則設定可以繼續。

3. 輸入用于連接配接資料庫的詳細資訊(Zabbix 資料庫必須已經建立)

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

如果選中了TLS加密選項,則會以以下形式顯示五個用于配置與資料庫的TLS連接配接的其他字段。(僅适用于MySQL或PostgreSQL)

4. 輸入 Zabbix 伺服器詳細資訊

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

輸入Zabbix伺服器的名稱是可選的,但是,如果送出了名稱,它将顯示在菜單欄和頁面标題中。

5. 檢視設定摘要

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

6. 下載下傳并放置配置檔案

PS:這部分按照頁面提示的路徑複制 zabbix.conf.php 就可以了

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料
Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

Note:如果Web伺服器使用者對conf /目錄具有寫通路權限,則配置檔案将自動儲存,并且可以立即進行下一步。

7. 完成安裝

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

8. 登入

預設使用者名為Admin,密碼為zabbix。

Zabbix 5.0 及 web 界面 centos7 yum 安裝前言一、配置 yum 源二、php 7.2 安裝三、Zabbix 5.0 安裝四、Zabbix web 前端 安裝參考資料

9. 更多(java 網關,前端的使用)

請通路官網手冊

參考資料

https://www.cnblogs.com/heqiuyong/p/11526706.html

https://blog.csdn.net/hl449006540/article/details/79726672

https://mirrors.tuna.tsinghua.edu.cn/remi/

https://blog.whsir.com/post-5373.html

https://mirrors.tuna.tsinghua.edu.cn/help/epel/

https://blog.csdn.net/qq_39583463/article/details/80571849

https://www.cnblogs.com/joycezhou/p/13439646.html

https://blog.csdn.net/sunylat/article/details/81869513

https://www.zabbix.com/documentation/current/manual/installation/install

https://www.cnblogs.com/zhy-1992/p/6179940.html

https://blog.csdn.net/weixin_44736359/article/details/107164195