文档章节

kafka自动化安装配置

厉力文武
 厉力文武
发布于 2017/02/20 09:10
字数 1110
阅读 48
收藏 0

#!/bin/bash

#/usr/local/kafka0/bin/kafka-server-start.sh -daemon /usr/local/kafka0/config/server.properties &
#/usr/local/kafka1/bin/kafka-server-start.sh -daemon /usr/local/kafka1/config/server.properties &
#/usr/local/kafka2/bin/kafka-server-start.sh -daemon /usr/local/kafka2/config/server.properties &

setup_dir="/usr/local/"
kafkaVersion="kafka_2.11-0.9.0.1"
localIP=`ifconfig |awk -F'[: ]+' NR==2'{print $4}'`

cd $setup_dir
wget http://mirror.bit.edu.cn/apache/kafka/0.9.0.1/kafka_2.11-0.9.0.1.tgz

tar zxvf ${kafkaVersion}.tgz

mv ${kafkaVersion}/config/server.properties ${kafkaVersion}/config/server.properties.bak
mkdir ${kafkaVersion}/logs

cp -a ${kafkaVersion} kafka0
cp -a ${kafkaVersion} kafka1
cp -a ${kafkaVersion} kafka2

echo "# kafka" >>/etc/rc.local
echo "nohup /usr/local/kafka0/bin/kafka-server-start.sh /usr/local/kafka0/config/server.properties &" >>/etc/rc.local
echo "nohup /usr/local/kafka1/bin/kafka-server-start.sh /usr/local/kafka1/config/server.properties &" >>/etc/rc.local
echo "nohup /usr/local/kafka2/bin/kafka-server-start.sh /usr/local/kafka2/config/server.properties &" >>/etc/rc.local
#################################################################################################################
#################################################################################################################

cat >> ${setup_dir}kafka0/config/server.properties << eof
############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0

############################# Socket Server Settings #############################

listeners=PLAINTEXT://:9092
# 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=$localIP

# The number of threads handling network requests
num.network.threads=3

# 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=${setup_dir}kafka0/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=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

############################# 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

# 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 #############################


# root directory for all kafka znodes.
zookeeper.connect=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
eof

#################################################################################################################
#################################################################################################################


cat >> ${setup_dir}kafka1/config/server.properties << eof
############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=1

############################# Socket Server Settings #############################

listeners=PLAINTEXT://:9093
# The port the socket server listens on
port=9093

# Hostname the broker will bind to. If not set, the server will bind to all interfaces
host.name=$localIP

# The number of threads handling network requests
num.network.threads=3

# 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=${setup_dir}kafka1/logs

# the brokers.
num.partitions=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

############################# Log Retention Policy #############################

# The minimum age of a log file to be eligible for deletion
log.retention.hours=168


# 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 #############################

# root directory for all kafka znodes.
zookeeper.connect=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
eof


#################################################################################################################
#################################################################################################################


cat >> ${setup_dir}kafka2/config/server.properties << eof
############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=2

############################# Socket Server Settings #############################

listeners=PLAINTEXT://:9094
# The port the socket server listens on
port=9094

# Hostname the broker will bind to. If not set, the server will bind to all interfaces
host.name=$localIP

# The number of threads handling network requests
num.network.threads=3

# 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=${setup_dir}kafka2/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=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

############################# Log Retention Policy #############################

# The minimum age of a log file to be eligible for deletion
log.retention.hours=168

# 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 #############################

# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# root directory for all kafka znodes.
zookeeper.connect=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
eof

rm -rf ${kafkaVersion}
 

© 著作权归作者所有

厉力文武
粉丝 30
博文 86
码字总数 81619
作品 0
朝阳
程序员
私信 提问
OpenStack 上搭建 Kafka 集群

最近在 OpenStack 环境下需要部署消息队列集群,包括 RabbitMQ 和 Kafka,这篇记述一下 Kafka 集群的部署过程。 本文所用的环境包括: 软件版本 OpenStack 版本: Pike release Kafka 版本:2...

blackpiglet
2018/10/15
0
0
Java Spring Boot 2.0实战百万级Kafka消息中间件与原理解析

Apache Kafka是开源分布式高并发消息中间件,支持每秒百万级消息并发,在互联网高并发架构:双11、电商秒杀抢购、网络直播、IOT大数据采集、聊天App、导航等高并发架构中大量使用。本节课程一...

徐雷frank
02/19
0
0
离线网络环境下一键式部署

关键词 封闭网络:一个相对封闭的网络环境,仅可以使用有限的资源如:maven镜像仓库、Centos/Ubuntu源等,无法连接互联网的网络环境。 一键部署:这里所说的“一键式部署”不仅仅是指这样的场...

ThoughtWorks中国
2017/12/29
0
0
Kafka 资源分配自动调整系统--Cruise Control

Cruise Control 是首个将 Kafka 群集的动态工作负载重新平衡和自动分配的全自动化系统。通过简化 Kafka 集群的运作,为用户提供了极大的便利。 Cruise Control 是用于持续监视 Kafka 集群并根...

匿名
2017/08/31
504
0
云+社区技术沙龙 Kafka meetup 深圳站

如果说 2018 年是技术大爆炸年,那么 Apache Kafka 绝对是其中闪亮的新星。 自Kafka 从首发之日起,已经走过了快八个年头。Kafka 已经从最开始的大规模消息系统,发展成为功能完善的分布式流...

吉衣OSC
2018/04/02
528
0

没有更多内容

加载失败,请刷新页面

加载更多

哪些情况下适合使用云服务器?

我们一直在说云服务器价格适中,具备弹性扩展机制,适合部署中小规模的网站或应用。那么云服务器到底适用于哪些情况呢?如果您需要经常原始计算能力,那么使用独立服务器就能满足需求,因为他...

云漫网络Ruan
今天
5
0
Java 中的 String 有没有长度限制

转载: https://juejin.im/post/5d53653f5188257315539f9a String是Java中很重要的一个数据类型,除了基本数据类型以外,String是被使用的最广泛的了,但是,关于String,其实还是有很多东西...

低至一折起
今天
17
0
OpenStack 简介和几种安装方式总结

OpenStack :是一个由NASA和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目。项目目标是提供实施简单、可大规模扩展、丰富、标准统一的云计算管理平台。OpenSta...

小海bug
昨天
11
0
DDD(五)

1、引言 之前学习了解了DDD中实体这一概念,那么接下来需要了解的就是值对象、唯一标识。值对象,值就是数字1、2、3,字符串“1”,“2”,“3”,值时对象的特征,对象是一个事物的具体描述...

MrYuZixian
昨天
9
0
解决Mac下VSCode打开zsh乱码

1.乱码问题 iTerm2终端使用Zsh,并且配置Zsh主题,该主题主题需要安装字体来支持箭头效果,在iTerm2中设置这个字体,但是VSCode里这个箭头还是显示乱码。 iTerm2展示如下: VSCode展示如下: 2...

HelloDeveloper
昨天
9
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部