2、kafka伪分布多broker部署
[root@baozi kafka_2.10-0.8.2.1]# ll config总用量 32-rw-r--r--. 1 root root 1199 2月 27 06:02 consumer.properties-rw-r--r--. 1 root root 3846 2月 27 06:03 log4j.properties-rw-r--r--. 1 root root 2
·
[root@baozi kafka_2.10-0.8.2.1]# ll config
总用量 32-rw-r--r--. 1 root root 1199 2月 27 06:02 consumer.properties
-rw-r--r--. 1 root root 3846 2月 27 06:03 log4j.properties
-rw-r--r--. 1 root root 2228 2月 27 06:02 producer.properties
-rw-r--r--. 1 root root 5566 6月 20 20:35 server.properties
-rw-r--r--. 1 root root 3325 2月 27 06:02 test-log4j.properties
-rw-r--r--. 1 root root 993 2月 27 06:02 tools-log4j.properties
-rw-r--r--. 1 root root 1023 2月 27 06:02 zookeeper.properties
1、复制一份server.properties为server1.properties
[root@baozi kafka_2.10-0.8.2.1]# cp config/server.properties config/server1.properties
2、修改配置文件server1.properties:
broker.id=1
port=9040
log.dirs=/mykafka1/kafka-logs
3、启动多个broker:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-server-start.sh config/server.properties >/dev/null 2>&1 &
[root@baozi ~]# jps
2134 Kafka
2939 Jps
2028 QuorumPeerMain
[root@baozi ~]#
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-server-start.sh config/server1.properties >/dev/null 2>&1 &
会有两个kafka进程:
[root@baozi kafka_2.10-0.8.2.1]# jps
2134 Kafka
3014 Jps
2028 QuorumPeerMain
2961 Kafka
[root@baozi kafka_2.10-0.8.2.1]#
4、创建主题:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-topics.sh --create --zookeeper 192.168.1.200:2181 --replication-factor 1 --partitions 3 --topic test
[2015-06-20 21:28:20,773] INFO Accepted socket connection from /192.168.1.200:48550 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2015-06-20 21:28:20,782] INFO Client attempting to establish new session at /192.168.1.200:48550 (org.apache.zookeeper.server.ZooKeeperServer)
[2015-06-20 21:28:20,784] INFO Established session 0x14e10fd34b30015 with negotiated timeout 30000 for client /192.168.1.200:48550 (org.apache.zookeeper.server.ZooKeeperServer)
[2015-06-20 21:28:21,173] INFO Got user-level KeeperException when processing sessionid:0x14e10fd34b30015 type:setData cxid:0x3 zxid:0x7d txntype:-1 reqpath:n/a Error Path:/config/topics/test Error:KeeperErrorCode = NoNode for /config/topics/test (org.apache.zookeeper.server.PrepRequestProcessor)
[2015-06-20 21:28:21,205] INFO Got user-level KeeperException when processing sessionid:0x14e10fd34b30015 type:create cxid:0x4 zxid:0x7e txntype:-1 reqpath:n/a Error Path:/config/topics Error:KeeperErrorCode = NodeExists for /config/topics (org.apache.zookeeper.server.PrepRequestProcessor)
Created topic "test".
[2015-06-20 21:28:21,308] INFO Processed session termination for sessionid: 0x14e10fd34b30015 (org.apache.zookeeper.server.PrepRequestProcessor)
[2015-06-20 21:28:21,315] INFO Closed socket connection for client /192.168.1.200:48550 which had sessionid 0x14e10fd34b30015 (org.apache.zookeeper.server.NIOServerCnxn)
[2015-06-20 21:28:21,432] INFO Got user-level KeeperException when processing sessionid:0x14e10fd34b30000 type:create cxid:0x71 zxid:0x82 txntype:-1 reqpath:n/a Error Path:/brokers/topics/test/partitions/1 Error:KeeperErrorCode = NoNode for /brokers/topics/test/partitions/1 (org.apache.zookeeper.server.PrepRequestProcessor)
[2015-06-20 21:28:21,436] INFO Got user-level KeeperException when processing sessionid:0x14e10fd34b30000 type:create cxid:0x72 zxid:0x83 txntype:-1 reqpath:n/a Error Path:/brokers/topics/test/partitions Error:KeeperErrorCode = NoNode for /brokers/topics/test/partitions (org.apache.zookeeper.server.PrepRequestProcessor)
[2015-06-20 21:28:21,459] INFO Got user-level KeeperException when processing sessionid:0x14e10fd34b30000 type:create cxid:0x76 zxid:0x87 txntype:-1 reqpath:n/a Error Path:/brokers/topics/test/partitions/2 Error:KeeperErrorCode = NoNode for /brokers/topics/test/partitions/2 (org.apache.zookeeper.server.PrepRequestProcessor)
[2015-06-20 21:28:21,470] INFO Got user-level KeeperException when processing sessionid:0x14e10fd34b30000 type:create cxid:0x79 zxid:0x8a txntype:-1 reqpath:n/a Error Path:/brokers/topics/test/partitions/0 Error:KeeperErrorCode = NoNode for /brokers/topics/test/partitions/0 (org.apache.zookeeper.server.PrepRequestProcessor)
[root@baozi kafka_2.10-0.8.2.1]#
查看所有主题:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-topics.sh --list --zookeeper 192.168.1.200:2181
[2015-06-20 21:29:09,118] INFO Accepted socket connection from /192.168.1.200:48552 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2015-06-20 21:29:09,126] INFO Client attempting to establish new session at /192.168.1.200:48552 (org.apache.zookeeper.server.ZooKeeperServer)
[2015-06-20 21:29:09,128] INFO Established session 0x14e10fd34b30016 with negotiated timeout 30000 for client /192.168.1.200:48552 (org.apache.zookeeper.server.ZooKeeperServer)
test
test1 - marked for deletion
test2
[2015-06-20 21:29:09,334] INFO Processed session termination for sessionid: 0x14e10fd34b30016 (org.apache.zookeeper.server.PrepRequestProcessor)
[2015-06-20 21:29:09,337] INFO Closed socket connection for client /192.168.1.200:48552 which had sessionid 0x14e10fd34b30016 (org.apache.zookeeper.server.NIOServerCnxn)
[root@baozi kafka_2.10-0.8.2.1]#
更多推荐
已为社区贡献4条内容
所有评论(0)