Remember a kafka migration related issues

Process:
1. First find out how many groups all consumers have and notify them to prepare
2. The kafka producer migrates to a new address
3. The consumer changes to the new kafka address after the old kafka consumption is completed

In Kubernetes (k8s), the service task is not executed during the restart process, resulting in data loss.
Adjust the restart strategy: In the configuration of the Deployment or StatefulSet, you can control the restart behavior of the Pod by adjusting the restart strategy. By default, the restart policy is "Always", which means whenever a Pod terminates, it will restart immediately. The restart policy can be set to "OnFailure" so that a restart is only triggered when the application fails, avoiding interrupting tasks during a normal restart.

Graceful Termination (Graceful Termination): Implement a graceful termination mechanism in the application, that is, when receiving a termination signal (such as SIGTERM), complete the ongoing task first, and then exit normally. Kubernetes will send a termination signal to the Pod, and the application needs to catch and handle this signal. By terminating gracefully, you can ensure that as much as possible of the current task is completed during the restart process, avoiding interruption.

Guess you like

Origin blog.csdn.net/a203206868/article/details/131580345