zabbix分佈式監控系統安裝配置

zabbix簡介:php

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

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

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

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

Alexei Vladishev建立了Zabbix項目,當前處於活躍開發狀態,Zabbix SIA提供支持.web

Zabbix是一個企業級的、開源的、分佈式的監控套件sql

Zabbix能夠監控網絡和服務的監控情況. Zabbix利用靈活的告警機制,容許用戶對事件發送基於Email的告警. 這樣能夠保證快速的對問題做出相應. Zabbix能夠利用存儲數據提供傑出的報告及圖形化方式. 這一特性將幫助用戶完成容量規劃.數據庫

Zabbix支持polling和trapping兩種方式. 全部的Zabbix報告均可以經過配置參數在WEB前端進行訪問. Web前端將幫助你在任何區域都可以迅速得到你的網絡及服務情況. Zabbix能夠經過儘量的配置來扮演監控你的IT基礎框架的角色,而無論你是來自於小型組織仍是大規模的公司.apache

Zabbix是零成本的. 由於Zabbix編寫和發佈基於GPL V2協議. 意味着源代碼是免費發佈的.vim

Zabbix公司也提供商業化的技術支持.

zabbix的特性:

(1)安裝與配置簡單。
(2)可視化web管理界面。
(3)免費開源。
(4)支持中文。
(5)自動發現。
(6)分佈式監控。
(7)實時繪圖。

環境說明:

check1爲Server,check2和check3爲Proxy

[root@check1 ~]# cat /etc/redhat-release 
CentOS release 6.9 (Final)
[root@check1 ~]# uname -a
Linux check1 2.6.32-696.16.1.el6.x86_64 #1 SMP Wed Nov 15 16:51:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

1、zabbix安裝

Zabbix 3.0對PHP的要求最低爲5.4,而CentOS6默認爲5.3.3,徹底不知足要求,故須要利用第三方源,將PHP升級到5.4以上,注意,不支持PHP7

[root@check1 ~]# mkdir zabbix
[root@check1 ~]# cd zabbix/
[root@check1 zabbix]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
[root@check1 zabbix]# yum -y install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
[root@check1 zabbix]# vim /etc/php.ini
  889 date.timezone = Asia/Shanghai
  663 post_max_size = 32M
  375 max_execution_time = 300
  385 max_input_time = 300
  705 always_populate_raw_post_data = -1

安裝MySQL

MySQL建議使用5.6版本,CentOS6.x默認爲5.1,不建議使用性能偏低

[root@check1 ~]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
[root@check1 ~]# yum -y install mysql-server mysql-devel

[root@check1 ~]# rpm -qa | grep mysql*
mysql-community-libs-5.6.40-2.el6.x86_64
mysql-community-release-el6-5.noarch
php56w-mysql-5.6.35-1.w6.x86_64
mysql-community-common-5.6.40-2.el6.x86_64
mysql-community-libs-compat-5.6.40-2.el6.x86_64
mysql-community-client-5.6.40-2.el6.x86_64
mysql-community-server-5.6.40-2.el6.x86_64
mysql-community-devel-5.6.40-2.el6.x86_64

[root@check1 ~]# vim /etc/my.cnf
[mysqld]
innodb_file_per_table
[root@check1 ~]# service mysqld start
[root@check1 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):       #初次運行直接回車
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y        #是否設置root密碼,輸入y回車設置密碼
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y      #是否刪除匿名用戶,生產環境建議刪除,可直接回車
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n             #是否禁止root用戶遠程登陸,根據本身的需求選擇
... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y       #是否刪除test數據庫,可直接回車
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]       #是否從新加載權限表,直接回車
... Success!

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...

上面若是沒有設置root密碼可用一下命令進行設置
[root@check1 ~]# mysqladmin -u root password

[root@check1 ~]# mysql -uroot -p
Enter password:

mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';       #IP地址與zabbix的用戶、庫和密碼自行更換
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

mysql> show databases; 
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| mysql                  |
| performance_schema     |
| zabbix                 |
+------------------------+
4 rows in set (0.00 sec)

安裝zabbix

[root@check1 ~]# useradd -m -s /sbin/nologin zabbix
[root@check1 ~]# yum -y install httpd libxml2-devel net-snmp-devel libcurl-devel
[root@check1 ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.0/zabbix-3.2.0.tar.gz
[root@check1 ~]# mv zabbix-3.2.0.tar.gz zabbix
[root@check1 ~]# cd zabbix/
[root@check1 zabbix]# tar xf zabbix-3.2.0.tar.gz 
[root@check1 zabbix]# cd zabbix-3.2.0
[root@check1 zabbix-3.2.0]# /usr/bin/mysql -uzabbix -p zabbix < database/mysql/schema.sql
Enter password:
[root@check1 zabbix-3.2.0]# /usr/bin/mysql -uzabbix -p zabbix < database/mysql/images.sql
Enter password: 
[root@check1 zabbix-3.2.0]# /usr/bin/mysql -uzabbix -p zabbix < database/mysql/data.sql
Enter password:
[root@check1 zabbix-3.2.0]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2
[root@check1 zabbix-3.2.0]# make
[root@check1 zabbix-3.2.0]# make install

編譯過程當中若是遇到報錯以下:
configure: error: Not found mysqlclient library

解決:
ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so
ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient_r.so)

配置zabbix:

[root@check1 ~]# vim /etc/zabbix/zabbix_server.conf
 DBHost=localhost
 DBName=zabbix
 DBUser=zabbix
 DBPassword=zabbix
 ListenIP=127.0.0.1,192.168.1.1     #自行更改zabbix監聽的IP地址
[root@check1 ~]# iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT
[root@check1 ~]# service iptables save &&service iptables restart
iptables:將防火牆規則保存到 /etc/sysconfig/iptables:  [肯定]
iptables:將鏈設置爲政策 ACCEPT:filter                [肯定]
iptables:清除防火牆規則:                             [肯定]
iptables:正在卸載模塊:                               [肯定]
iptables:應用防火牆規則:                             [肯定]
[root@check1 ~]# setenforce 0
[root@check1 ~]# vim /etc/selinux/config
 SELINUX=disabled
[root@check1 ~]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
[root@check1 ~]# cp /root/zabbix/zabbix-3.2.0/misc/init.d/fedora/core/zabbix_* /etc/init.d/
[root@check1 ~]# chmod +x /etc/init.d/zabbix_*
[root@check1 ~]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
 

配置Web

[root@check1 ~]# vim /etc/httpd/conf/httpd.conf
 ServerName 127.0.0.1,192.168.1.1
 DocumentRoot "/var/www/html/zabbix"

[root@check1 ~]# mkdir -p /var/www/html/zabbix
[root@check1 ~]# cp -r /root/zabbix/zabbix-3.2.0/frontends/php/* /var/www/html/zabbix/
[root@check1 ~]# chown -R apache.apache /var/www/html/zabbix/
[root@check1 ~]# service httpd start
正在啓動 httpd:                                     [肯定]
[root@check1 ~]# chkconfig zabbix_server on
[root@check1 ~]# /etc/init.d/zabbix_server start
Starting zabbix_server:                            [肯定]
[root@check1 ~]# netstat -anpt | grep zabbix
tcp   0   0   192.168.1.1:10051    0.0.0.0:*    LISTEN   2433/zabbix_server 
tcp   0   0   127.0.0.1:10051      0.0.0.0:*    LISTEN   2433/zabbix_server

[root@check1 ~]# iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

 

 web配置zabbix

用戶名和密碼默認爲:

用戶名:Admin

密碼:zabbix

簡單配置

一、改成中文

更換語言後zabbix會出現亂碼,須要給zabbix更換下字體庫

在任意一臺windows執行

找一種字體複製出去一份,把名字改成msyh.ttf或MSYH.ttf

把字體文件上傳到/var/www/html/zabbix/fonts目錄下

編輯文件

[root@check1 fonts]# vim vim /var/www/html/zabbix/include/defines.inc.php

  45 define('ZBX_GRAPH_FONT_NAME',           'MSYH'); // font file name

  93 define('ZBX_FONT_NAME', 'MSYH');

[root@check1 fonts]# /etc/init.d/zabbix_server restart

安裝配置zabbix代理之zabbix_proxyhttp://www.cnblogs.com/LuckWJL/p/9055587.html

zabbix安裝配置agent程序之agent配置文件詳解:http://www.cnblogs.com/LuckWJL/p/9055912.html

zabbix_server經過zabbix_proxy進行監控Host:http://www.cnblogs.com/LuckWJL/p/9056195.html

相關文章
相關標籤/搜索