1. 程式人生 > 其它 >zabbix部署之yum快速安裝

zabbix部署之yum快速安裝

各位朋友好!近期公司新派了一個任務,監控一批主機,根據系統資訊和監控需求分析,決定使用zabbix 3.x來進行部署監控,下面為隨手筆記;不足之處還請指出。

主機A:192.168.241.136(server端)

主機B:192.168.241.132(agent端)

##採用yum方式安裝,如有二進位制或rpm包安裝需求,請參看其他文件;

一、部署

【serever端】

1、準備yum源,根據自己環境調整

##下載官方yum源
yum install https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

##我放一下公網部署,阿里的zabbix yum源

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

2、安裝zabbix-server-mysql、zabbix-web-mysql、zabbix-agent和maridb-server

yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server

3、啟動資料庫,並加入開機啟動

1 systemctl enable --now maridb 

4、建立zabbix資料庫和zabbix MySQL使用者

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.
* to zabbix@localhost identified by "zabbix";

5、匯入zabbix資料庫表結構和相關資料;

##此處在版本處留心更換版本號
zcat /usr/share/doc/zabbix-server-mysql-3.x.xx/create.sql.gz|mysql -uzabbix -pzabbix zabbix

6、配置zabbix server連線MySQL資料庫

sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

7、時區配置

sed -i.ori '18a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf

8、處理掉zabbix可能會出現的中文亂碼問題

yum -y install wqy-microhei-fonts
yes|cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

9、啟動並將各個元件應用加入開機啟動

systemctl enable --now zabbix-server httpd zabbix-agent

10、環境測試;server端部署至此完畢。

##server端輸入以下指令獲取登入url
echo "瀏覽器訪問 http://`hostname -I|awk '{print $1}'`/zabbix"

11、注#zabbix預設登入賬戶密碼

user:Admin
password:zabbix

【agent端】

1、依舊優先配置yum源,注意根據自己情況調整

##下載官方yum源
yum install https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

2、安裝zabbix-agent

yum -y install zabbix-agent

3、調整server端IP

sed -i 's#Server=127.0.0.1#Server=[調整為server端地址]#' /etc/zabbix/zabbix_agentd.conf

4、啟動並開機自啟

systemctl enable --now zabbix-agent

over over bye