kafka集群安装及管理(二)
发表于:2024-11-17 作者:千家信息网编辑
千家信息网最后更新 2024年11月17日,一、broker的迁移1.查看zookeeper和kafka启动情况[root@slave1 ~]# pssh -h hostlist -i 'jps'[1] 22:08:11 [SUCCESS] 2
千家信息网最后更新 2024年11月17日kafka集群安装及管理(二)
一、broker的迁移
1.查看zookeeper和kafka启动情况
[root@slave1 ~]# pssh -h hostlist -i 'jps'[1] 22:08:11 [SUCCESS] 20.0.5.123492 QuorumPeerMain8140 Jps6414 Kafka[2] 22:08:11 [SUCCESS] 20.0.5.133490 QuorumPeerMain4972 Kafka22972 Jps[3] 22:08:11 [SUCCESS] 20.0.5.117369 QuorumPeerMain23754 Jps11534 Kafka[4] 22:08:11 [SUCCESS] 20.0.5.1421263 Jps[5] 22:08:11 [SUCCESS] 20.0.5.1520818 Jps
2.创建一个topic
[root@slave1 ~]# /opt/kafka/bin/kafka-topics.sh --create --zookeeper 20.0.5.11:2181 --replication-factor 3 --partitions 3 --topic topic1Created topic "topic1".[root@slave1 ~]# /opt/kafka/bin/kafka-topics.sh --describe --zookeeper 20.0.5.11:2181 --topic topic1Topic:topic1 PartitionCount:3 ReplicationFactor:3 Configs: Topic: topic1 Partition: 0 Leader: 1 Replicas: 1,3,2 Isr: 1,3,2 Topic: topic1 Partition: 1 Leader: 2 Replicas: 2,1,3 Isr: 2,1,3 Topic: topic1 Partition: 2 Leader: 3 Replicas: 3,2,1 Isr: 3,2,1
3.在要迁移的节点上启动kafka进程
[root@slave1 ~]# pssh -h hostlist '/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties > /root/kafka.log 2>1&'[1] 22:17:21 [SUCCESS] 20.0.5.12[2] 22:17:21 [SUCCESS] 20.0.5.11[3] 22:17:21 [SUCCESS] 20.0.5.13[4] 22:17:21 [SUCCESS] 20.0.5.14[5] 22:17:21 [SUCCESS] 20.0.5.15[root@slave1 ~]# pssh -h hostlist -i 'jps'[1] 22:17:29 [SUCCESS] 20.0.5.123492 QuorumPeerMain8461 Jps6414 Kafka[2] 22:17:29 [SUCCESS] 20.0.5.1421298 Kafka21609 Jps[3] 22:17:29 [SUCCESS] 20.0.5.117369 QuorumPeerMain24844 Jps11534 Kafka[4] 22:17:29 [SUCCESS] 20.0.5.133490 QuorumPeerMain4972 Kafka23292 Jps[5] 22:17:29 [SUCCESS] 20.0.5.1520854 Kafka21165 Jps
4.创建需要迁移的topic的json文件
[root@slave1 ~]# cat topic_move.json{"topics": [{"topic": "topic1"}],"version":1}
5.生成迁移规则
[root@slave1 ~]# /opt/kafka/bin/kafka-reassign-partitions.sh --zookeeper 20.0.5.11:2181 --topics-to-move-json-file topic_move.json --broker-list "3,4,5" --generateCurrent partition replica assignment{"version":1,"partitions":[{"topic":"topic1","partition":1,"replicas":[2,1,3],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":0,"replicas":[1,3,2],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":2,"replicas":[3,2,1],"log_dirs":["any","any","any"]}]}Proposed partition reassignment configuration{"version":1,"partitions":[{"topic":"topic1","partition":1,"replicas":[5,3,4],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":0,"replicas":[4,5,3],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":2,"replicas":[3,4,5],"log_dirs":["any","any","any"]}]}
6.将生成的数据写入新的json文件
[root@slave1 ~]# cat re_node.json{"version":1,"partitions":[{"topic":"topic1","partition":1,"replicas":[5,3,4],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":0,"replicas":[4,5,3],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":2,"replicas":[3,4,5],"log_dirs":["any","any","any"]}]}
7.开始迁移
[root@slave1 ~]# /opt/kafka/bin/kafka-reassign-partitions.sh --zookeeper 20.0.5.11:2181 --reassignment-json-file re_node.json --executeCurrent partition replica assignment{"version":1,"partitions":[{"topic":"topic1","partition":1,"replicas":[2,1,3],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":0,"replicas":[1,3,2],"log_dirs":["any","any","any"]},{"topic":"topic1","partition":2,"replicas":[3,2,1],"log_dirs":["any","any","any"]}]}Save this to use as the --reassignment-json-file option during rollbackSuccessfully started reassignment of partitions.[root@slave1 ~]# /opt/kafka/bin/kafka-reassign-partitions.sh --zookeeper 20.0.5.11:2181 --reassignment-json-file re_node.json --verifyStatus of partition reassignment:Reassignment of partition topic1-1 completed successfullyReassignment of partition topic1-0 completed successfullyReassignment of partition topic1-2 completed successfully
8.查看新的分区
[root@slave1 ~]# /opt/kafka/bin/kafka-topics.sh --describe --zookeeper 20.0.5.11:2181 --topic topic1Topic:topic1 PartitionCount:3 ReplicationFactor:3 Configs: Topic: topic1 Partition: 0 Leader: 4 Replicas: 4,5,3 Isr: 5,3,4 Topic: topic1 Partition: 1 Leader: 5 Replicas: 5,3,4 Isr: 5,3,4 Topic: topic1 Partition: 2 Leader: 3 Replicas: 3,4,5 Isr: 5,3,4
#迁移完后修改好producer和consumer指向新的连接后再停止旧的服务
文件
生成
情况
指向
数据
节点
规则
进程
服务
集群
管理
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
数据库漏洞扫描 开源
上海旅烁互联网科技
12306用户数据库技术
服务器对应几个域名
sql数据库应用国开试题
如何在网上学习网络安全
如何实现和外网连接数据库
无线网络技术标准第四代
阿坝app软件开发
冬奥期间网络安全工作总结
数据库无法替换
国产串口终端服务器哪家好
c 和2008数据库连接
金华市婺城区一达网络技术
不属于信息网络安全管理
计算机软件开发与应用论文
软件开发方向互联网
胶州手机软件开发系统
互联网科技股票最新
开心消消乐软件开发公司
个人电脑建立订单数据库
分布式dhcp服务器
代驾软件开发商
山西综合软件开发要多少钱
计算机网络技术第二版第9章
软件产品与软件开发服务
电信软件开发招标
ajax异步调用数据库
摄像机如何接入云服务器
灵丘标准网络安全创新服务