【zabbix部署】基于linux安装zabbix监控服务和被监控服务
环境配置
zabbix_server:10.0.0.1
zabbix_agentd:10.0.0.1,10.0.0.2(暂定)
操作系统:centos7.6
安装环境配置
1. LNMP环境
zabbix监控管理基于web页面展示出来的,并且需要使用mysql来存储数据,需先配置好LNMP环境
# 安装环境包
[root@tanbaobao ~]# yum -y install gcc pcre-devel openssl-devel # 安装nginx,这里我之前安装好了(https://www.cnblogs.com/HeiDi-BoKe/p/11417155.html)
[root@VM_0_10_centos tmp]# tar -zxf nginx-1.16.1.tar.gz
# 切换到解压目录
[root@VM_0_10_centos nginx-1.16.1]# mkdir -p /var/tmp/nginx
# 配置
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module
# 编译安装
[root@VM_0_10_centos nginx-1.16.1]# make
[root@VM_0_10_centos nginx-1.16.1]# make install
# 启动服务
[root@VM_0_10_centos nginx]# cd sbin/
[root@VM_0_10_centos sbin]# pwd
/usr/local/nginx/sbin
[root@VM_0_10_centos sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
[root@VM_0_10_centos sbin]# ./nginx -s reload # 安装php
[root@tanbaobao ~]# yum -y install php php-mysql mariadb mariadb-devel mariadb-server php-fpm
2. 修改nginx配置文件
1)主配置文件
[root@tanbaobao zabbix-3.4.4]# cat /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
# 缓存php生成页面内容,8个16k
# fastcgi_buffers 8 16k;
# 缓存php生成的头部信息
# fastcgi_buffers_size 32k;
# 连接php的超时时间
# fastcgi_connect_timeout 300;
# 发送请求的超时时间
# fastcgi_send_timeout 300;
# 读取请求的超时时间
# fastcgi_read_timeout 300;
# 连接外部conf文件
include /usr/local/nginx/conf/thy/*.conf;
}
2)外部文件
[root@tanbaobao zabbix-3.4.4]# cat /usr/local/nginx/conf/thy/other.conf
server{
listen 80;
server_name 10.0.0.1;
location / {
root html;
# Turn on nginx state
# stub_status on;
index index.html index.htm index.php;
}
location /nginx_status {
stub_status on;
access_log off;
allow 10.0.0.1;
allow 10.0.0.2;
deny all;
} # 缓存php生成页面内容,8个16k
# fastcgi_buffers 8 16k;
# 缓存php生成的头部信息
# fastcgi_buffers_size 32k;
# 连接php的超时时间
# fastcgi_connect_timeout 300;
# 发送请求的超时时间
# fastcgi_send_timeout 300;
# 读取请求的超时时间
# fastcgi_read_timeout 300; location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
3)启动服务
# 确保防火墙已关闭,selinux为disabled
[root@tanbaobao zabbix-3.4.4]# /usr/local/nginx/sbin/nginx -s reload
[root@tanbaobao zabbix-3.4.4]# systemctl restart mariadb
[root@tanbaobao zabbix-3.4.4]# systemctl restart php-fpm
4)测试PHP页面网页连通性
# 编写test测试页面
[root@tanbaobao zabbix-3.4.4]# cat /usr/local/nginx/html/test.php
<?php
phpinfo();
?> # 通过浏览器或curl访问
[root@tanbaobao zabbix-3.4.4]# curl http://10.0.0.1/test.php
部署监控服务zabbix_server
1. 源码安装zabbix server
1)安装依赖包
[root@tanbaobao zabbix-3.4.4]# yum -y install net-snmp-devel curl-devel libevent-devel
# 将下载好的zabbix源码包解压编译安装zabbix_server
[root@tanbaobao zabbix-3.4.4]# tar -zxvf zabbix-3.4.4.tar.gz
[root@tanbaobao zabbix-3.4.4]# cd zabbix-3.4.4/
[root@tanbaobao zabbix-3.4.4]# ./configure --enable-server \
> --enable-proxy \
> --enable-agent \
> --with-mysql=/usr/bin/mysql_config \
> --with-netsnmp \
> --with-libcurl
[root@tanbaobao zabbix-3.4.4]# make && make install

2)初始化zabbix
创建数据库,上线zabbix web页面
创建数据库:
# 创建zabbix数据库,支持中文集,并授予相应权限
[root@tanbaobao zabbix-3.4.4]# mysql
MariaDB [(none)]> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'localhost' identified by '密码';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec) # 上面创建的是空数据库,数据在/usr/local/src/zabbix-3.4.4/database/mysql目录下,导入数据注意顺序
[root@tanbaobao zabbix-3.4.4]# cd /usr/local/src/zabbix-3.4.4/database/mysql/
[root@tanbaobao mysql]# ls
data.sql images.sql schema.sql
[root@tanbaobao mysql]# mysql -uzabbix -p数据库密码 zabbix < schema.sql
[root@tanbaobao mysql]# mysql -uzabbix -p数据库密码 zabbix < images.sql
[root@tanbaobao mysql]# mysql -uzabbix -p数据库密码 zabbix < data.sql
上线的web页面:
# 将zabbix的php页面代码复制到nginx发布目录下
[root@tanbaobao src]# cd /usr/local/src/zabbix-3.4.4/frontends/php/
[root@tanbaobao php]# cp -r * /usr/local/nginx/html/
[root@tanbaobao php]# chmod -R 777 /usr/local/nginx/html/
修改zabbix_server配置文件相关参数:
[root@tanbaobao php]# cat /usr/local/etc/zabbix_server.conf | grep -v '^$' | grep -v "^#"
LogFile=/tmp/zabbix_server.log # 日志设置
DBHost=localhost # 数据库主机,默认注释
DBName=zabbix # 数据库名称
DBUser=zabbix # 数据库用户
DBPassword=密码 # 数据库密码,默认注释
Timeout=4
LogSlowQueries=3000 # 创建zabbix用户
[root@tanbaobao php]# useradd -s /sbin/nologin zabbix # 启动zabbix_server服务
[root@tanbaobao php]# zabbix_server
# 查看服务是否正常启动,如果没有启动,先用killall 服务名之后再重新启动服务
[root@tanbaobao php]# ss -ntulp | grep zabbix_server
tcp LISTEN 0 128 *:10051 *:* users:(("zabbix_server"......
修改zabbix_agentd配置文件:
[root@tanbaobao php]# cat /usr/local/etc/zabbix_agentd.conf | grep -v '^$' | grep -v "^#"
LogFile=/tmp/zabbix_agentd.log # 日志设置
Server=127.0.0.1,10.0.0.1 # 允许哪些主机可以监控本机
ServerActive=127.0.0.1,10.0.0.1 # 允许哪些主机通过主动模式监控本机
Hostname=tanbaobao # 设置本机主机名
UnsafeUserParameters=1 # 开启允许自定义key # 启动agentd服务
[root@tanbaobao php]# zabbix_agentd
[root@tanbaobao php]# ss -ntulp | grep zabbix_agentd
tcp LISTEN 0 128 *:10050 *:* users:(("zabbix_agentd"........
浏览器访问页面:http://ip/index.php


点击下一步根据错误提示:


[root@tanbaobao html]# yum -y install php-gd php-xml php-bcmath php-mbstring
修改/etc/php.ini文件如下内容:

# 重启php-fpm服务
[root@tanbaobao html]# systemctl restart php-fpm

发现有个警告:(当然这个warning不解决也没关系,但是我这边还是解决比较好点)

解决:
# 查看是否有该模块(发现并没有该模块)
[root@tanbaobao html]# find / -name "ldap.so" # 安装ldap模块(参考https://www.cnblogs.com/bigdevilking/p/9440098.html)
[root@tanbaobao html]# yum -y install php-ldap # 再次查看发现ldap模块已经存在了
[root@tanbaobao html]# find / -name "ldap.so"
/usr/lib64/php/modules/ldap.so # 重启服务
[root@tanbaobao html]# systemctl restart php-fpm

初始化数据库页面:



使用用户名和密码登录zabbix(登录之后可以设置界面语言环境为中文):

2. 搭建被监控端zabbix_agentd
[root@VM_0_16_centos zabbix-3.4.4]# useradd -s /sbin/nologin zabbix
[root@VM_0_16_centos zabbix-3.4.4]# tar -zxvf zabbix-3.4.4.tar.gz
[root@VM_0_16_centos src]# cd zabbix-3.4.4/ [root@VM_0_16_centos zabbix-3.4.4]# ./configure --enable-agent
[root@VM_0_16_centos zabbix-3.4.4]# make && make install [root@VM_0_16_centos zabbix-3.4.4]# cat /usr/local/etc/zabbix_agentd.conf
Server=监控服务ip # 被动模式
ServerActive=监控服务ip # 主动模式
Hostname=VM_0_16_centos # 被监控主机自己主机名
EnableRemoteCommands=1 # 监控异常后,允许远程登录执行命令
3.配置使用zabbix监控系统
1)添加监控主机

添加监控主机,名称建议和主机名一致,也可以不一致

2)为被监控主机添加模板
选择模板并连接到主机

到此,监控端主机添加完成
【zabbix部署】基于linux安装zabbix监控服务和被监控服务的更多相关文章
- Linux 安装zabbix
Linux 安装zabbix zabbix是基于web界面的开源分布式监控平台,可以监控各种服务器的配置参数,支持自定义配置和自定义告警,并且可以实现邮件.短信等方式的告警,zabbix基本组件如 ...
- linux安装Zabbix监控
源码包3.4.0下载 https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.0/zabbix-3.4 ...
- zabbix源码编译安装以及添加第一台host监控
基础准备 硬件需求 数据库需求 软件需求 其他软件需求 安装 安装方式 source code 编译好的二进制包 rpm或者deb 源码编译安装部署zabbix以及附件 前提准备 最小化安装操作系 ...
- linux安装zabbix的tar包和另外一个并存
在安装zabbix客户端的时候,发现存在一个zabbix客户端,现在我们要重新建一个来与之并存 第一步安装: cd /data0/software/ tar xf zabbix-3.0.28.tar. ...
- 基于Oracle安装Zabbix
软件版本 Oracle Enterprise Linux 7.1 64bit Oracle Enterprise Edition 12.1.0.2 64bit Zabbix 3.2.1 准备工作 上传 ...
- (转)基于CentOS 7安装Zabbix 3.4和Zabbix4.0
原文:https://blog.csdn.net/leshami/article/details/78708049 CentOS 7环境下Zabbix4.0的安装和配置实例-----------htt ...
- 使用Ubuntu系统编译安装Zabbix企业级监控系统
使用Ubuntu系统编译安装Zabbix企业级监控系统 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Ubuntu系统部署笔记:https://www.cnblogs.com/ ...
- Centos 源码安装zabbix 2.4.5
Zabbix简介 Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案.zabbix能监视各种网络参数,保证服务器系统 的安全运营:并提供柔软的通知机制以让系统管 ...
- CentOS 7 源码安装 Zabbix 6.0
Zabbix 主要有以下几个组件组成: Zabbix Server:Zabbix 服务端,是 Zabbix 的核心组件.它负责接收监控数据并触发告警,还负责将监控数据持久化到数据库中. Zabbix ...
随机推荐
- 文件系统之LVM 逻辑卷管理
1. LVM介绍 LVM 是 Logical Volume Manager 的简称,中文就是逻辑卷管理. 物理卷(PV,Physical Volume):就是真正的物理硬盘或分区. 卷组(VG,Vol ...
- [ch04-03] 用神经网络解决线性回归问题
系列博客,原文在笔者所维护的github上:https://aka.ms/beginnerAI, 点击star加星不要吝啬,星越多笔者越努力. 4.3 神经网络法 在梯度下降法中,我们简单讲述了一下神 ...
- 大型情感剧集Selenium:4_老中医教你(单/多/下拉框)选项定位 #华为云·寻找黑马程序员#
今天讲什么 讲什么标题说了,讲selenium的单选.多选.下拉框选项定位.但其实这东西,没什么太多说的,又比较枯燥,那该怎么让这一集selenium的课程变得有趣呢?有请老中医,哈哈- 怎么样,这个 ...
- v-bind和v-model的本质区别和作用域
每篇一句 一场寂寞凭谁诉.算前言,总轻负. Vue视图数据展示方式和彼此的区别: {{插值表达式}} {{}}插值表达式里面 只能写表达式,不能写语句 文本输出,不会解析标签 不能作用在标签的属性上, ...
- 转:领域模型中的实体类分为四种类型:VO、DTO、DO、PO
经常会接触到VO,DO,DTO的概念,本文从领域建模中的实体划分和项目中的实际应用情况两个角度,对这几个概念进行简析.得出的主要结论是:在项目应用中,VO对应于页面上需要显示的数据(表单),DO对应于 ...
- 解密国内BAT等大厂前端技术体系-阿里篇(长文建议收藏)
进入2019年,大前端技术生态似乎进入到了一个相对稳定的环境,React在2013年发布至今已经6年时间了,Vue 1.0在2015年发布,至今也有4年时间了. 整个业界在前端框架不断迭代中,也寻找到 ...
- docker等文档
docker strapi koa express
- UESTC-1963咸鱼咕咕咕(二分图匹配)
咸鱼咕咕咕 Time Limit: 1000 MS Memory Limit: 64 MB Submit Status 咸鱼有个咕咕笼. 咕咕笼可以划分成m×nm×n个格子,每个小格子可以放下 ...
- webpack(四) --css样式及图片打包
一.CSS样式打包 1. loader简介 由于Webpack打包入口目前只配置了一个index.js文件,那么其他需要被打包的文件都必须通过模块化方式引入该文件才行,而默认情况下,引入的文件必须是j ...
- [知也无涯]GAN对人脸算法的影响
红绣被,两两间鸳鸯.不是鸟中偏爱尔,为缘交颈睡南塘.全胜薄情郎. 看到一篇GAN对人脸图像算法的影响,决心学习一个. 人脸检测 这也是我最关注的模块.文章推荐了极小面部区域人脸识别Finding ti ...