您好,登錄后才能下訂單哦!
Kafka中怎么實現數據日志分離,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
1. 停止kafka集群
root@bluejay-PC:/# /usr/local/kafka/kafka01/bin/kafka-server-stop.sh root@bluejay-PC:/# /usr/local/kafka/kafka02/bin/kafka-server-stop.sh root@bluejay-PC:/# /usr/local/kafka/kafka03/bin/kafka-server-stop.sh
2. 刪除kafka集群中每個服務的logs
root@bluejay-PC:/usr/local/kafka/kafka01/logs# rm -rf * root@bluejay-PC:/usr/local/kafka/kafka02/logs# rm -rf * root@bluejay-PC:/usr/local/kafka/kafka03/logs# rm -rf *
3.停止zookeeper集群的每個服務
root@bluejay-PC:/# /usr/local/zookeeper/zookeeper01/bin/zkServer.sh stop ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/zookeeper01/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED root@bluejay-PC:/# /usr/local/zookeeper/zookeeper02/bin/zkServer.sh stop ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/zookeeper02/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED root@bluejay-PC:/# /usr/local/zookeeper/zookeeper03/bin/zkServer.sh stop ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/zookeeper03/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED root@bluejay-PC:/#
4. 刪除zookeeper中的data 中除myid的所有內容,和dataLog中所有內容
root@bluejay-PC:/# cd /usr/local/zookeeper/zookeeper01/data root@bluejay-PC:/usr/local/zookeeper/zookeeper01/data# ls myid version-2 root@bluejay-PC:/usr/local/zookeeper/zookeeper01/data# rm -rf version-2/ root@bluejay-PC:/usr/local/zookeeper/zookeeper01/data# root@bluejay-PC:/usr/local/zookeeper/zookeeper01/data# ls myid root@bluejay-PC:/usr/local/zookeeper/zookeeper01/data# cd /usr/local/zookeeper/zookeeper02/data root@bluejay-PC:/usr/local/zookeeper/zookeeper02/data# rm -rf version-2/ root@bluejay-PC:/usr/local/zookeeper/zookeeper02/data# ls myid root@bluejay-PC:/usr/local/zookeeper/zookeeper02/data# cd /usr/local/zookeeper/zookeeper03/data root@bluejay-PC:/usr/local/zookeeper/zookeeper03/data# rm -rf version-2/ root@bluejay-PC:/usr/local/zookeeper/zookeeper03/data# ls myid root@bluejay-PC:/usr/local/zookeeper/zookeeper03/data#
5. 重啟zookeeper集群
root@bluejay-PC:/# /usr/local/zookeeper/zookeeper01/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/zookeeper01/bin/../conf/zoo.cfg Starting zookeeper ... STARTED root@bluejay-PC:/# /usr/local/zookeeper/zookeeper02/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/zookeeper02/bin/../conf/zoo.cfg Starting zookeeper ... STARTED root@bluejay-PC:/# /usr/local/zookeeper/zookeeper03/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/zookeeper03/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
6. 重新配置每個kafka的配置文件
將log.dirs 配置到data目錄
log.dirs=/usr/local/kafka/kafka03/data
7. 創建topic后查看 kafka 中的logs 和 data目錄
/usr/local/kafka/kafka03/bin/kafka-topics.sh --create --zookeeper 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183 --replication-factor 1 --partitions 1 --topic first
root@bluejay-PC:/usr/local/kafka/kafka03/logs# ls -l 總用量 164 -rw-r--r-- 1 root staff 307 4月 4 15:05 controller.log -rw-r--r-- 1 root staff 0 4月 4 15:05 kafka-authorizer.log -rw-r--r-- 1 root staff 0 4月 4 15:05 kafka-request.log -rw-r--r-- 1 root staff 9955 4月 4 15:05 kafkaServer-gc.log.0.current -rw-r--r-- 1 root staff 67722 4月 4 15:07 kafkaServer.out -rw-r--r-- 1 root staff 172 4月 4 15:05 log-cleaner.log -rw-r--r-- 1 root staff 67722 4月 4 15:07 server.log -rw-r--r-- 1 root staff 5675 4月 4 15:07 state-change.log root@bluejay-PC:/usr/local/kafka/kafka03/logs# ls -l ../data 總用量 88 -rw-r--r-- 1 root staff 0 4月 4 15:05 cleaner-offset-checkpoint drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-0 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-12 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-15 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-18 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-21 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-24 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-27 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-3 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-30 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-33 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-36 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-39 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-42 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-45 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-48 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-6 drwxr-sr-x 2 root staff 4096 4月 4 15:07 __consumer_offsets-9 drwxr-sr-x 2 root staff 4096 4月 4 15:07 first-0 -rw-r--r-- 1 root staff 4 4月 4 15:09 log-start-offset-checkpoint -rw-r--r-- 1 root staff 88 4月 4 15:05 meta.properties
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。