centos7 安裝部署 zabbix5.0 監(jiān)控系統(tǒng)

一、安裝Mariadb數(shù)據(jù)庫

  1. centos7上安裝mariadb數(shù)據(jù)庫
yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
  1. 初始化mariadb數(shù)據(jù)庫
[root@zbxserver ~]# mysql_secure_installation
Enter current password for root (enter for none):  ##這里回車一次
Set root password? [Y/n] y  ##這里輸入y并回車一次
New password:   ##這里輸入一次root賬號的密碼,并回車一次。啰嗦,這里輸入密碼是不會顯示的。
Re-enter new password:     ##這里再輸入一次root賬號的密碼,并回車一次。
Password updated successfully!
Reloading privilege tables..
 ... Success!
 
Remove anonymous users? [Y/n] y  ##這里輸入y并回車一次
 ... Success!
 
Disallow root login remotely? [Y/n] n  ##這里輸入n并回車一次
 ... skipping.
 
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] n  ##這里輸入n并回車一次
 ... skipping.
 
Reload privilege tables now? [Y/n] y  ##這里輸入y并回車一次
 ... Success!
Thanks for using MariaDB!
  1. 創(chuàng)建zabbix所需的數(shù)據(jù)庫、用戶
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user zabbix@localhost identified by '你的密碼';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
MariaDB [(none)]> exit
#在上面第三行中的“你的密碼”寫上用戶zabbix的數(shù)據(jù)庫密碼,等會要用到

二、Zabbix5.0 server端的安裝

  1. 基礎(chǔ)準(zhǔn)備工作
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

hostnamectl set-hostname zbxserver
 
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  1. 安裝并設(shè)置zabbixyum
    2-1.安裝zabbix
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

2-2.修改zabbix源地址為阿里云的zabbix鏡像地址

vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/
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/x86_64/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/x86_64/debuginfo/
enabled=1
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/x86_64/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

#將zabbix官方的地址替換為阿里云的zabbix地址
  1. 查看yum的列表中是否有了zabbix(可略)
yum list | grep zabbix
  1. 安裝zabbix主服務(wù)和agent程序
yum install zabbix-server-mysql zabbix-agent -y
  1. 安裝SCL組件
yum install centos-release-scl -y
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
#如果提示沒有php的話請安裝
yum install rh-php72-php-mbstring rh-php72-php-bcmath rh-php72-php-gd rh-php72-php-mysqlnd rh-php72-php-xml rh-php72-php-ldap rh-php72-php-fpm rh-php72 -y
  1. 導(dǎo)入初始架構(gòu)和數(shù)據(jù)
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
  1. 修改zabbix server的主配置文件、修改數(shù)據(jù)庫密碼
cp /etc/zabbix/zabbix_server.conf{,.bak}
vim /etc/zabbix/zabbix_server.conf
#將【DBPassword=】 修改為 【DBPassword=你的密碼】然后保存退出
#注釋:這里的密碼就是剛才設(shè)置的數(shù)據(jù)庫用戶zabbix的密碼,要保持一致
  1. 修改zabbix的前端頁面的php時區(qū)
cp /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf{,.bak}
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#將; php_value[date.timezone] = Europe/Riga 修改為 php_value[date.timezone] = Asia/Shanghai

#如果這行配置前面有#或者;,請刪掉,然后保存退出即可
  1. 啟動zabbix server 及相關(guān)服務(wù),并設(shè)置為開機自啟
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
  1. 驗證zabbix是否安裝成功
[root@zbxserver ~]# netstat -ntlup |grep zabbix
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      10753/zabbix_agentd 
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      16598/zabbix_server 
tcp6       0      0 :::10050                :::*                    LISTEN      10753/zabbix_agentd 
tcp6       0      0 :::10051                :::*                    LISTEN      16598/zabbix_server
注釋:zabbix server使用的端口是10051,zabbix agent的端口是10050,這非常重要。

如果發(fā)現(xiàn)沒有10050或者10051端口,那么請檢查zabbix的日志。從日志中你將能很快定位問題點

tail -f /var/log/zabbix/zabbix_server.log

還可以使用命令mysql -u zabbix -p檢查數(shù)據(jù)庫是否正確
  1. 初始化zabbix server 的頁面
打開瀏覽器,輸入地址【http://本機IP/zabbix】

大概是第一頁是zabbix的前端檢查各個組件是否ok,必須全部是綠色打鉤的

然后輸入數(shù)據(jù)庫的密碼,密碼就是數(shù)據(jù)庫用戶zabbix的密碼
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容