Kafka中怎么實現(xiàn)數(shù)據(jù)日志分離,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
為企業(yè)提供成都網(wǎng)站設(shè)計、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司、網(wǎng)站優(yōu)化、成都營銷網(wǎng)站建設(shè)、競價托管、品牌運營等營銷獲客服務(wù)。創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認可!
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集群中每個服務(wù)的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集群的每個服務(wù)
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的所有內(nèi)容,和dataLog中所有內(nèi)容
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. 創(chuàng)建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
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。