zabbix服務器端服務搭建

zabbix介紹:
zabbix是一個基於web界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。
zabbix能監視各種網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各種問題。
zabbix由2部分構成,zabbix server與可選組件zabbix agent。
zabbix server可以通過SNMP,zabbix agent,ping,端口監視等方法提供對遠程服務器/網絡狀態的監視,數據收集功能,它可以運行在Linux,Ubuntu,Solarls,HP-UX,AIX,Free BSD,Open BSD,OS X等平臺上。
zabbix agent 需要安裝在被監視的目標服務器上,它主要完成對硬件信息或與操作系統有關的內存,CPU等信息的收集。
zabbix server可以單獨監視遠程服務器的服務狀態;同時也可以與zabbix agent配合,可以輪詢zabbix agent 主動接收監視數據(agent方式),同時還可被動接收zabbix agent發送的數據(trapping方式)。
另外zabbix server還支持SNMP(v1,v2),可以與SNMP軟件(例如:net-snmp)等配合使用。

部署zabbix
環境:
服務器:192.168.56.12
需安裝的應用:lamp架構,zabbix server,zabbix agent。
由於zabbix使用php語言開發的,所以必須先部署lamp架構,使其支持運行php網頁

1.zabbix服務端安裝
//安裝依賴包
[root@hyj ~]# yum -y install net-snmp-devel libevent-devel
//下載zabbix
[root@hyj ~]# cd /usr/src/
[root@hyj src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
//解壓zabbix
[root@hyj src]# tar xf zabbix-3.4.12.tar.gz
//創建zabbix用戶和組
[root@hyj ~]# groupadd -r zabbix
[root@hyj ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix

//配置zabbix數據庫
[root@hyj ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
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> 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 'zabbix123';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

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

[root@hyj ~]# cd /usr/src/zabbix-3.4.12/database/mysql/
[root@hyj mysql]# ls
data.sql images.sql schema.sql
[root@hyj mysql]# mysql -uzabbix -pzabbix123 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@hyj mysql]# mysql -uzabbix -pzabbix123 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@hyj mysql]# mysql -uzabbix -pzabbix123 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

//編譯安裝zabbix
[root@hyj ~]# cd /usr/src/zabbix-3.4.12
[root@hyj zabbix-3.4.12]# ./configure --enable-server \

--enable-agent \
--with-mysql \
--with-net-snmp \
--with-libcurl \
--with-libxml2
[root@hyj zabbix-3.4.12]# make install

2.zabbix服務端配置
[root@hyj ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
//修改服務端配置文件
//設置數據庫信息
[root@hyj ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[root@hyj ~]# vi /usr/local/etc/zabbix_server.conf
...
...
DBPassword=zabbix123 //設置zabbix數據庫連接密碼

//啓動zabbix_server和zabbix_agentd
[root@hyj ~]# zabbix_server
[root@hyj ~]# zabbix_agentd
[root@hyj ~]# 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 :::*

3.zabbix服務端web界面an裝與配置
//修改/etc/php.ini的配置並重啓php-fpm
[root@hyj ~]# sed -ri 's/(post_max_size =)./\1 16M/g' /etc/php.ini
[root@hyj ~]# sed -ri 's/(max_execution_time =).
/\1 300/g' /etc/php.ini
[root@hyj ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini[root@hyj ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@hyj ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done

[root@hyj ~]# cd /usr/src/zabbix-3.4.12
[root@hyj zabbix-3.4.12]# ls
aclocal.m4 config.guess database Makefile README
AUTHORS config.log depcomp Makefile.am sass
bin config.status frontends Makefile.in src
build config.sub include man upgrades
ChangeLog configure INSTALL misc
compile configure.ac install-sh missing
conf COPYING m4 NEWS
[root@hyj zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix
[root@hyj zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@hyj zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs

//配置apache虛擬主機
[root@hyj ~]# vi /etc/httpd24/httpd.conf
</VirtualHost>

<VirtualHost :80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName zabbix.ranwoaini.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@hyj ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@hyj ~]# 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@hyj ~]# apachectl stop
[root@hyj ~]# apachectl start
//添加域名映射
192.168.56.12 zabbix.ranwoaini.com

//關閉防火牆,使用域名訪問
[root@hyj ~]# systemctl stop firewalld
[root@hyj ~]# setenforce 0
zabbix服務器端服務搭建zabbix服務器端服務搭建
zabbix服務器端服務搭建
zabbix服務器端服務搭建zabbix服務器端服務搭建
zabbix服務器端服務搭建 默認登錄用戶Admin,登錄密碼zabbixzabbix服務器端服務搭建

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