zookeeper+kafka集群


------------------------------------
zookeper:
59.110.173.251(xianshang  ssq)   /home/appinstall/zookeeper-3.4.9
47.94.133.25   (xianshang 5M host)/home/songlk/appinstall/zookeeper-3.4.9
60.205.136.57 (jsfund)  /home/songlk/appinstall/zookeeper-3.4.9


zoo.cfg:

dataDir=/home/centos/zookeeper


server.1=59.110.173.251:2888:3888
server.2=47.94.133.25:2888:3888
server.3=60.205.136.57:2888:3888


写集群文件
echo 1 > /home/centos/zookeeper/myid

echo 2 > /home/centos/zookeeper/myid

echo 3 > /home/centos/zookeeper/myid

--------------

iptables -A INPUT -p tcp --dport 2181 -j ACCEPT

iptables -A INPUT -p tcp --dport 2888 -j ACCEPT

iptables -A INPUT -p tcp --dport 3888 -j ACCEPT


分别启动
59.110.173.251
/home/appinstall/zookeeper-3.4.9/bin/zkServer.sh start
47.94.133.25
/home/songlk/appinstall/zookeeper-3.4.9/bin/zkServer.sh start
60.205.136.57
/home/songlk/appinstall/zookeeper-3.4.9/bin/zkServer.sh start

查看leader与slave状态

/home/appinstall/zookeeper-3.4.9/bin/zkServer.sh status

/home/songlk/appinstall/zookeeper-3.4.9/bin/zkServer.sh status
 
/home/songlk/appinstall/zookeeper-3.4.9/bin/zkServer.sh status

-----

flume


/home/songlk/appinstall/flume

----

kafka

59.110.173.251(xianshang  ssq)

/home/appinstall/kafka

47.94.133.25   (xianshang 5M host)

/home/songlk/appinstall/kafka

60.205.136.57( jsfund)

/home/songlk/appinstall/kafka

配置server.properties

broker.id=251

listeners=PLAINTEXT://:9092

log.dirs=/home/appinstall/kafka/kafka-logs

zookeeper.connect=59.110.173.251:2181,47.94.133.25:2181,60.205.136.57:2181


broker.id=25
listeners=PLAINTEXT://:9092

log.dirs=/home/songlk/appinstall/kafka/kafka-logs

 zookeeper.connect=59.110.173.251:2181,47.94.133.25:2181,60.205.136.57:2181

broker.id=57

listeners=PLAINTEXT://:9092

log.dirs=/home/songlk/appinstall/kafka/kafka-logs

zookeeper.connect=59.110.173.251:2181,47.94.133.25:2181,60.205.136.57:2181

----
producer.properties
59.110.173.251:9092,47.94.133.25:9092,60.205.136.57:9092

启动kafka

/home/appinstall/kafka/bin/kafka-server-start.sh -daemon /home/appinstall/kafka/config/server.properties

/home/songlk/appinstall/kafka/bin/kafka-server-start.sh -daemon /home/songlk/appinstall/kafka/config/server.properties

/home/songlk/appinstall/kafka/bin/kafka-server-start.sh -daemon /home/songlk/appinstall/kafka/config/server.properties

关闭

/home/appinstall/kafka/bin/kafka-server-stop.sh

/home/songlk/appinstall/kafka/bin/kafka-server-stop.sh

/home/songlk/appinstall/kafka/bin/kafka-server-stop.sh

启动异常:

There is insufficient memory for the Java Runtime Environment to continue.

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"

------------------------

./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test

8.创建主题 
        $>/home/appinstall/kafka/bin/kafka-topics.sh --create --zookeeper 59.110.173.251:2181 --replication-factor 3 --partitions 3 --topic test

[root@iz2zej15counp893693urlz bin]# /home/appinstall/kafka/bin/kafka-topics.sh --create --zookeeper 59.110.173.251:2181 --replication-factor 3 --partitions 3 --topic test
Created topic "test".

    9.查看主题列表
        $>/home/appinstall/kafka/bin/kafka-topics.sh --list --zookeeper 59.110.173.251:2181

/home/songlk/appinstall/kafka/bin/kafka-topics.sh --list --zookeeper 59.110.173.251:2181
/home/songlk/appinstall/kafka/bin/kafka-topics.sh --list --zookeeper 59.110.173.251:2181


[root@iz2zej15counp893693urlz bin]# /home/appinstall/kafka/bin/kafka-topics.sh --list --zookeeper 59.110.173.251:2181
test


    10.启动控制台生产者
 /home/songlk/appinstall/kafka/bin/kafka-console-producer.sh --broker-list 60.205.136.57:9092 --topic test

    11.启动控制台消费者
  /home/songlk/appinstall/kafka/bin/kafka-console-consumer.sh --bootstrap-server 60.205.136.57:9092 --topic test --from-beginning --zookeeper 60.205.136.57:2181

 ====================

 

 

    12.在生产者控制台输入hello world

--------------------------------------------------------------------------------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值