Zabbix監控安裝搭建

1安裝之前的準備

1.1關閉防火牆

  1. 臨時關閉防火牆:sudo systemctl stop firewalld
  2. 永久關閉防火牆:sudo systemctl disable firewalld,然後reboot重啓
  3. 查看防火牆狀態:sudo systemctl status firewalld

1.2關閉SELinux

  1. 查看當前狀態:getenforce
  2. 臨時關閉:setenforce 0
  3. 永久關閉:vim /etc/selinux/config,將SELINUX=enforcing改爲SELINUX=disabled,保存後重啓

2安裝及配置數據庫

2.1安裝數據庫

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7- x86_64/pgdg-centos10-10-2.noarch.rpm -y  

yum install postgresql10-contrib postgresql10-server -y

2.2初始化數據庫

/usr/pgsql-10/bin/postgresql-10-setup initdb

systemctl start postgresql-10

systemctl enable postgresql-10.service

2.3配置數據庫

  1. 切換用戶到postgres:su - postgres
  2. 進入pgsql:psql
  3. 配置密碼:ALTER USER postgres WITH PASSWORD '111111';
  4. 創建數據庫和用戶:CREATE DATABASE zabbix;CREATE USER zabbix CREATEDB LOGIN PASSWORD '111111';GRANT ALL ON DATABASE zabbix TO zabbix;
  5. 修改監聽地址權限

vim  /var/lib/pgsql/10/data/postgresql.conf修改爲listen_addresses = '*'

vim  /var/lib/pgsql/10/data/pg_hba.conf,末尾添加一行:host  all  all  0.0.0.0/0  md5

3安裝php

安裝php源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install -y - mod_php72w yum-utils php72w-cli php72w-common php72w-gd php72w-mbstring php72w-mysql

php72-xml php72-fpm php-redis php72w-xml php72w-fpm

systemctl enable php-fpm.service

systemctl start php-fpm

4安裝及配置zabbix

4.1安裝zabbix

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm

yum clean all

yum -y install zabbix-server-pgsql zabbix-web-pgsql zabbix-agent

4.2導入初始架構和數據

zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

4.3爲Zabbix服務器配置數據庫

編輯文件/etc/httpd/conf.d/zabbix.conf,取消註釋併爲您設置正確的時區:php_value date.timezone Asia/Shanghai

vi /etc/zabbix/zabbix_server.conf

DBHOST =localhost

數據庫名= zabbix

DBUSER = zabbix

DBPASSWORD = 111111

4.4其他配置

修改文件權限

chown -R root:apache /var/lib/php

httpd配置 vim /etc/httpd/conf/httpd.conf:ServerName x.x.x.x(定義客戶端從服務器讀取數據時返回給客戶端的主機名)

DocumentRoot  "/usr/share/zabbix"

 

4.5啓動Zabbix服務器和代理程序進程並使其在系統引導時啓動

systemctl restart zabbix-server zabbix-agent httpd

systemctl enable zabbix-server zabbix-agent httpd

4.6安裝php

打開網址安裝

http://x.x.x.x/setup.php

按照提示進行安裝

按照提示修改 vim /etc/php.ini 裏面參數 時區設置爲PRC

按照提示進行操作完成安裝

5用zabbix監控linux主機

在被監控主機上安裝

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm

yum clean all

yum install -y zabbix40-agent.x86_64

cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.old

vim /etc/zabbix/zabbix_agentd.conf   #清空配置文件

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=192.168.10.104  # 填寫zabbix_server服務端 的 IP

ListenPort=10050

ServerActive=192.168.10.104  # 填寫zabbix_server服務端 的 IP

Hostname=aliyun   #監控端主機名

Timeout=30

Include=/etc/zabbix/zabbix_agentd.d/*.conf

systemctl  restart zabbix-agent

 

去網頁新建主機 添加模板即可監控

6版本配置

軟件

版本

Centos

7

Postgresql

10

Zabbix

4.0

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