快速搭建監控zabbix3.2

大家好,今天是快速搭建監控平臺zabbix3.2(親測有效)

要求:

centos7.2 系統

提前關閉防火牆和selinux

不是root用戶請給該用戶sudo 權限

流程如下:

安裝MariaDB數據庫

yum -y install mariadb-server mariadb-devel

systemctl start mariadb.service

查看狀態

ps aux | grep mysqld

配置數據庫

[root@localhost ~]# mysql
首次直接進入mysql數據庫

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '123456';

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit

安裝zabbix

獲取並安裝zabbix的yum源wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

生成yum源快照,這樣可以直接用tab鍵來補全安裝。

yum makecache

查看文件:[root@localhost ~]# yum search zabbix
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
  base: ftp.sjtu.edu.cn
 
extras: ftp.sjtu.edu.cn
 * updates: ftp.sjtu.edu.cn
========================================================= N/S matched: zabbix ===================================
pcp-export-zabbix-agent.x86_64 : Module for exporting PCP metrics to Zabbix agent
zabbix-agent.x86_64 : Zabbix Agent
zabbix-get.x86_64 : Zabbix Get
zabbix-java-gateway.x86_64 : Zabbix java gateway
zabbix-proxy-mysql.x86_64 : Zabbix proxy for MySQL or MariaDB database
zabbix-proxy-pgsql.x86_64 : Zabbix proxy for PostgreSQL database
zabbix-proxy-sqlite3.x86_64 : Zabbix proxy for SQLite3 database
zabbix-release.noarch : Zabbix repository configuration
zabbix-sender.x86_64 : Zabbix Sender
zabbix-server-mysql.x86_64 : Zabbix server for MySQL or MariaDB database
zabbix-server-pgsql.x86_64 : Zabbix server for PostgresSQL database
zabbix-web.noarch : Zabbix web frontend common package
zabbix-web-mysql.noarch : Zabbix web frontend for MySQL
zabbix-web-pgsql.noarch : Zabbix web frontend for PostgreSQL
zabbix-web-japanese.noarch : Japanese font settings for frontend

  Name and summary matches only, use "search all" for everything.

----------------------------------下面說下以上包的用途---------------------------------
zabbix-agent.:zabbix客戶端,用來收集客戶端各種參數
zabbix-get:zabbix的一個工具,用來檢查是否可以獲取服務器信息(一般服務端要安裝)
zabbix-java-gateway:用於監控JMX應用的程序,它把收集到的信息發送個(這個看需求安裝,我暫時沒裝)
zabbix-proxy:zabbix proxy可以代替zabbix server檢索客戶端的數據,然後把數據彙報給zabbix server,並且在一定程度上分擔了zabbix server的壓力。zabbix proxy可以非常簡便的實現了集中式、分佈式監控。
zabbix-release:會生成一個zabbix的yum源,可以直接下載相關軟件包。
zabbix-sender:用於發送數據給server或者proxy。
zabbix-web:zabbix要使用web界面,這個包是用來處理Apache和php,mysql等之間的依賴關係。
zabbix-web-mysql:這個是zabbix前段支持mysql的
zabbix-web-japanese:支持日語

可以選擇自己需要的安裝包進行安裝,我只選了幾個需要的

yum install zabbix-get zabbix-sender zabbix-server-mysql  zabbix-web zabbix-web-mysql zabbix-agent

生成查找快照

updatedb

查找create.sql文件位置

[root@localhost ~]# locate create.sql
/usr/share/doc/zabbix-server-mysql-3.2.2/create.sql.gz
/usr/share/doc/zabbix-server-pgsql-3.2.2/create.sql.gz

切換到zabbix-server目錄

cd /usr/share/doc/zabbix-server-mysql-3.2.2/

查看目錄下文件詳細信息

[root@localhost zabbix-server-mysql-3.2.2]# ll
total 1896
-rw-r--r--. 1 root root      98 Feb 27 17:22 AUTHORS
-rw-r--r--. 1 root root  742520 Feb 27 17:22 ChangeLog
-rw-r--r--. 1 root root   17990 Feb 27 17:23 COPYING
-rw-r--r--. 1 root root 1161488 Mar  2 22:49 create.sql.gz
-rw-r--r--. 1 root root      52 Feb 27 17:24 NEWS
-rw-r--r--. 1 root root     188 Feb 27 17:22 README

解壓create.sql.gz這個文件:

[root@localhost zabbix-server-mysql-3.2.2]# gunzip create.sql.gz 

把這個create.sql導入到數據庫中,時間可能稍微有些長,多等一會。
[root@localhost zabbix-server-mysql-3.2.2]# mysql -uzabbix -p zabbix < create.sql

查找這個mysql.sock文件路徑,記下來,一會要用到:

[root@localhost zabbix-server-mysql-3.2.2]# locate mysql.sock
/var/lib/mysql/mysql.sock

修改zabbix_server_conf這個配置文件

[root@localhost zabbix-server-mysql-3.2.2]# vim /etc/zabbix/zabbix_server.conf

找到這一行:
#DBPassword=
在下面再寫一行
DBPassword=123456
再找到這行:
#DBSocket=/tmp/mysql.sock

在下面再寫一行
DBSocket=/var/lib/mysql/mysql.sock
這個密碼是你DariaDB裏面之前設置zabbix用戶的密碼,可以根據自己喜好改。
這個路徑就是上面locate mysql.scok找到的那個路徑
----------------------------正常應該有這幾個參數------------------------------------------

[root@localhost zabbix-server-mysql-3.2.2]# egrep -vn "^#|^$" /etc/zabbix/zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
91:DBName=zabbix
107:DBUser=zabbix
117:DBPassword=123456
125:DBSocket=/var/lib/mysql/mysql.sock
290:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
416:Timeout=4
458:AlertScriptsPath=/usr/lib/zabbix/alertscripts
468:ExternalScripts=/usr/lib/zabbix/externalscripts
504:LogSlowQueries=3000

修改/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 always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai                                //改爲亞洲/上海
    </IfModule>

開啓一系列服務,包括Apache、Mariadb、zabbix-server、zabbix-agent

[root@localhost zabbix-server-mysql-3.2.2]# systemctl start httpd.service
[root@localhost zabbix-server-mysql-3.2.2]# systemctl start mariadb
[root@localhost zabbix-server-mysql-3.2.2]# systemctl start zabbix-server
[root@localhost zabbix-server-mysql-3.2.2]# systemctl start zabbix-agent

下面把上面4個服務設置成開機啓動
[root@localhost zabbix-server-mysql-3.2.2]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost zabbix-server-mysql-3.2.2]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost zabbix-server-mysql-3.2.2]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.servic.
[root@localhost zabbix-server-mysql-3.2.2]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.servic

查看ip,直接用瀏覽器來安裝zabbix
[root@localhost zabbix-server-mysql-3.2.2]# ip a
在瀏覽器上安裝
安裝地址(ip替換爲自己ip):
http://ip/zabbix

快速搭建監控zabbix3.2

下一步
快速搭建監控zabbix3.2

下一步
快速搭建監控zabbix3.2

下一步
快速搭建監控zabbix3.2

一直下一步

快速搭建監控zabbix3.2

登陸後就能看到zabbix3.2的控制檯了

安裝zabbix-agent端

yum安裝即可

wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

yum install zabbix-agent

systemctl start zabbix-agent

systemctl enable zabbix-agent

安裝完成後修改配置文件

vim /etc/zabbix/zabbix_agentd.conf

sed -i 's/Server=127.0.0.1/Server=172.16.5.9/g' /etc/zabbix/zabbix_agentd.conf

sed -i 's/ServerActive=127.0.0.1/ServerActive=172.16.5.9/g'/etc/zabbix/zabbix_agentd.conf

systemctl restart zabbix-agent

ps aux | grep zabbix

lsof -i:10050

出現的一些小問題

解決查看監控圖形字體是亂碼或者小方框的問題

快速搭建監控zabbix3.2

解決辦法:
1、在windows系統找一箇中文字體上傳到服務器中
C:\Windows\Fonts

我這裏找了一個宋體,拖到桌面後名字會變成simsun.ttc
2、直接將simsun.ttc上傳到zabbix字體目錄下,我這裏的路徑是/usr/share/zabbix/fonts
3、更改字體後綴,將原來.ttc改成ttf
1
2 mv simsun.ttc simsun.ttf
chown gdgkapp.gdgkapp simsun.ttf
4、修改配置文件
我這裏配置文件在 /usr/share/zabbix/include/defines.inc.php

1 vim /data/zabbix/include/defines.inc.php
找到以下兩處內容
1
2 define('ZBX_FONT_NAME', 'DejaVuSans');
define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
改成
1
2 define('ZBX_FONT_NAME', 'simsun');
define('ZBX_GRAPH_FONT_NAME', 'simsun');
保存退出,然後直接刷新頁面就好了

快速搭建監控zabbix3.2

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