Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-25855 Added support for Galera replication with cluster auto bootstrapping #377

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Feb 15, 2022

  1. Support Galera Replication

    This patch add support for Galera replication.
    
    Features:
    - It detects if Galera replication was enabled wsrep_on=ON
    - By default it enables cluster auto bootstrap feature
    - By default the first cluster node is used for cluster auto bootstrapping
      based on the wsrep_cluster_address parameter or by setting the
      `WSREP_CLUSTER_ADDRESS` environment variable
    - cluster auto bootstrap feature can be disabled by setting the
      `WSREP_SKIP_AUTO_BOOTSTRAP` environment variable
    - use the `WSREP_AUTO_BOOTSTRAP_ADDRESS` environment variable to explicitly
      choice other node for cluster bootstrapping
    - cluster node hostnames or IP addresses must be valid to enable cluster
      auto bootstrapping
    
    How to use it.
    
    1. Prepare MariaDB configuration file `galera.cnf`:
    
    ```plaintext
    [galera]
    wsrep_on                       = ON
    wsrep_sst_method               = mariabackup
    wsrep_provider                 = /usr/lib/libgalera_smm.so
    binlog_format                  = row
    default_storage_engine         = InnoDB
    innodb_doublewrite             = 1
    innodb_autoinc_lock_mode       = 2
    ```
    
    2. Make it read-only:
    
    ```plaintext
    chmod 444 galera.cnf
    ```
    
    3. Prepare Docker Compose file `docker-compose.yml`:
    
    ```yaml
    services:
        node:
            image: mariadb
            restart: always
            security_opt:
                - label=disable
            environment:
                WSREP_CLUSTER_ADDRESS: "${WSREP_CLUSTER_ADDRESS:-}"
                MARIADB_ROOT_PASSWORD: example
            volumes:
                - ./galera.cnf:/etc/mysql/conf.d/10-galera.cnf:ro
            command:
                - --wsrep-cluster-address=gcomm://db_node_1,db_node_2,db_node_3
            deploy:
                replicas: 3
    ```
    
    4. Start Docker Compose:
    
    ```plaintext
    docker-compose --project-name db up
    ```
    
    To start N MariaDB instances using environment variable:
    
    ```plaintext
    WSREP_CLUSTER_ADDRESS="gcomm://db_node_1,db_node_2,db_node_3,db_node_4,db_node_5"
    docker-compose --project-name db up --scale node="$(echo "${WSREP_CLUSTER_ADDRESS}" | tr ',' ' ' | wc -w)"
    ```
    
    To start N MariaDB instances using MariaDB configuration file:
    
    ```plaintext
    docker-compose --project-name db up --scale node="$(grep -i wsrep_cluster_address <name>.cnf | tr -d ' ' | tr ',' ' ' | wc -w)"
    ```
    
    Closes: MariaDB#28
    tymonx authored and grooverdan committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    d9c2595 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    38bebe0 View commit details
    Browse the repository at this point in the history