w3resource

Removing a Node from Galera Cluster


Force a Node to Leave Galera Cluster

Write MySQL commands to safely remove a node from a Galera Cluster.

Solution:

-- Check current status before leaving
SHOW STATUS LIKE 'wsrep_cluster_size';

-- Stop the node from accepting new writes or reads
SET GLOBAL wsrep_on=OFF;

-- Stop MySQL service
-- (This step must be performed outside SQL, e.g., 'service mysql stop')

-- Remove cluster configuration from my.cnf
-- (This step involves editing the configuration file directly)

-- Restart MySQL without Galera
-- (This step must be performed outside SQL, e.g., 'service mysql start')

Explanation:

  • Purpose of the Query:
    • Properly removes a node from a Galera Cluster to maintain cluster integrity.
  • Key Components:
    • Disabling wsrep_on prevents new cluster-related operations.
    • Configuration changes and service management are done outside SQL.
  • Real-World Application:
    • Useful for maintenance, upgrades, or when a node is no longer needed in the cluster

Notes:

  • Ensure other nodes are aware of the change in cluster size for load balancing.

For more Practice: Solve these Related Problems:

  • Write SQL commands to safely remove a node from a Galera Cluster while maintaining data integrity.
  • Write SQL to prepare a node for removal from a Galera Cluster by redirecting its traffic.


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous MySQL Exercise: Monitor Galera Cluster Health.
Next MySQL Exercise: Configure Semi-Synchronous Replication.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.