【转】flume+kafka+zookeeper 日志收集平台的搭建
首先说明下我的目的是什么,我的目的是单纯的收集nginx的日志以及各种应用程序的日志
nginx 日志
预留的位置
flume 和 kafka这个大小的作用是什么我就不再说了,大家去自己搜下
一 。 环境
AWS Red Hat Enterprise Linux Server release 7.1 (Maipo)
二。 需要的应用包
apache-flume-1.6.0-bin.tar.gz
kafka_2.10-0.8.1.1.tgz
jdk-7u67-linux-x64.tar.gz
KafkaOffsetMonitor-assembly-0.2.0.jar
kafka-manager-1.2.3.zip
zookeeper-3.4.7.tar.gz
三。 搭建
先看看我们host的配置
192.168.1.10 zoo1 zoo2 zoo3 kafka_1 kafka_2 kafka_3
ls /opt/tools/
apache-tomcat-7.0.65 flume jdk1.7.0_67 kafka nginx redis-3.0.5 zookeeper
1.安装zookeeper
zookeeper 的配置比较简单。
部署3个zookeeper
配置文件举例
ls
zoo1 zoo2 zoo3 zkui
最后这个是zookeeper的WEB管理
cat master/conf/
configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg
[root@ip-172-31-9-125 zookeeper]# cat master/conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/tool/zookeeper/zoo1/data
dataLogDir=/opt/tools/zookeeper/zoo1/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.0=zoo1:8880:7770
server.1=zoo2:8881:7771
server.2=zoo3:8882:7772
分别启动3个zk 这里就不再说了
2. kafka
ls
kafka_1 kafka_2 kafka_3 kafka-manager-1.2.3 kafkaOffsetMonitor kfkstart.sh
cat kfkstart.sh
#!/bin/bash
nohup /opt/tools/kafka/kafka_1/bin/kafka-server-start.sh /opt/tools/kafka/kafka_1/config/server.properties &
nohup /opt/tools/kafka/kafka_2/bin/kafka-server-start.sh /opt/tools/kafka/kafka_2/config/server.properties &
nohup /opt/tools/kafka/kafka_3/bin/kafka-server-start.sh /opt/tools/kafka/kafka_3/config/server.properties &
nohup /opt/tools/kafka/kafka-manager-1.2.3/bin/kafka-manager -Dkafka-manager.zkhosts="zoo1:2181,zoo2:2182,zoo3:2183" &
cat /opt/tools/kafka/kafka_1/config/server.properties
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0 #这个很重要 就是唯一的ID号
############################# Socket Server Settings #############################
# The port the socket server listens on
port=9092 #监听的端口
# Hostname the broker will bind to. If not set, the server will bind to all interfaces
host.name=kafka_1 #这里看清楚我们的前面配置的机器名啊
# Hostname the broker will advertise to producers and consumers. If not set, it uses the
# value for "host.name" if configured. Otherwise, it will use the value returned from
# java.net.InetAddress.getCanonicalHostName().
#advertised.host.name=<hostname routable by clients>
# The port to publish to ZooKeeper for clients to use. If this is not set,
# it will publish the same port that the broker binds to.
#advertised.port=<port accessible by clients>
# The number of threads handling network requests
num.network.threads=2
# The number of threads doing disk I/O
num.io.threads=8
# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400
# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400
# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600
############################# Log Basics #############################
# A comma seperated list of directories under which to store log files
log.dirs=/opt/tools/kafka/kafka_1/logs
# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=2
############################# Log Flush Policy #############################
# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000
# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000
############################# Log Retention Policy #############################
# The minimum age of a log file to be eligible for deletion
log.retention.hours=168
# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
# segments don't drop below log.retention.bytes.
#log.retention.bytes=1073741824
# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824
# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000
# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires.
# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction.
log.cleaner.enable=false
############################# Zookeeper #############################
# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=zoo1:2181,zoo2:2182,zoo3:2183
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
启动kafka
配置位偏移量工具
ls kafkaOffsetMonitor
KafkaOffsetMonitor-assembly-0.2.0.jar logs offsetapp.db start.sh
cat kafkaOffsetMonitor/start.sh
#!/bin/bash
nohup java -cp KafkaOffsetMonitor-assembly-0.2.0.jar com.quantifind.kafka.offsetapp.OffsetGetterWeb --zk zoo1:2181,zoo2:2182,zoo3:2183 --port 8087 --refresh 10.seconds --retain 1.days 1>logs/stdout.log 2>logs/stderr.log &
kafka 管理工具
cat kafka-manager-1.2.3/conf/application.conf
# Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
# See accompanying LICENSE file.
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="changeme"
application.secret=${?APPLICATION_SECRET}
# The application languages
# ~~~~~
application.langs="en"
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# global=Global
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=
#
# You can expose this datasource via JNDI if needed (Useful for JPA)
# db.default.jndiName=DefaultDS
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
# Ebean configuration
# ~~~~~
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
#
# ebean.default="models.*"
# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
# Root logger:
logger.root=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
kafka-manager.zkhosts="zoo1:2181,zoo2:2182,zoo3:2183"
kafka-manager.zkhosts=${?ZK_HOSTS}
pinned-dispatcher.type="PinnedDispatcher"
pinned-dispatcher.executor="thread-pool-executor"
3 flume
(1)目录模式 以及 exec模式
cat conf/flume-conf.properties
#定义agent的名字为statge_nginx
stage_nginx.sources = S1
stage_nginx.channels = M1
stage_nginx.sinks = sink
#定义source的一些设置 我在这里写了2个模式
stage_nginx.sources.S1.type = spooldir #目录模式
stage_nginx.sources.S1.channels = M1
stage_nginx.sources.S1.spoolDir = /logs/nginx/log/shop #nginx 日志目录
#stage_nginx.sources.S1.type = exec #SH模式
#stage_nginx.sources.S1.channels = M1
#stage_nginx.sources.S1.command = tail -F /logs/nginx/log/shop/access.log #执行命令 如果我们有很多日志,那么久多启动几个flume吧。。。没想到其他的办法
#定义sink
stage_nginx.sinks.sink.type = org.apache.flume.sink.kafka.KafkaSink
stage_nginx.sinks.sink.topic = test #!!!!自己创建的tpoic
stage_nginx.sinks.sink.brokerList = kafka_1:9092,kafka_2:9093,kafka_3:9094
stage_nginx.sinks.sink.requiredAcks = 0
stage_nginx.sinks.sink.batchSize = 20
stage_nginx.sinks.sink.channel = M1
#定义channel
stage_nginx.channels.M1.type = memory
stage_nginx.channels.M1.capacity = 100
# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
./bin/flume-ng agent -c /opt/tools/flume/conf/ -f /opt/tools/flume/conf/flume-conf.properties -n stage_nginx 启动flume
搜索python kafka consumer 来编写一个消费的程序
【转】flume+kafka+zookeeper 日志收集平台的搭建的更多相关文章
- ELK+Kafka 企业日志收集平台(一)
背景: 最近线上上了ELK,但是只用了一台Redis在中间作为消息队列,以减轻前端es集群的压力,Redis的集群解决方案暂时没有接触过,并且Redis作为消息队列并不是它的强项:所以最近将Redis ...
- ELK+kafka构建日志收集系统
ELK+kafka构建日志收集系统 原文 http://lx.wxqrcode.com/index.php/post/101.html 背景: 最近线上上了ELK,但是只用了一台Redis在 ...
- 基于Flume的美团日志收集系统(一)架构和设计
美团的日志收集系统负责美团的所有业务日志的收集,并分别给Hadoop平台提供离线数据和Storm平台提供实时数据流.美团的日志收集系统基于Flume设计和搭建而成. <基于Flume的美团日志收 ...
- 基于Flume的美团日志收集系统(一)架构和设计【转】
美团的日志收集系统负责美团的所有业务日志的收集,并分别给Hadoop平台提供离线数据和Storm平台提供实时数据流.美团的日志收集系统基于Flume设计和搭建而成. <基于Flume的美团日志收 ...
- 转:基于Flume的美团日志收集系统(一)架构和设计
美团的日志收集系统负责美团的所有业务日志的收集,并分别给Hadoop平台提供离线数据和Storm平台提供实时数据流.美团的日志收集系统基于Flume设计和搭建而成. <基于Flume的美团日志收 ...
- 基于Flume的美团日志收集系统 架构和设计 改进和优化
3种解决办法 https://tech.meituan.com/mt-log-system-arch.html 基于Flume的美团日志收集系统(一)架构和设计 - https://tech.meit ...
- 基于Flume的美团日志收集系统(二)改进和优化
在<基于Flume的美团日志收集系统(一)架构和设计>中,我们详述了基于Flume的美团日志收集系统的架构设计,以及为什么做这样的设计.在本节中,我们将会讲述在实际部署和使用过程中遇到的问 ...
- .NET Core使用NLog通过Kafka实现日志收集
微服务日志之.NET Core使用NLog通过Kafka实现日志收集 https://www.cnblogs.com/maxzhang1985/p/9522017.html 一.前言 NET Core ...
- 利用ELK构建一个小型的日志收集平台
利用ELK构建一个小型日志收集平台 伴随着应用以及集群的扩展,查看日志的方式总是不方便,我们希望可以有一个便于我们查询及提醒功能的平台:那么首先需要剖析有几步呢? 格式定义 --> 日志收集 - ...
随机推荐
- bzoj4401: 块的计数
首先,块的大小确定的话,可以发现方案最多只有1种 然后就可以O(nsqrt(n))搞,不过会TLE 接着我们又发现,一个节点可以作一个块的根,当且仅当该节点的size能被块的大小整除 然后就可以O(n ...
- 绘制图形与3D增强技巧(二)----直线图元
一. glBegin(GL_LINES); glend(); 二.线带和线环 glBegin(GL_LINE_STRIP); glend(); glBegin(GL_LINE_LOOP); glend ...
- Hive 窗口函数、分析函数
1 分析函数:用于等级.百分点.n分片等 Ntile 是Hive很强大的一个分析函数. 可以看成是:它把有序的数据集合 平均分配 到 指定的数量(num)个桶中, 将桶号分配给每一行.如果不能平均分配 ...
- 【UOJ#33】【UR#2】树上GCD 有根树点分治 + 容斥原理 + 分块
#33. [UR #2]树上GCD 有一棵$n$个结点的有根树$T$.结点编号为$1…n$,其中根结点为$1$. 树上每条边的长度为$1$.我们用$d(x,y)$表示结点$x,y$在树上的距离,$LC ...
- BLOG搬家
前段时间一直用的新浪blog,发现推送信息是否杂乱,所以特地投奔学长CSDN,外加之前颓废心过重,现在打算新面貌认真学习
- UTF-8有签名和无签名的区别
当有签名的UTF-8编码内容被解析器解析时,解析器直接根据签名即可判断出使用UTF-8编码来进行解析,当无签名时,解析器会根据内容的编码来进行判别.所以,有签名的将更容易被解析器以正确的编码方式进行解 ...
- Myeclipse 加载ojdbc14.jar步骤
目的:加载驱动程序,需要找到驱动的具体位置,就是找到其驱动的类名,Class.forName("oracle.jdbc.driver.OracleDriver");//加载并注册驱 ...
- gvim e303 无法打开 “[未命名]“的交换文件,恢复将不可能
今天vim出现:“gvim e303 无法打开 “[未命名]“的交换文件,恢复将不可能” 解决办法: 修改你的.vimrc,增加下面的一行: set directory=.,$TEMP "默 ...
- 区别 Jquery对象和Dom对象
在讨论之前,先约定好定义变量的风格. 如果获取的对象是jQuery对象,那么在变量前加上$,例如: var $variable = jQuery对象; 如果获取的是DOM对象,则定义如下: var v ...
- 2 构建Mysql+heartbeat+DRBD+LVS集群应用系统系列之MySql的搭建
preface 上一节我们讲了DRBD的原理,以及如何部署DRBD,那么现在在上一节的基础上部署Mysql 安装并启动Mysql 为了方便,我一般采用yum安装Mysql.命令如下: 在172.16. ...