監控服務zabbix部署
阿新 • • 發佈:2018-08-21
基於 支持中文 character nec snmp 設備 安裝zabbix ora rac Zabbix是什麽?
‘zabbix‘是基於web界面的提供分布式系統監視以及網絡監視功能的企業級的開源解決方案。
‘zabbix能監視各種網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制讓系統管理員快速定位並解決問題‘
Zabbix組成
1.zabbix server
通過SNMP、zabbix agent 、ping, 端口監視等方法提供對遠程服務器/網絡狀態的監視,數據收集等功能 運行在linux\Ubuntu\Solaris\HP-UX\AIX\Free BSD\Open BSD\OS X等平臺。 ‘與zabbix agent 配合,可以輪詢zabbix agent 主動接收監視數據(agent方式), 也可以被動接收zabbix agent 發送的數據(trapping方式)。 支持SNMP(v1,v2)‘
2.zabbix agent
安裝在被監視的目標服務器上,主要完成對硬件信息或與操作系統有關的內存,CPU等信息的收集。
zabbix特點
安裝與配置簡單,學習成本低
免費開源
自動發現服務器與網絡設備
支持多語言(包括中文)
分布式監視以及web集中管理功能
email等通知功能
用戶安全認證和柔軟的授權方式
zabbix配置文件
服務器配置文件(/usr/local/etc/zabbix_server.conf)
客戶端配置文件(/usr/local/etc/zabbix_agentd.conf)
zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)
zabbix服務端安裝
‘安裝依賴包‘
[root@yxr ~]# yum -y install net-snmp-devel libevent-devel
‘下載zabbix‘
[root@yxr src]# cd /usr/src/
[root@yxr src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
‘解壓‘
[root@yxr src]# tar xf zabbix-3.4.12.tar.gz
‘創建zabbix用戶和組‘ [root@yxr src]# groupadd -r zabbix [root@yxr src]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
‘配置zabbix數據庫‘
[root@yxr src]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.08 sec) ‘創建zabbix並支持中文‘
mysql> show databases; (查看存在哪些數據庫)
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
+--------------------+
5 rows in set (0.11 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix123!‘; ‘授權zabbix用戶在數據庫本機上登錄訪問所有數據庫‘
Query OK, 0 rows affected, 2 warnings (0.11 sec)
mysql> grant all privileges on zabbix.* to [email protected] identified by ‘zabbix123!‘;
Query OK, 0 rows affected, 1 warning (0.04 sec)
‘註意:mysql服務進程啟動時會讀取mysql庫中的所有授權表至內存中:
1.grant 或revoke等執行權限操作會保存與表中,mysql的服務進程會自動重讀授權表,並更新至內存中
2.對於不能夠或不能及時重讀授權表的命令,可手動讓mysql的服務進程重讀授權表‘
mysql> flush privileges;
Query OK, 0 rows affected (0.16 sec)
mysql> exit
Bye
[root@yxr ~]# cd /usr/src/zabbix-3.4.12/database/mysql/
[root@yxr mysql]# ls
data.sql images.sql schema.sql
[root@yxr mysql]# mysql -uzabbix -pzabbix123! zabbix <schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@yxr mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@yxr mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
‘編譯安裝zabbix‘
root@yxr mysql]# cd /usr/src/zabbix-3.4.12/
[root@yxr zabbix-3.4.12]# ./configure --enable-server > --enable-agent > --with-mysql > --with-net-snmp > --with-libcurl > --with-libxml2
[root@yxr zabbix-3.4.12]# make install
zabbix服務端配置
[root@yxr ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[root@yxr ~]# vim /usr/local/etc/zabbix_server.conf
‘搜索/DBPassword‘
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=zabbix123! ‘設置zabbix數據庫連接密碼‘
‘啟動zabbix_server和zabbix_agentd‘
[root@yxr ~]# zabbix_server
[root@yxr ~]# zabbix_agentd
[root@yxr ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
zabbix服務端web界面安裝與配置
‘修改/etc/php.ini的配置並重啟php-fpm‘
[root@yxr ~]# sed -ri ‘s/(post_max_size =).*/\1 16M/g‘ /etc/php.ini
[root@yxr ~]# sed -ri ‘s/(max_execution_time =).*/\1 300/g‘ /etc/php.ini
[root@yxr ~]# sed -ri ‘s/(max_input_time =).*/\1 300/g‘ /etc/php.ini
[root@yxr ~]# sed -i ‘/;date.timezone/a date.timezone = Asia/Shanghai‘ /etc/php.ini
[root@yxr ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@yxr ~]# cd /usr/src/zabbix-3.4.12/
[root@yxr zabbix-3.4.12]# ls
aclocal.m4 configure Makefile.am
AUTHORS configure.ac Makefile.in
bin COPYING man
build database misc
ChangeLog depcomp missing
compile frontends NEWS
conf include README
config.guess INSTALL sass
config.log install-sh src
config.status m4 upgrades
config.sub Makefile
[root@yxr zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix
[root@yxr zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@yxr zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs/
‘配置apache虛擬主機,在/etc/httpd24/httpd.conf的配置文件的末尾添加如下內容:‘
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName www.yaoxiaorong.com
ProxyRequests off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
‘設置zabbix/conf目錄的權限,讓zabbix有權限生成配置文件zabbix.conf.php‘
[root@yxr ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@yxr ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxrwxrwx. 2 apache apache 81 Jul 30 19:41 /usr/local/apache/htdocs/zabbix/conf
‘重啟apache‘
[root@yxr ~]# apachectl -t
Syntax OK
[root@yxr ~]# apachectl stop
[root@yxr ~]# apachectl start
[root@yxr ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
安裝zabbix web界面
‘修改/etc/hosts文件,添加域名與IP的映射(windows在
C:\Windows\System32\drivers\etc下的hosts文件)
在瀏覽器上訪問域名,本文設置的域名為www.yaoxiaorong.com,你也可以修改成你自己想命名的域名
恢復zabbix/conf目錄的權限為755‘
在瀏覽器上訪問域名進行安裝:
如圖一:
然後一直下一步下一步,直到出現如下的內容,然後輸入密碼
直到出現這個步驟,輸入用戶名和密碼(用戶是admin,密碼是zabbix)
最後成功的界面
監控服務zabbix部署