1. 程式人生 > 其它 >centos7安裝zabbix5.0

centos7安裝zabbix5.0

一、安裝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,檢視亂碼是否解決