Kafka配置(注意log.dirs不要配置在tmp目录下,因为该目录会被linux定时任务删除,会导致kafka崩溃)
需要三个Kafka实例,分别安装在下面三个机器上:
192.168.240.167
192.168.240.168
192.168.240.169
第一步,修改192.168.240.167机器上的Kafka配置
config/server.properties:
broker.id=1
listeners=PLAINTEXT://192.168.240.167:9093 这里必须加上IP或者HOST,否则上报到ZK的地址会变成127.0.0.1
num.partitions=10 默认分区数量需要估算,一般是一个进程占用一个partition
zookeeper.connect=192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181
第二步,修改192.168.240.168机器上的Kafka配置
config/server.properties:
broker.id=2
listeners=PLAINTEXT://192.168.240.168:9093 这里必须加上IP或者HOST,否则上报到ZK的地址会变成127.0.0.1
num.partitions=10 默认分区数量需要估算,一般是一个进程占用一个partition
zookeeper.connect=192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181
第三步,修改192.168.240.169机器上的Kafka配置
config/server.properties:
broker.id=3
listeners=PLAINTEXT://192.168.240.169:9093 这里必须加上IP或者HOST,否则上报到ZK的地址会变成127.0.0.1
num.partitions=10 默认分区数量需要估算,一般是一个进程占用一个partition
zookeeper.connect=192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181
第四步,启动Kafka进程
三台机器分别进入Kafka根目录,运行:
nohup bin/kafka-server-start.sh config/server.properties > kafka.out &
第五步,创建Topic
进入任意一台机器上的Kafka根目录,运行:
bin/kafka-topics.sh --create --zookeeper 192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181 --replication-factor 1 --partitions 10 --topic threebody.core
bin/kafka-topics.sh --create --zookeeper 192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181 --replication-factor 1 --partitions 10 --topic threebody.match
bin/kafka-topics.sh --create --zookeeper 192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181 --replication-factor 1 --partitions 10 --topic threebody.battle
bin/kafka-topics.sh --create --zookeeper 192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181 --replication-factor 1 --partitions 10 --topic threebody.monitor
查看Topic信息
bin/kafka-topics.sh --describe --zookeeper 192.168.240.167:2181,192.168.240.168:2181,192.168.240.169:2181 --topic threebody.core