CDH-Kafka节点迁移

櫰木2年前技术文章1008


1、节点迁移

先添加节点,将需要换掉的节点关闭,等待选举leader

启动新添加的节点

1.png

关闭旧的节点

2.png

等待选举leader

3.png

出现离线分区。需要将分区分配到新的节点

2、重分配分区

kafak kerberos环境下使用

参考文档:https://docs.cloudera.com/documentation/enterprise/latest/topics/kafka_security.html

1、如果使用kerberos cache。创建jaas.conf,然后使用kinit进行认证

KafkaClient {
com.sun.security.auth.module.Krb5LoginModule required
useTicketCache=true;
};

2、如果使用kerberos keytab,则创建jaas.conf

KafkaClient {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
keyTab="/etc/security/keytabs/mykafkaclient.keytab"
principal="mykafkaclient/clients.hostname.com@EXAMPLE.COM";
};

3、创建client.properties

security.protocol=SASL_PLAINTEXT
sasl.kerberos.service.name=kafka

4、验证topic是否存在

kafka-topics --list --zookeeper cdp01:2181/kafka

5、使用jaas.conf文件

export KAFKA_OPTS="-Djava.security.auth.login.config=/home/user/jaas.conf"

6、使用jaas.conf进行查看topic

#路径按照实际情况配置
export KAFKA_OPTS="-Djava.security.auth.login.config=/home/user/jaas.conf"
kafka-topics --bootstrap-server cdp01:9092,cdp03:9092,cdp05:9092 --list --command-config client.properties

7、生成topic-gen.json

{
    "topics": [
        {
            "topic": "__consumer_offsets"
        },
        {
            "topic": "__smm-app-consumer-metrics-keys-index-changelog"
        },
        {
            "topic": "__smm-app-producer-metrics-keys-index-changelog"
        },
        {
            "topic": "__smm-app-smm-consumer-table-15m-changelog"
        },
        {
            "topic": "__smm-app-smm-consumer-table-15m-repartition"
        },
        {
            "topic": "__smm-app-smm-consumer-table-30s-changelog"
        },
        {
            "topic": "__smm-app-smm-consumer-table-30s-repartition"
        },
        {
            "topic": "__smm-app-smm-producer-table-15m-changelog"
        },
        {
            "topic": "__smm-app-smm-producer-table-15m-repartition"
        },
        {
            "topic": "__smm-app-smm-producer-table-30s-changelog"
        },
        {
            "topic": "__smm-app-smm-producer-table-30s-repartition"
        },
        {
            "topic": "__smm_alert_notifications"
        },
        {
            "topic": "__smm_consumer_metrics"
        },
        {
            "topic": "__smm_producer_metrics"
        },
        {
            "topic": "connect-configs"
        },
        {
            "topic": "connect-offsets"
        },
        {
            "topic": "connect-status"
        },
        {
            "topic": "test_producer_perf"
        }
    ],
    "version": 1
}

通过--topics-to-move-json-file 和--generate来分配分区策略

kafka-reassign-partitions --zookeeper cdp01:2181/kafka --broker-list "87,215,202"   --topics-to-move-json-file topic-gen.json --generate --command-config client.properties

--broker-list   的值是要分配的kafka broker id,中间逗号隔开

会输出当前分配策略和期望分配策略

当前分配策略

期望分配策略

将当前分配策略备份。使用期望分配策略进行分区分配

通过--reassignment-json-file 参数和--execute执行分配策略

kafka-reassign-partitions --zookeeper cdp01:2181/kafka --reassignment-json-file topic_move.json --execute


通过-reassignment-json-file 和--verify 验证分配是否成功

全部成功后,删除旧的kafka broker

重启kafka,恢复正常


相关文章

网络数据链路层-MAC帧(1)

网络数据链路层-MAC帧(1)

1.数据链路层数据链路层是网络协议栈中最底层的内容,而在之前对其他层次的学习让我们知道传输层可以保证数据的可靠性问题,网络层保证数据跨网络转发的路由问题,而数据链路层解决的就是局域网内两台主机间通信的...

 MySQL优化器特性(九)行数评估

MySQL优化器特性(九)行数评估

查询的行数在成本计算中起了很重要的作用:1、row_evaluate_cost和行数直接相关2、需要访问多少索引页面,和行数直接相关。根据页面大小和平均索引条目长度计算每个索引页面的记录数,根据记录数...

flink单task多slot调优

flink单task多slot调优

1. 单taskmanager多slot的设置方法方式一:在配置文件中配置taskmanager.numberOfTaskSlots,通过修改提交任务的客户端配置文件中的配置flink-co...

Hbase2.x 使用hbck2

Hbase2.x 使用hbck2

1、背景默认情况下apache hbase 使用hbck2时,无法使用-j 来加载hbck2的jar包,无法进行修复2、解决办法是由于默认情况下只使用自带的hbase hbck修复命令,大部分功能在2...

at和corntab 计划任务

一、什么是计划任务每个人在生活当中或多或少都有一些工作,有的工作是按照一定周期循环的, 例如每天固定时间的闹铃、工作打卡等等; 有的工作则是临时发生的,例如刚好有亲友到访,需要你在一个特定的时间去车站...

RabbitMQ 集群部署

RabbitMQ 集群部署

1. 两种模式说到集群,小伙伴们可能第一个问题是,如果我有一个 RabbitMQ 集群,那么是不是我的消息集群中的每一个实例都保存一份呢?这其实就涉及到 RabbitMQ 集群的两种模式:1)普通集群...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。