一、安裝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 's@repo.zabbix.com@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