How to do a primary switchoverΒΆ

A user may want to change the primary in a MySQL cluster to improve performance, enable maintenance, recover from failure, or balance load across nodes.

On a healthy cluster, the primary can be changed by running the promote-to-primary action with parameter scope set to unit on the unit that should become the new primary.

juju run mysql/1 promote-to-primary scope=unit

In this example, the unit mysql/1 will become the new primary. The previous primary will become a secondary.

juju run mysql-k8s/1 promote-to-primary scope=unit

In this example, the unit mysql-k8s/1 will become the new primary. The previous primary will become a secondary.

Juju 2.9 users

Remember that juju run <action name> becomes juju run-action <action name> --wait.

See also: Breaking changes between Juju 2.9 and 3

Caution

The promote-to-primary action can be used in cluster scope, when using cluster-cluster replication.

See Switchover / Failover for more information.