189 8069 5689

Kafka中怎么实现数据日志分离

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

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联的支持。


本文题目:Kafka中怎么实现数据日志分离
标题URL:http://cdxtjz.cn/article/jsoodg.html

其他资讯