kafka集群安装配置
1、wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.10.1.1/kafka_2.10-0.10.1.1.tgz 2、单机环境 tar -zxvf kafka_2.10-0.10.1.1.tgz -C /usr/local/ cd /usr/local/kafka_2.10-0.10.1.1 vim config/zookeeper.properties vim config/server.properties nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties & nohup ./bin/kafka-server-start.sh config/server.properties & ./bin/kafka-console-producer.sh --broker-list 192.168.17.116:9092 --topic test ./bin/kafka-console-consumer.sh --zookeeper 192.168.17.116:2181 --topic test --from-beginning 3、集群环境 192.168.17.116 192.168.17.118 192.168.17.99 vim config/zookeeper.properties tickTime=2000 dataDir=/data/zookeeper/ clientPort=2181 initLimit=5 syncLimit=2 server.1=192.168.17.116:2888:3888 server.1=192.168.17.118:2888:3888 server.1=192.168.17.99:2888:3888 在dataDir目录/data/zookeeper/下写一个myid文件,命令如下:echo 1 >myid,这个id是zookeeper的主机标示,每个主机id不同,在这里我设置的第二台是2,第三台是3。 vim config/server.properties broker.id=1(前面设置的本机id) port=9092 host.name=192.168.17.116(本机IP) zookeeper.connect=192.168.17.116:2181,192.168.17.118:2181,192.168.17.99:2181 log.dirs=/usr/ss/kafka_2.10-0.9.0.0/logs nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties & nohup ./bin/kafka-server-start.sh config/server.properties & 创建topic: ./bin/kafka-topics.sh --create --topic topic_1 --partitions 1 --replication-factor 3 --zookeeper 127.0.0.1:2181 bin/kafka-topics.sh --create --topic topic_2 --partitions 1 --replication-factor 3 \--zookeeper localhost:2181 bin/kafka-topics.sh --create --topic topic_3 --partitions 1 --replication-factor 3 \--zookeeper localhost:2181 查看topic创建情况: bin/kafka-topics.sh --list --zookeeper localhost:2181 发送消息 bin/kafka-console-producer.sh --topic topic_1 --broker-list 192.168.1.181:9092,192.168.1.181:9093,192.168.1.181:9094 接收消息 bin/kafka-console-consumer.sh --topic topic_1 --zookeeper 192.168.1.181:2181 --from-beginning

