Zabbix5.0的安裝(超詳細)
一、安裝zabbix-server
首先在虛擬機器上把Centos7安裝完畢並關閉防火牆與SElinux。
開啟Zabbix官網選擇Zabbix版本-OS系統-OS版本-資料庫-WebServer
2、替換阿里雲Zabbix源
shell指令碼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、前期準備
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all
安裝Zabbix server 和 agent
yum install zabbix-server-mysql zabbix-agent
安裝Zabbix frontend
yum install centos-release-scl
編輯配置檔案 /etc/yum.repos.d/zabbix.repo
vim /etc/yum.repos.d/zabbix.repo [zabbix-frontend] ... enabled=1 ...
安裝 Zabbix frontend packages
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
安裝Mysql資料庫
cd /usr/local/src/ wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm rpm -ivh mysql57-community-release-el7-8.noarch.rpm yum -y install mysql-server
啟動Mysql
systemctl start mysqld
獲取安裝時的臨時密碼
grep 'temporary password' /var/log/mysqld.log
‘,LW:N3)&hQ8h’臨時密碼 用這個密碼登入並修改密碼
mysql -uroot -p',LW:N3)&hQ8h' mysql> set password for root@localhost = password('password');
建立初始資料庫
mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; mysql> quit;
匯入初始架構和資料,系統將提示您輸入新建立的密碼
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
為Zabbix server配置資料庫
編輯配置檔案 /etc/zabbix/zabbix_server.conf
vim /etc/zabbix/zabbix_server.conf
DBPassword=password
為Zabbix前端配置PHP
編輯配置檔案 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
啟動Zabbix server和agent程序
啟動Zabbix server和agent程序,併為它們設定開機自啟
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
二、開啟http:IP/zabbix 例:http://10.0.0.147/zabbix
點選“Next step”檢查元件是否OK
點選“Next step”,配置連線資料庫
輸入zabbix帳戶的密碼,然後“Next step”
直接下一步
下一步
看到上述提示,說明安裝成功。點"Finish"
使用者名稱:Admin,密碼:zabbix
顯示中文亂碼解決方法
在zabbix-server伺服器上安裝如下檔案符集
yum install wqy-microhei-fonts
然後替換linux上預設的字符集
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
重啟zabbix-server,檢視亂碼是否解決
三、客戶端安裝
同zabbix-server伺服器操作,第一步是替換阿里源。
執行如下命令:
yum install zabbix-agent
配置vim /etc/zabbix/zabbix_agentd.conf 。修改zabbix-server的IP
vim /etc/zabbix/zabbix_agentd.conf
Server=10.0.0.147
重啟zabbix-agent