一、安裝zabbix-server
作業系統:CentOS 7.5

1、首先關閉防火墻與SElinux
關閉防火墻
systemctl stop firewalld&&systemctl disable firewalld
關閉SELinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
2、替換阿里云Zabbix源
vi zabbix_aliyun.sh
復制下面的腳本
#!/bin/bash echo -e "請給出要安裝的zabbix版本號,建議使用4.x的版本 \033[31musage:./zabbix_aliyun.sh 4.0|4.4|4.5|5.0 \033[0m" echo "例如要安裝4.4版本,在命令列寫上 ./zabbix_aliyun.sh 4.4" if [ -z $1 ];then exit fi VERSION=$1 if [ -f /etc/yum.repos.d/zabbix.repo ];then rm -rf /etc/repos.d/zabbix.repo fi rpm -qa | grep zabbix-release && rpm -e zabbix-release rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/$VERSION/rhel/7/x86_64/zabbix-release-$VERSION-1.el7.noarch.rpm sed -i "s@zabbix/.*/rhel@zabbix/$VERSION/rhel@g" /etc/yum.repos.d/zabbix.repo sed -i '[email protected]@mirrors.aliyun.com/zabbix@g' /etc/yum.repos.d/zabbix.repo [ $? -eq 0 ] && echo "阿里云的zabbix源替換成功" || exit 1 yum clean all yum makecache fast
然后執行命令:看到下圖表示替換成功
bash zabbix_aliyun.sh 5.0

3、由于zabbix提供集中的web監控管理界面,因此服務在web界面的呈現需要LAMP架構支持,
安裝httpd php
yum install -y httpd php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash

4、安裝常用的開發軟體
yum groups install "Development Tools"

5、安裝Zabbix5.0倉庫
rpm -ivh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all

6、安裝Zabbix server and agent
yum install zabbix-server-mysql zabbix-agent -y

7、啟用Red Hat軟體集合
SCL(Software Collections)可以讓你在同一個作業系統上安裝和使用多個版本的軟體,而不會影響整個系統的安裝包
yum install centos-release-scl -y

啟用zabbix-deprecated repository
vi /etc/yum.repos.d/zabbix.repo

8、安裝zabbix前端
yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl

9、安裝資料庫
yum -y install mariadb-server mariadb

啟動mariadb
systemctl start mariadb&&systemctl enable mariadb

查看mariadb運行狀態
systemctl status mariadb

啟動msyql后執行初始安全設定,設定資料庫密碼為123456
mysqladmin -u root password "123456"
創建初始資料庫
1.mysql -uroot -p #輸入密碼123456 2.create database zabbix character set utf8 collate utf8_bin; 3.create user zabbix@localhost identified by 'password'; #密碼是password,匯入Zabbix資料庫結構和資料輸入這個密碼 4.grant all privileges on zabbix.* to zabbix@localhost; 5.quit; #退出
10、在Zabbix服務器主機上,匯入初始架構和資料,系統將提示您輸入新創建的密碼
回車密碼是password
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

為Zabbix服務器配置資料庫,后面配置資料庫的web界面會用到此資料庫密碼,去掉注釋加上password
vi /etc/zabbix/zabbix_server.conf

11、為Zabbix前端配置PHP
編輯檔案/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf,取消注釋并設定正確的時區
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

時區修改完成后一定要記得重啟PHP服務,否則web界面PHP會報錯

重啟PHP
systemctl restart rh-php72-php-fpm
啟動Zabbix服務及相關服務
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm&&systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

12、配置Zabbix Web前端
瀏覽器輸入http://ip/zabbix,Zabbix初始用戶名:Admin,初始密碼為:zabbix
點next step

如果上面提到的配置時區后未重啟PHP時,這里會報錯,重啟一下PHP就好了

重啟PHP命令
systemctl restart rh-php72-php-fpm

配置mysql資料庫賬號和密碼, 輸入zabbix帳戶的密碼,點next step
密碼是前面設定過的password

Name那里起一個名, 點next step


點finish

至此zabbix前端配置完成
輸入賬號Admin密碼zabbix


13、Zabbix前端界面設定成中文
1、選擇User settings,語言選擇中文,點擊update

2.、顯示中文亂碼解決方法(特別是圖表那塊的漢字)
在zabbix-server服務器上安裝如下檔案符集
yum install -y wqy-microhei-fonts
然后替換linux上默認的字符集,輸入y,然后回車
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

最后重繪網頁或重啟zabbix-server,查看亂碼是否解決
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/473370.html
標籤:Linux
上一篇:給linux(centos)作業系統設定主機名的幾種方式
下一篇:管道符、重定向和環境變數
