1. 程式人生 > >【zabbix 監控】第一章 zabbix的安裝配置

【zabbix 監控】第一章 zabbix的安裝配置

bash led rman mirrors inux tar arch from localhost

安裝前準備

一、下載網絡yum源:

http://mirrors.163.com/.help/centos.html
https://opsx.alibaba.com/mirror

1、首先備份/etc/yum.repos.d/CentOS-Base.repo,備份之前要先安裝weget(yum -y install wget)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 2、選擇下載一下兩個中任意一個yum源 網易163 yum源: 下載對應版本repo文件, 放入/etc/yum.repos.d/(操作前請做好相應備份) • CentOS7 • CentOS6 • CentOS5 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo #163的yum源,
下載到指定目錄下wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -P /etc/yum.repos.d/ 阿裏雲yum源:https://opsx.alibaba.com/mirror wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 註:關於wget的幾個參數介紹: -O 指定保存的文件名後下載文件 -c 斷點續傳 --limit-rare 限速下載 例: wget --limit-rare=3K /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 3、運行以下命令生成緩存 yum clean all yum makecache

二、防火墻設置

1、可以開啟防火墻:
[root@localhost ~]# firewall-cmd --permanent --add-service=http
success
[root@localhost ~]# firewall-cmd --permanent --add-service=https
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# systemctl enable firewalld.service

2、如果感覺麻煩可以考慮關閉防火墻:
[root@localhost ~]# systemctl stop firewalld.service

[root@localhost ~]# systemctl disable firewalld.service

三、關閉SELINUX

1、查看SElinux狀態:
[root@web129 ~]#/usr/sbin/sestatus -v #如果SELinux status參數為enabled即為開啟狀態
SELinux status: enabled
[root@web129 ~]# getenforce
Disabled
2、關閉SELinux:
(1)臨時關閉(不用重啟機器):
setenforce 0 #設置SELinux 成為permissive模式
#setenforce 1 設置SELinux 成為enforcing模式
(2)永久關閉(需要重啟服務器)
修改配置文件:
[root@web129 ~]# vim /etc/selinux/config
將SELINUX=enforcing改為SELINUX=disabled
或者sed關閉:
[root@web129 ~]# sed -i "s/^SELINUX\=enforcing/SELINUX\=disabled/g" /etc/selinux/config

開始安裝zabbix

1、參考官網提供的zabbix幫助手冊:https://www.zabbix.com/documentation/3.2/manual

2、搭建zabbix的yum倉庫:
由於我們epl的yum倉庫裏存放的zabbix的版本較低,所以我們先搭建一個zabbix的yum倉庫,服務端和客戶端上都要做這個步驟。

安裝過程中如遇見了如下問題,是與原來yum發生沖突卸載即可(此問題是我重復安裝zabbix 不同版本yum源導致,一般不會出現):
[root@localhost yum.repos.d]# rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
獲取http://mirrors.aliyun.com/zabbix/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.DERtgj: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY
準備中... ################################# [100%]
file /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX from install of zabbix-release-3.2-1.el7.noarch conflicts with file from package zabbix-release-3.0-1.el7.noarch
file /etc/yum.repos.d/zabbix.repo from install of zabbix-release-3.2-1.el7.noarch conflicts with file from package zabbix-release-3.0-1.el7.noarch
[root@localhost yum.repos.d]# yum -y remove zabbix-release-3.0-1.el7.noarch

 如果沒有上述問題直接往下執行:

[root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
或者用下邊的方法
[root@web129 yum.repos.d]# rpm -ivh http://101.110.118.57/repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get


Error downloading packages:
iksemel-1.4-2.el7.centos.x86_64: [Errno 256] No more mirrors to try.
fping-3.10-1.el7.x86_64: [Errno 256] No more mirrors to try.
zabbix-web-mysql-3.2.11-1.el7.noarch: [Errno 256] No more mirrors to try.
zabbix-server-mysql-3.2.11-1.el7.x86_64: [Errno 256] No more mirrors to try.

yum -y install unixODBC #一個鏈接數據庫的組件, fping

root@localhost ~]#  yum -y install mariadb mariadb-server

[root@localhost ~]#systemctl enable mariadb ;systemctl start mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type help; or \h for help. Type \c to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by yanglt;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit


[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@localhost zabbix-server-mysql-3.2.11]#  zcat create.sql.gz | mysql -uroot zabbix  #解壓並導入庫
[root@localhost zabbix-server-mysql-3.2.11]# 

[root@localhost ~]#vim /etc/zabbix/zabbix_server.conf
修改一下內容:
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=yanglt

[root@localhost ~]#  systemctl enable zabbix-server.service ;systemctl start zabbix-server.service 


[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai     #只需要增加一行,或者修改時區
[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# systemctl start httpd

打開網頁:http://192.168.19.128/zabbix

技術分享圖片

技術分享圖片

密碼為數據庫授權用戶密碼:

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

默認用戶名:Admin

密碼:zabbix

技術分享圖片

技術分享圖片

你好

【zabbix 監控】第一章 zabbix的安裝配置