Zabbix3.4系列之一:安裝教程

zabbix是一個基於WEB界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。

zabbix能監視各種網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各種問題。

zabbix由2部分構成,zabbix server與可選組件zabbix agent。

zabbix server可以通過SNMP,zabbix agent,ping,端口監視等方法提供對遠程服務器/網絡狀態的監視,數據收集等功能,它可以運行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平臺上。


最近公司部署zabbix用於監控服務器,記錄下自己操作信息,下面是在測試環境上安裝的一個操作步驟:

一、安裝環境:

1、系統環境:CentOS Linux release 7.5.1804 (Core) 

2、zabbix版本:zabbix-release-3.4-2.el7.noarch

3、測試環境,關閉了防火牆(生產環境不建議關閉,根據需求設置防火牆)

[root@centos78 ~]# systemctl stop firewlld.service       關閉防火牆

[root@centos78 ~]# systemctl disable firewalld.service  開機禁用防火牆啓動

4、關閉Selinux

[root@centos78 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

[root@centos78 ~]# setenforce 0

二、安裝數據庫

1、指定下載最新的10.2版本,編輯安裝包路徑下載路徑:

 [root@centos78 ~]# vim /etc/yum.repos.d/base.repo  (沒有base.repo可以自己創建)

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.2/centos7-amd64

gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck = 1

2、安裝10.2的mariadb

yum install mariadb-server

3、設置mariadb

[root@centos78 ~]# systemctl start mariadb  啓動

[root@centos78 ~]# systemctl enable mariadb 設置開機啓動

[root@centos78 ~]# systemctl status mariadb   查看啓動狀態


三、Zabbix3.4安裝及配置

1、下載和安裝Zabbix

[root@centos78 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm  (下載Zabbix最新版本)

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

2、創建數據和導入數據

[root@centos78 ~]# mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 8

Server version: 10.2.17-MariaDB MariaDB Server

Copyright (c) 2000, 2018, 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;     創建數據庫zabbix

Query OK, 1 row affected (0.00 sec)


MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';  設置zabbix權限和密碼

Query OK, 0 rows affected (0.00 sec)


MariaDB [(none)]> exit    退出

Bye


導入數據庫

[root@centos78 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.13/create.sql.gz  |mysql -uzabbix -pzabbix zabbix

配置數據庫用戶和密碼

[root@centos78 ~]# vim /etc/zabbix/zabbix_server.conf   修改配置文件,設置密碼

DBPassword=zabbix

[root@centos78 ~]# grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf  查看關鍵配置信息

38:LogFile=/var/log/zabbix/zabbix_server.log

49:LogFileSize=0

72:PidFile=/var/run/zabbix/zabbix_server.pid

82:SocketDir=/var/run/zabbix

101:DBName=zabbix                       數據庫名稱

117:DBUser=zabbix                          用戶名稱

126:DBPassword=zabbix                  數據庫密碼

330:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

448:Timeout=4

490:AlertScriptsPath=/usr/lib/zabbix/alertscripts

500:ExternalScripts=/usr/lib/zabbix/externalscripts

536:LogSlowQueries=3000


啓動zabbix和設置開機啓動

[root@centos78 ~]# systemctl start zabbix-server

[root@centos78 ~]# systemctl enable zabbix-server


編輯Zabbix前端PHP配置,更改時區

[root@centos78 ~]# vim /etc/httpd/conf.d/zabbix.conf

    <IfModule mod_php5.c>

        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 max_input_vars 10000

        php_value always_populate_raw_post_data -1

        php_value date.timezone Asia/Shanghai           #修改爲亞洲上海

    </IfModule>


啓動http和設置開啓啓動

[root@centos78 ~]# systemctl start httpd

[root@centos78 ~]# systemctl enable httpd



四、安裝Zabbix Web

1、通過瀏覽器訪問,並配置信息

1.png

2.jpg

3.jpg

4.jpg

5.jpg

6.jpg

[root@centos78 ~]# cat /etc/zabbix/web/zabbix.conf.php    查看生成配置文件信息

<?php

// Zabbix GUI configuration file.

global $DB;

$DB['TYPE']     = 'MYSQL';

$DB['SERVER']   = 'localhost';

$DB['PORT']     = '0';

$DB['DATABASE'] = 'zabbix';

$DB['USER']     = 'zabbix';

$DB['PASSWORD'] = 'zabbix';

// Schema name. Used for IBM DB2 and PostgreSQL.

$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';

$ZBX_SERVER_PORT = '10051';

$ZBX_SERVER_NAME = 'zabbix';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;


登錄網站:http://192.168.1.1/zabbix

登錄最新版Zabbix3.4  默認用戶Admin  默認密碼zabbix

輸入用戶名和密碼以後點擊 sign in

7.jpg


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