galera_new_cluster - Linux


galera_new_cluster initializes and bootstraps a new Galera cluster, creating the necessary configuration files and database objects to enable multi-master replication. It automates the complex process of setting up a Galera cluster, making it easier to establish a highly available database infrastructure.


galera_new_cluster [OPTIONS]


  • -u, –user=USER
    • The MySQL user to use for database operations. Defaults to "root".
  • -p, –password=PASSWORD
    • The password for the MySQL user. Defaults to an empty string.
  • -h, –host=HOST
    • The hostname or IP address of the primary Galera node. Defaults to "localhost".
  • -P, –port=PORT
    • The port number to connect to MySQL. Defaults to "3306".
  • -d, –datadir=DATADIR
    • The directory to store MySQL data files. Defaults to "/var/lib/mysql".
  • -c, –configdir=CONFIGDIR
    • The directory to store MySQL configuration files. Defaults to "/etc/mysql".
  • –force
    • Proceed with cluster initialization even if the data directory is not empty.


Simple usage:


Specify username and password:

galera_new_cluster -u username -p password

Using a custom data directory:

galera_new_cluster -d /opt/mysql/data

Common Issues

  • Empty data directory: Ensure the data directory specified using the -d option is empty before running galera_new_cluster.
  • MySQL user permissions: The MySQL user used for database operations must have the necessary privileges, including the ability to create and manage databases.
  • Firewall restrictions: Check if firewalls are blocking connections to the MySQL port.


Creating a Galera cluster from scratch:

sudo service mysql start

Adding a node to an existing Galera cluster:

galera_new_cluster -h <existing_node_hostname>
sudo service mysql start

Related Commands

  • mysql – The MySQL command-line client.
  • my.cnf – The MySQL configuration file.
  • wsrep-recover – A utility used for recovering Galera nodes after a failure.