centos7.4部署zabbix4.2 server agent-Linux

一、部署server端

第一步:關閉selinux、防火牆

#查看是否開啓selinux。Enforcing爲開啓狀態,Permissive爲關閉
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0

#修改配置文件,將SELINUX=enforcing改爲SELINUX=disabled
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled

#關閉防火牆
[root@localhost ~]# systemctl stop firewalld.service 

第二步:設置主機名

[root@localhost ~]# hostnamectl set-hostname zb_server
[root@localhost ~]# exit
#配置完成之後,退出重新登錄一下

[root@zb_server ~]# hostname
zb_server
#可以看到主機已經改變

第三步:配置軟件倉庫

清華鏡像站:https://mirrors.tuna.tsinghua.edu.cn
點擊使用幫助——在左側找到"centos",直接複製tsinghua.repo倉庫文件就行。epel.repo也是在網站內找到“epel”複製進來。

[root@zb_server yum.repos.d]# vim tsinghua.repo
[root@zb_server yum.repos.d]# vim epel.repo
[root@zb_server /]# rpm -ivh http://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm

#清除原有的緩存
[root@zb_server yum.repos.d]# yum clean all

#新建緩存
[root@zb_server /]# yum makecache

第四步:時間同步

1.安裝ntp時間同步服務和ntp客戶端工具

#查看是否已安裝
[root@zb_server /]# yum list installed | grep 'ntp'
fontpackages-filesystem.noarch      1.44-8.el7                     @anaconda/7.4
ntp.x86_64                          4.2.6p5-28.el7.centos          @base        
ntpdate.x86_64                      4.2.6p5-28.el7.centos          @base        
python-ntplib.noarch                0.3.2-1.el7                    @anaconda/7.4

#如果沒有安裝就進行安裝
[root@zb_server /]# yum -y install ntp.x86_64 ntpdate.x86_64

2.先做一次同步
[root@zb_server /]# ntpdate -u 0.cn.pool.ntp.org
13 Aug 09:32:11 ntpdate[123775]: adjust time server 119.28.183.184 offset 0.001769 sec
[root@zb_server /]# date
Tue Aug 13 09:32:43 PDT 2019

#我在這個配置的時間是2019/8/14/ 0:32,所以可以看出時區不一致
3.設置時區
[root@zb_server /]# timedatectl set-timezone Asia/Shanghai

#再看一下時間已正常
[root@zb_server /]# date
Wed Aug 14 00:37:05 CST 2019

4.註釋掉默認的ntp服務器配置,替換爲國內的ntp服務器
[root@zb_server /]# vim /etc/ntp.conf
 #server 0.centos.pool.ntp.org iburst
 #server 1.centos.pool.ntp.org iburst
 #server 2.centos.pool.ntp.org iburst
 #server 3.centos.pool.ntp.org iburst
 server 0.cn.pool.ntp.org iburst
 server 1.cn.pool.ntp.org iburst
 server 2.cn.pool.ntp.org iburst
 server 3.cn.pool.ntp.org iburst

5.重啓服務
[root@zb_server /]# systemctl restart ntpd


第五步:安裝數據庫、zabbbix

1.安裝
[root@zb_server /]# yum install -y mariadb-server  mariadb

2.重啓服務、設置開機啓動
[root@zb_server /]# systemctl restart mariadb
[root@zb_server /]# systemctl enable mariadb 

3.建庫&授權
#默認密碼爲空,直接回車就ok
[root@zb_server /]# mysql -u root -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
MariaDB [(none)]> exit
Bye


4.導入epel的gpg-key證書
[root@zb_server /]# rpm --import https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7

5.安裝zabbix
[root@zb_server /]#  yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
# 如果發現有不能安裝的,就yum -y update

6.導入數據
[root@zb_server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p zabbix


7.編輯zabbix的配置文件
[root@zb_server ~]# vim /etc/zabbix/zabbix_server.conf
添加:DBPassword=password
[root@zb_server ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai

8.啓動server&agent端,並設置開機啓動
[root@zb_server ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@zb_server ~]# systemctl enable zabbix-server zabbix-agent httpd

第六步:配置zabbix-web

在瀏覽器中輸入 http:// IP地址 /zabbix 登錄到web頁面,完成安裝嚮導填寫

用戶名:Admin
密碼:zabbix

二、部署agent端

1.主動模式配置

ServerActive:當工作在主動模式時,將數據推送給哪臺Server端服務器,多個逗號隔開
Hostname:當前服務器的主機名,Server通過此參數識別當前主機


#我的server和agent都在一臺主機上
[root@zb_server ~]# vim /etc/zabbix/zabbix_agentd.conf
##### Active checks related
ServerActive=127.0.0.1
Hostname=zb_server

2.被動模式配置

Server:用於指定允許哪臺服務器拉取當前服務器的數據
ListenPort:agentd監聽端口,默認10050
ListenIP:agentd監聽IP


[root@zb_server ~]# vim /etc/zabbix/zabbix_agentd.conf
##### Passive checks related
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=zb_server

3.重啓服務

systemctl restart zabbix-agent
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章