kafka单机安装配置
1、下载kafka
wget https://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.2.1/kafka_2.9.2-0.8.2.1.tgz
2、解压
tar -zxf kafka_2.9.2-0.8.2.1.tgz
创建软连接
ln -s /opt/workspace/apps/kafka_2.10-0.8.2.1 /opt/workspace/kafka
3、修改配置文件
(1)kafka配置文件
cd /opt/workspace/kafka/config vim server.properties ############################# Server Basics ############################# # The id of the broker. This must be set to a unique integer for each broker.
broker.id=0 ############################# 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
# 修改为主机ip,不然服务器返回给客户端的是主机的hostname,客户端并不一定能够识别
host.name=10.205.28.4 ############################# Log Basics ############################# # A comma seperated list of directories under which to store log files
# 日志目录
log.dirs=/var/log/kafka #zookeeper地址和端口
zookeeper.connect=localhost:2181
(2)zookeeper配置
vim zookeeper.properties
# the directory where the snapshot is stored.
dataDir=/var/zookeeper
dataLogDir=/var/log/zookeeper
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=100 # 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
具体解释请参考:http://nanchengru.com/2015/04/zookeeper%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE%E4%BB%A5%E5%8F%8A%E5%91%BD%E4%BB%A4/
4、启动zookeeper和kafka
写了个脚本
#!/bin/sh #启动zookeeper
zookeeper-server-start.sh ../config/zookeeper.properties > /var/log/zookeeper/zk-server-start.log & #休眠3秒
sleep 3 #等3秒后执行下一条 #启动kafka
kafka-server-start.sh ../config/server.properties > /var/log/kafka/kafka-server-start.log &
5、使用kafka
Step 3: Create a topic(创建主题:test) Let's create a topic named "test" with a single partition and only one replica:
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
We can now see that topic if we run the list topic command:
> bin/kafka-topics.sh --list --zookeeper localhost:2181
test
Alternatively, instead of manually creating topics you can also configure your brokers to auto-create topics when a non-existent topic is published to.
Step 4: Send some messages Kafka comes with a command line client that will take input from a file or from standard input and send it out as messages to the Kafka cluster. By default each line will be sent as a separate message.
Run the producer and then type a few messages into the console to send to the server. > bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message
Step 5: Start a consumer Kafka also has a command line consumer that will dump out messages to standard output.
> bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
This is a message
This is another message
心得总结:
1.produce启动的时候参数使用的是kafka的端口而consumer启动的时候使用的是zookeeper的端口;
2.必须先创建topic才能使用;
3.topic本质是以文件的形式储存在zookeeper上的。
参考:
http://kafka.apache.org/documentation.html#quickstart
http://www.tuicool.com/articles/uQzYfq
kafka单机安装配置的更多相关文章
- Linux下Kafka单机安装配置方法(图文)
Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢 介绍 Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了 ...
- Linux下Kafka单机安装配置方法
Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢? 首先让我们看几个基本的消息系统术语: •Kafka将消息以topi ...
- Linux下Kafka单机安装配置
安装jdkJDK版本大于1.8 安装kafkatar -zxvf kafka_2.11-0.10.2.1.tgz mv kafka_2.11-0.10.2.1 /usr/local/kafka 配置k ...
- Linux系统消息队列框架Kafka单机安装配置
http://www.ithao123.cn/content-11128587.html
- Kafka单机安装Version1.0.1(自带Zookeeper)
1.说明 Kafka单机安装,基于版本1.0.1, 使用kafka_2.12-1.0.1.tgz安装包, 其中2.12是编译工具Scala的版本. 而且不需要另外安装Zookeeper服务, 使用Ka ...
- kafka manager安装配置和使用
kafka manager安装配置和使用 .安装yum源 curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintra ...
- Ubuntu 16下单机安装配置zookeeper和kafka
网上其他的没有一个能直接照做完成的,我这个也是看了些帖子,整出来的怕以后忘记 建议连接工具:Bitvise SSH Client 一.安装配置zookeeper 下载zookeeper 3.4.13: ...
- Hadoop单机安装配置过程:
1. 首先安装JDK,必须是sun公司的jdk,最好1.6版本以上. 最后java –version 查看成功与否. 注意配置/etc/profile文件,在其后面加上下面几句: export JAV ...
- CentOS下 RabbitMQ单机安装配置
CentOS RabbitMQ rpm 安装方法: 系统环境:CentOS6IP地址:10.100.62.41 1.erlang安装: erlang下载地址: http://www.rabbitmq. ...
随机推荐
- JavaScript HTML DOM EventListener
JavaScript HTML DOM EventListener addEventListener() 方法 实例 点用户点击按钮时触发监听事件: document.getElementById(& ...
- Tomcat 8熵池阻塞变慢详解(转)
Tomcat 8熵池阻塞变慢详解 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs Tomcat 8启动很慢,且日志上无任何错误,在日志中查看到如下信息: ...
- ECSHOP错误Redefining already defined constructor for class如何解决
本地PHP环境PHP5.4,安装ecshop2.7.3后,很多地方会报如下的错 Redefining already defined constructor for class XXX 使用和类名相同 ...
- bzoj2127: happiness
Description 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了,每个同学对于选择文科与理科有着自己的喜悦值,而一对好朋友 ...
- Oracle数据库基础知识_字符串操作相关2
6.LPAD,RPAD 作用:左/右边的字符串填充一些特定的字符语法: LPAD(string , n, [pad_String]) string:可是字符或者参数 ...
- nginx下搭建fastcgi的开发环境
在上一章最简单理解CGI,FastCGI,WSGI 我们将fastcgi规范类比HTTP.下面我们通过一个案例更加明白fastcgi 我们使用的是 nginx作为前端 代理,我们包装了gevent_ ...
- Unity问答——NGUI怎么使用按键模拟鼠标点击?
这篇博客源自我在泰课在线的回答.链接:http://www.taikr.com/group/1/thread/248 问:NGUI怎么模拟用代码模拟控制点击 答: 1. 这个问题问得好.因为在使用按键 ...
- Node.js包(JXcore)
Node.js的代码是开放的,并准备好被复制像任何其他Javascript代码.但现在它不可能的了.JXcore 这是一个开源项目,引入了包装和源文件和其他资源加密成JX包一个独特的功能. 考虑大型项 ...
- QT 线程暂停,继续执行的一种实现(有些道理,而且封装了)
注意:本次实现线程的暂停执行主要采用互斥量的方法,如果有更好的实现方法的小伙伴可以在下面留言! 直接插入代码了,由于做的小demo,代码写的可能有点乱,但还算完整. 1 2 3 4 5 6 7 8 9 ...
- java学习之常量与进制
java中的常量包括以下几类: 1.整型常量,比如:3,5,89,99 2.浮点型常量:比如1.23,5.98,3.1415926 3,字符常量:'a','c','1'(需要注意的一点是字符常量只能包 ...