第二篇【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 ...
随机推荐
- Java架构师 成长之路 -- 跳出程序员陷阱(转载)
本人也是coding很多年,虽然很失败,但也总算有点失败的心得,不过我在中国,大多数程序员都是像我一样,在一直走着弯路. 如果想成为一个架构师,就必须走正确的路,否则离目标越来越远,正在辛苦工作的程序 ...
- [转帖]看完这篇文章,我奶奶都懂了https的原理
看完这篇文章,我奶奶都懂了https的原理 http://www.17coding.info/article/22 非对称算法 以及 CA证书 公钥 核心是 大的质数不一分解 还有 就是 椭圆曲线算法 ...
- 如何使用JavaScript实现前端导入和导出excel文件
一.SpreadJS 简介 SpreadJS 是一款基于 HTML5 的纯 JavaScript 电子表格和网格功能控件,以“高速低耗.纯前端.零依赖”为产品特色,可嵌入任何操作系统,同时满足 .NE ...
- java this的作用
this: 区分成员变量和局部变量的重名问题,this.name指的是类中的成员变量,而不是方法内部的
- Java中创建的对象多了,必然影响内存和性能
1, Java中创建的对象多了,必然影响内存和性能,所以对象的创建越少越好,最后还要记得销毁.
- PYQT5 pyinstaller 打包工程
win+R 输入cmd 回车 首先安装 pyinstaller : pip install pyinstaller 安装 pywin32: pip install pywin32 在cmd中输入工程 ...
- java之设计模式汇总
1.单例模式 就是一个类只产生一个对象 对应数据库连接 定时执行者服务(ScheduledExecutorService) 在整个项目中应该只有一个对象 2.工厂模式 定义一个用于创建对象的接口 让子 ...
- sql server truncate语句
truncate语句 --truncate table '表名' --这样就利用SQL语句清空了该数据表,而不保留日志
- 分布式的几件小事(六)dubbo如何做服务治理、服务降级以及重试
1.服务治理 服务治理主要作用是改变运行时服务的行为和选址逻辑,达到限流,权重配置等目的. ①调用链路自动生成 一个大型的分布式系统,会由大量的服务组成,那么这些服务之间的依赖关系和调用链路会很复杂, ...
- sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1366, "Incorrect string value: '\\xE6\\xB1\\x89\\xE8\\xAF\\xAD...' for column 'className' at row 1") [SQL: INSERT INTO classmessage (`classId
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1366, "Incorrect string value: '\\xE ...