zabbix服务器端服务搭建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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服务端安装
//安装依赖包
[[email protected] ~]# yum -y install net-snmp-devel libevent-devel
//下载zabbix
[[email protected] ~]# cd /usr/src/
[[email protected] src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
//解压zabbix
[[email protected] src]# tar xf zabbix-3.4.12.tar.gz
//创建zabbix用户和组
[[email protected] ~]# groupadd -r zabbix
[[email protected] ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix

//配置zabbix数据库
[[email protected] ~]# 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 [email protected] identified by ‘zabbix123‘;
Query OK, 0 rows affected, 2 warnings (0.00 sec)

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

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

//编译安装zabbix
[[email protected] ~]# cd /usr/src/zabbix-3.4.12
[[email protected] zabbix-3.4.12]# ./configure --enable-server

--enable-agent
--with-mysql
--with-net-snmp
--with-libcurl
--with-libxml2
[[email protected] zabbix-3.4.12]# make install

2.zabbix服务端配置
[[email protected] ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
//修改服务端配置文件
//设置数据库信息
[[email protected] ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[[email protected] ~]# vi /usr/local/etc/zabbix_server.conf
...
...
DBPassword=zabbix123 //设置zabbix数据库连接密码

//启动zabbix_server和zabbix_agentd
[[email protected] ~]# zabbix_server
[[email protected] ~]# zabbix_agentd
[[email protected] ~]# 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
[[email protected] ~]# sed -ri ‘s/(post_max_size =)./1 16M/g‘ /etc/php.ini
[[email protected] ~]# sed -ri ‘s/(max_execution_time =).
/1 300/g‘ /etc/php.ini
[[email protected] ~]# sed -ri ‘s/(max_input_time =).*/1 300/g‘ /etc/php.ini[[email protected] ~]# sed -i ‘/;date.timezone/a date.timezone = Asia/Shanghai‘ /etc/php.ini
[[email protected] ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done

[[email protected] ~]# cd /usr/src/zabbix-3.4.12
[[email protected] 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
[[email protected] zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix
[[email protected] zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[[email protected] zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs

//配置apache虚拟主机
[[email protected] ~]# 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
[[email protected] ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[[email protected] ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxrwxrwx. 2 apache apache 81 Jul 30 19:41 /usr/local/apache/htdocs/zabbix/conf
//重启apache
[[email protected] ~]# apachectl stop
[[email protected] ~]# apachectl start
//添加域名映射
192.168.56.12 zabbix.ranwoaini.com

//关闭防火墙,使用域名访问
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# setenforce 0
技术分享图片技术分享图片
技术分享图片
技术分享图片技术分享图片
技术分享图片 默认登录用户Admin,登录密码zabbix技术分享图片

以上是关于zabbix服务器端服务搭建的主要内容,如果未能解决你的问题,请参考以下文章

Linux中详细搭建监控服务zabbix部署

基于rhel7.2的Zabbix平台搭建和部署

两种监控软件ganglia与zabbix各自的搭建

Linux监控平台——搭建zabbix监控平台

zabbix 4.4监控搭建

zabbix 4.4监控搭建