第二篇【Zabbix客户端的完整布署】
关于Zabbix服务端布署请查看
1、上传zabbix安装包(源码包默认(Server和Agent是一起的))
[root@sms-v2 ~]# ll /root/
-rw-r--r-- root root 11月 : zabbix-4.4..tar.gz
2、安装依赖包
[root@sms-v2 ~]# yum install gcc gcc-c++ pcre-devel -y
3、创建运行用户
#创建组用户
[root@sms-v2 ~]# groupadd zabbix #创建用户
[root@sms-v2 ~]# useradd -g zabbix -M -s /sbin/nologin zabbix #检查是否创建成功
[root@sms-v2 ~]# id zabbix
uid=(zabbix) gid=(zabbix) 组=(zabbix)
4、软件的安装
#解压软件
[root@sms-v2 ~]# tar xvf zabbix-4.4..tar.gz #进入软件安装目录
[root@sms-v2 ~]# cd zabbix-4.4./ #安装软件
[root@sms-v2 zabbix-4.4.3]# ./configure --prefix=/data/application/zabbix-4.4.3 --enable-agent #编译安装
[root@sms-v2 zabbix-4.4.3]# make && make install #安装完成的目录
[root@sms-v2 zabbix-4.4.3]# tree /data/application/zabbix-4.4.3/
/data/application/zabbix-4.4.3/
├── bin
│ ├── zabbix_get
│ └── zabbix_sender
├── etc
│ ├── zabbix_agentd.conf
│ └── zabbix_agentd.conf.d
├── lib
│ └── modules
├── sbin
│ └── zabbix_agentd
└── share
└── man
├── man1
│ ├── zabbix_get.1
│ └── zabbix_sender.1
└── man8
└── zabbix_agentd.8
5、创建存放日志的目录
[root@sms-v2 zabbix-4.4.]# mkdir /data/application/zabbix-4.4./log
[root@sms-v2 zabbix-4.4.]# chown zabbix.zabbix /data/application/zabbix-4.4./log -R
6、编译zabbix Agent配置文件
[root@sms-v2 zabbix-4.4.3]# vi /data/application/zabbix-4.4.3/etc/zabbix_agentd.conf
...
# Mandatory: no
# Default:
# PidFile=/tmp/zabbix_agentd.pid
PidFile=/data/application/zabbix-4.4.3/log/zabbix_agentd.pid
### Option: LogType
# Specifies where log messages are written to:
# system - syslog
# file - file specified with LogFile parameter
# console - standard output
...
# Log file name for LogType 'file' parameter.
#
# Mandatory: yes, if LogType is set to file, otherwise no
# Default:
# LogFile= LogFile=/data/application/zabbix-4.4.3/log/zabbix_agentd.log #日志文件位置
### Option: LogFileSize
# Maximum size of log file in MB.
# - disable automatic log rotation.
#
# Mandatory: no
# Range: -
# Default:
# LogFileSize=
...
### Option: Server
# List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
# and '::/0' will allow any IPv4 or IPv6 address.
# '0.0.0.0/0' can be used to allow any IPv4 address.
# Example: Server=127.0.0.1,192.168.1.0/,::,:db8::/,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to
# Default:
# Server= Server=127.0.0.1,192.168.10.96 #Zabbix Server主动监控允许调用 ### Option: ListenPort
# Agent will listen on this port for connections from the server.
#
...
##### Active checks related ### Option: ServerActive
# List of comma delimited IP:port (or DNS name:port) pairs of Zabbix servers and Zabbix proxies for active checks.
# If port is not specified, default port is used.
# IPv6 addresses must be enclosed in square brackets if port for that host is specified.
# If port is not specified, square brackets for IPv6 addresses are optional.
# If this parameter is not specified, active checks are disabled.
# Example: ServerActive=127.0.0.1:,zabbix.domain,[::]:,::,[12fc::]
#
# Mandatory: no
# Default:
# ServerActive= ServerActive=192.168.10.96:10051 #Aget被动监控,即主机上传数据到Zabbix服务器
...
### Option: Hostname
# Unique, case sensitive hostname.
# Required for active checks and must match hostname as configured on the server.
# Value is acquired from HostnameItem if undefined.
#
# Mandatory: no
# Default:
# Hostname= Hostname=192.168.10.95 #配置主机名,建议配置为IP地址
...
### Option: User
# Drop privileges to a specific, existing user on the system.
# Only has effect if run as 'root' and AllowRoot is disabled.
#
# Mandatory: no
# Default:
User=zabbix #运行Agent的用户
...
### Option: Include
# You may include individual files or all files in a directory in the configuration file.
# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
# Mandatory: no
# Default:
# Include= # Include=/usr/local/etc/zabbix_agentd.userparams.conf
# Include=/usr/local/etc/zabbix_agentd.conf.d/
# Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
290 Include=/data/application/zabbix-4.4.3/etc/zabbix_agentd.conf.d/*.conf #配置文件的位置
...
7、编写zabbix Agent启动服务
[root@sms-v2 init.d]# cat /etc/init.d/zabbix_agentd
#!/bin/sh ##########################################################
###### Zabbix agent daemon init script
########################################################## zabbix_agentd_sbin=/data/application/zabbix-4.4./sbin/zabbix_agentd
zabbix_etc=/data/application/zabbix-4.4./etc/zabbix_agentd.conf
PidFile=/data/application/zabbix-4.4./log/zabbix_agentd.pid case $ in start)
$zabbix_agentd_sbin -c $zabbix_etc ;; stop)
kill -TERM `cat $PidFile` ;; restart)
$ stop
sleep
$ start
;; *)
echo "Usage: $0 start|stop|restart"
exit
esac
zabbix_agentd
#设置可执行权限
[root@sms-v2 ~]# chmod /etc/init.d/zabbix_agentd #zabbix agent开启、关闭、重启
[root@sms-v2 ~]# /etc/init.d/zabbix_agentd start
[root@sms-v2 ~]# /etc/init.d/zabbix_agentd stop
[root@sms-v2 ~]# /etc/init.d/zabbix_agentd restart #这里需要开启zabbix agent服务
8、查看zabbix agent日志
[root@sms-v2 ~]# tail -f /data/application/zabbix-4.4./log/zabbix_agentd.log
::101616.707 TLS support: NO
::101616.707 **************************
::101616.707 using configuration file: /data/application/zabbix-4.4./etc/zabbix_agentd.conf
::101616.707 agent # started [main process]
::101616.708 agent # started [collector]
::101616.709 agent # started [listener #]
::101616.710 agent # started [listener #]
::101616.710 agent # started [active checks #]
::101616.711 agent # started [listener #]
::101616.712 active check configuration update from [192.168.10.96:10051] started to fail (cannot connect to [[192.168.10.96]:10051]: [113] No route to host)
#这里的原因,因为zabbix服务端的端口没有在防火墙开放,导致agent连接不到服务端
#解决方法
#在zabbix服务端开放端口10051
[root@filestore-v2 ~]# firewall-cmd --permanent --add-port=10051/tcp
success
[root@filestore-v2 ~]# firewall-cmd --reload
success
agent端的服务器操作如下
[root@sms-v2 ~]# firewall-cmd --permanent --add-port=10050/tcp
success
[root@sms-v2 ~]# firewall-cmd --reload
success
再次查看日志
[root@sms-v2 ~]# tail -f /data/application/zabbix-4.4.3/log/zabbix_agentd.log
75987:20191224:101616.707 agent #0 started [main process]
75988:20191224:101616.708 agent #1 started [collector]
75991:20191224:101616.709 agent #4 started [listener #3]
75989:20191224:101616.710 agent #2 started [listener #1]
75992:20191224:101616.710 agent #5 started [active checks #1]
75990:20191224:101616.711 agent #3 started [listener #2]
75992:20191224:102216.927 active check configuration update from [192.168.10.96:10051] is working again
75992:20191224:102216.927 no active checks on server [192.168.10.96:10051]: host [192.168.10.95] not found
#解决方法:
这个原因,检查zabbix服务端的主机信息,是否跟当前的agent端的配置信息一样,比如主机名或IP地址在Server端与Agent端是否配置一样
9、在zabbix服务端利用自带的工具zabbix_get获取agent端的数据
#查看命令的使用方法
[root@filestore-v2 ~]# /data/application/zabbix-4.4./bin/zabbix_get --help
usage:
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address] -k item-key
zabbix_get -h
zabbix_get -V
General options:
-s --host host-name-or-IP 获取数据的IP地址
-p --port port-number 获取数据的端口 (默认端口: )
-I --source-address IP-address 指定该数据往哪个网口出去,这里主要是涉及多网卡的时候使用
-k --key item-key 指定监控项的key值
-h --help 查看帮忙文档
-V --version 显示当前agent版本 #获取主机CPU负载
[root@filestore-v2 ~]# /data/application/zabbix-4.4./bin/zabbix_get -s 192.168.10.95 -k "system.cpu.load[all,avg1]"
0.140000 #获取当前主机名
[root@filestore-v2 ~]# /data/application/zabbix-4.4./bin/zabbix_get -s 192.168.10.95 -k system.uname
Linux sms-v2 3.10.-.el7.x86_64 # SMP Fri Apr :: UTC x86_64
下一篇【Zabbix快速开始配置】请点击查看
第二篇【Zabbix客户端的完整布署】的更多相关文章
- 第一篇【Zabbix服务端的完整布署】
1.环境准备 服务器版本: [root@filestore-v2 ~]# cat /etc/redhat-release CentOS Linux release (Core) 内核版本: [root ...
- Zabbix 客户端安装教程(第二篇)
Zabbix 客户端安装教程 blog地址:http://www.cnblogs.com/caoguo [root@localhost ~]# yum install -y gcc make [roo ...
- openstack私有云布署实践【9.3 主从controller单向同步glance-image目录】
采用Rysnc单向同步,而不用双方实时同步,原因是在历史的运行过程中,我们发现,有些镜像包太大,当在主用的glance将镜像保存时,并不是一时半会就把镜像保存好,当主用在保存时,备用节点又在实时同步那 ...
- JDFS:一款分布式文件管理实用程序第二篇(更新升级、解决一些bug)
一 前言 本文是<JDFS:一款分布式文件管理实用程序>系列博客的第二篇,在上一篇博客中,笔者向读者展示了JDFS的核心功能部分,包括:服务端与客户端部分的上传.下载功能的实现,epoll ...
- 【第二篇】ASP.NET MVC快速入门之数据注解(MVC5+EF6)
目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...
- CentOS ASP.NET Core Runtime Jexus跨平台布署
.net core 开源和跨平台,能布署到当前主流的Windows,Linux,macOS 系统上.本篇我们将在 Linux 系统上使用 ASP.NET Core Runtime 和 Jexus 布署 ...
- 跟我学SpringCloud | 第二篇:注册中心Eureka
Eureka是Netflix开源的一款提供服务注册和发现的产品,它提供了完整的Service Registry和Service Discovery实现.也是springcloud体系中最重要最核心的组 ...
- [ 高并发]Java高并发编程系列第二篇--线程同步
高并发,听起来高大上的一个词汇,在身处于互联网潮的社会大趋势下,高并发赋予了更多的传奇色彩.首先,我们可以看到很多招聘中,会提到有高并发项目者优先.高并发,意味着,你的前雇主,有很大的业务层面的需求, ...
- 从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群)
从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...
随机推荐
- gulp时发生错误---------const { Math, Object } = primordials;
[问题描述] 执行完npm install后,对前台页面进行gulp操作时,报如下错误: const { Math, Object } = primordials; [错误日志] ***@**** M ...
- Swagger中paramType
paramType:表示参数放在哪个地方 header-->请求参数的获取:@RequestHeader(代码中接收注解) query-->请求参数的获取:@RequestPa ...
- [转帖]glib gslibc libc 的关系与区别
https://blog.csdn.net/Com_ma/article/details/78692092 [glibc 和 libc] glibc 和 libc 都是 Linux 下的 C 函数库. ...
- HDU 6662 Acesrc and Travel 换根DP,宇宙最傻记录
#include<bits/stdc++.h> typedef long long ll; using namespace std; const int maxn=1e6+50; cons ...
- Django 中事务的使用
目录 Django 中事务的使用 Django默认的事务行为 在HTTP请求上加事务 在View中实现事务控制 使用装饰器 使用context manager autocommit() commit_ ...
- Postman之前言
Postman是一款流行的接口api调试/测试工具.几乎可以发送大多数的HTTP请求. 1.依据开发提供的接口文档,对接口进行测试. 2.如果是自己学习,可以网上找一些免费的接口进行学习,或者抓包 - ...
- javaScript中 数组的新方法(reduce)
定义和用法 reduce() 方法接收一个函数作为累加器,数组中的每个值(从左到右)开始缩减,最终计算为一个值. reduce() 可以作为一个高阶函数,用于函数的 compose. 注意: redu ...
- vue-transition实现加入购物车效果及其他动画效果实现
vue提供了<transition></transition>和<transition-group></transition-group>实现元素状态的 ...
- NTL 库函数
NTL是一个高性能,可移植的C ++库,为任意长度的整数提供数据结构和算法; 可用于整数和有限域上的向量,矩阵和多项式; 可用于任意精度浮点运算. NTL为以下方面提供高质量的最先进算法实现: 任意长 ...
- Mybatis分页-利用Mybatis Generator插件生成基于数据库方言的分页语句,统计记录总数 (转)
众所周知,Mybatis本身没有提供基于数据库方言的分页功能,而是基于JDBC的游标分页,很容易出现性能问题.网上有很多分页的解决方案,不外乎是基于Mybatis本机的插件机制,通过拦截Sql做分页. ...