linux kafka集群 安装

下载地址:
http://kafka.apache.org/downloads
wget https://archive.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz

cd /data1/soft/kafka_2.11-2.1.0
mkdir -p logs

[root@datanode4 config]# pwd
/data1/soft/kafka_2.11-2.1.0/config

修改配置文件server.properties:

broker.id=0
port=9092
log.dirs=/data1/soft/kafka_2.11-2.1.0/logs
zookeeper.connect=datanode4:2181,datanode5:2181,datanode6:2181

分发:

[root@datanode4 soft]# scp -r kafka_2.11-2.1.0/ root@datanode5:/data1/soft/
[root@datanode4 soft]# scp -r kafka_2.11-2.1.0/ root@datanode6:/data1/soft/

在datanode5上修改server.properties

broker.id=1

在datanode6上修改server.properties

broker.id=2

在每台机器上启动:

[root@datanode4 kafka_2.11-2.1.0]# ./bin/kafka-server-start.sh -daemon ./config/server.properties
[root@datanode5 kafka_2.11-2.1.0]# ./bin/kafka-server-start.sh -daemon ./config/server.properties
[root@datanode6 kafka_2.11-2.1.0]# ./bin/kafka-server-start.sh -daemon ./config/server.properties

创建topic

[root@datanode4 bin]# ./kafka-topics.sh --create --zookeeper datanode4:2181,datanode5:2181,datanode6:2181 --replication-factor 3 --partitions 3 --topic mytopic
Created topic "mytopic".
[root@datanode4 bin]# ./kafka-topics.sh --describe --zookeeper localhost:2181 --topic mytopic
Topic:mytopic	PartitionCount:3	ReplicationFactor:3	Configs:
	Topic: mytopic	Partition: 0	Leader: 1	Replicas: 1,2,0	Isr: 1,2,0
	Topic: mytopic	Partition: 1	Leader: 2	Replicas: 2,0,1	Isr: 2,0,1
	Topic: mytopic	Partition: 2	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2
[root@datanode4 bin]# ./kafka-topics.sh --list --zookeeper datanode4:2181

kafka的bin目录下启动生产者和消费者

./kafka-console-producer.sh --broker-list localhost:9092 --topic mytopic
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic mytopic

http://kafka.apache.org/21/documentation.html#quickstart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值