第一步:准备三个server.properties文件
调整properties文件里面的额呢绒
-
server.properties
broker.id=0 #当前这个节点对外提供的ip和端口 listeners=PLAINTEXT://192.168.156.131:9092 log.dirs=/root/kafka/data/kafka-logs
-
server.properties
broker.id=1 listeners=PLAINTEXT://192.168.156.131:9093 log.dirs=/root/kafka/data/kafka-logs-1
-
server.properties
broker.id=2 listeners=PLAINTEXT://192.168.156.131:9094 log.dirs=/root/kafka/data/kafka-logs-2
实际操作过程:
[root@localhost config]# pwd
/root/kafka/kafka_2.11-2.4.1/config
[root@localhost config]# ls
connect-console-sink.properties connect-mirror-maker.properties server.properties
connect-console-source.properties connect-standalone.properties tools-log4j.properties
connect-distributed.properties consumer.properties trogdor.conf
connect-file-sink.properties log4j.properties zookeeper.properties
connect-file-source.properties nohup.out
connect-log4j.properties producer.properties
[root@localhost config]# cp server.properties server1.properties
[root@localhost config]# cp server.properties server2.properties
# 依次修改配置文件里面的内容
[root@localhost config]# vim server.properties
第二步:在bin目录下启动服务器
启动zookeeper
./zookeeper-server-start.sh -daemon ../config/zookeeper.properties
启动三台服务器
./kafka-server-start.sh -daemon ../config/server.properties
./kafka-server-start.sh -daemon ../config/server1.properties
./kafka-server-start.sh -daemon ../config/server2.properties
实际操作:
[root@localhost config]# pwd
/root/kafka/kafka_2.11-2.4.1/config
[root@localhost config]# cd ../bin/
[root@localhost bin]# ./kafka-server-start.sh -daemon ../config/server.properties
[root@localhost bin]# ./kafka-server-start.sh -daemon ../config/server1.properties
[root@localhost bin]# ./kafka-server-start.sh -daemon ../config/server2.properties
[root@localhost bin]#
第三步:查看是否启动成功(进入zk查看)
[root@localhost bin]# ./zookeeper-shell.sh localhost:2181
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is disabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
ls /broker/ids
Node does not exist: /broker/ids
ls /
[admin, brokers, cluster, config, consumers, controller, controller_epoch, isr_change_notification, latest_producer_id_block, log_dir_event_notification, zookeeper]
ls /brokers/ids
[0, 1, 2]
如果有上面的信息证明三个服务器(集群)启动成功