Skip to content
logo
Percona XtraDB Cluster
Configure nodes for write-set replication
Initializing search
    percona/pxc-docs
    percona/pxc-docs
    • Home
      • About Percona XtraDB Cluster
      • Percona XtraDB Cluster limitations
      • Understand version numbers
      • Quick start guide for Percona XtraDB Cluster
      • Install Percona XtraDB Cluster
      • Configure nodes for write-set replication
        • Template of the configuration file
        • Next Steps: Bootstrap the first node
        • Essential configuration variables
      • Bootstrap the first node
      • Add nodes to cluster
      • Verify replication
      • High availability
      • PXC strict mode
      • Online schema upgrade
      • Non-Blocking Operations (NBO) method for Online Scheme Upgrades (OSU)
      • Security basics
      • Secure the network
      • Encrypt PXC traffic
      • Enable AppArmor
      • Enable SELinux
      • State snapshot transfer
      • Percona XtraBackup SST configuration
      • Restart the cluster nodes
      • Cluster failover
      • Monitor the cluster
      • Certification in Percona XtraDB Cluster
      • Percona XtraDB Cluster threading model
      • Understand GCache and Record-Set cache
      • GCache encryption and Write-Set cache encryption
      • Perfomance Schema instrumentation
      • Data at Rest Encryption
      • Upgrade Percona XtraDB Cluster
      • Crash recovery
      • Configure Percona XtraDB Cluster on CentOS
      • Configure Percona XtraDB Cluster on Ubuntu
      • Set up Galera arbitrator
      • How to set up a three-node cluster on a single box
      • How to set up a three-node cluster in EC2 environment
      • Load balancing with HAProxy
      • Load balancing with ProxySQL
      • ProxySQL admin utilities
      • Setting up a testing environment with ProxySQL
      • Release notes index
      • Percona XtraDB Cluster 8.0.31-23 (2023-03-14)
      • Percona XtraDB Cluster 8.0.30-22.md (2022-12-28)
      • Percona XtraDB Cluster 8.0.29-21 (2022-09-12)
      • Percona XtraDB Cluster 8.0.28-19.1 (2022-07-19)
      • Percona XtraDB Cluster 8.0.27-18.1
      • Percona XtraDB Cluster 8.0.26-16.1
      • Percona XtraDB Cluster 8.0.25-15.1
      • Percona XtraDB Cluster 8.0.23-14.1
      • Percona XtraDB Cluster 8.0.22-13.1
      • Percona XtraDB Cluster 8.0.21-12.1
      • Percona XtraDB Cluster 8.0.20-11
      • Percona XtraDB Cluster 8.0.20-11.3
      • Percona XtraDB Cluster 8.0.20-11.2
      • Percona XtraDB Cluster 8.0.19-10
      • Percona XtraDB Cluster 8.0.18-9.3
      • Index of wsrep status variables
      • Index of wsrep system variables
      • Index of wsrep_provider options
      • Index of files created by PXC
      • Frequently asked questions
      • Glossary
      • Copyright and licensing information
      • Trademark policy

    • Template of the configuration file
    • Next Steps: Bootstrap the first node
    • Essential configuration variables

    Configure nodes for write-set replication¶

    After installing Percona XtraDB Cluster on each node, you need to configure the cluster. In this section, we will demonstrate how to configure a three node cluster:

    Node Host IP
    Node 1 pxc1 192.168.70.61
    Node 2 pxc2 192.168.70.62
    Node 3 pxc3 192.168.70.63
    1. Stop the Percona XtraDB Cluster server. After the installation completes the server is not started. You need this step if you have started the server manually.

      $ sudo service mysql stop
      
    2. Edit the configuration file of the first node to provide the cluster settings.

      If you use Debian or Ubuntu, edit /etc/mysql/mysql.conf.d/mysqld.cnf:

      wsrep_provider=/usr/lib/galera4/libgalera_smm.so
      wsrep_cluster_name=pxc-cluster
      wsrep_cluster_address=gcomm://192.168.70.61,192.168.70.62,192.168.70.63
      

      If you use Red Hat or CentOS, edit /etc/my.cnf. Note that on these systems you set the wsrep_provider option to a different value:

      wsrep_provider=/usr/lib64/galera4/libgalera_smm.so
      wsrep_cluster_name=pxc-cluster
      wsrep_cluster_address=gcomm://192.168.70.61,192.168.70.62,192.168.70.63
      
    3. Configure node 1.

      wsrep_node_name=pxc1
      wsrep_node_address=192.168.70.61
      pxc_strict_mode=ENFORCING
      
    4. Set up node 2 and node 3 in the same way: Stop the server and update the configuration file applicable to your system. All settings are the same except for wsrep_node_name and wsrep_node_address.

      For node 2

      wsrep_node_name=pxc2
      wsrep_node_address=192.168.70.62
      

      For node 3

      wsrep_node_name=pxc3
      wsrep_node_address=192.168.70.63
      
    5. Set up the traffic encryption settings. Each node of the cluster must use the same SSL certificates.

      [mysqld]
      wsrep_provider_options=”socket.ssl_key=server-key.pem;socket.ssl_cert=server-cert.pem;socket.ssl_ca=ca.pem”
      
      [sst]
      encrypt=4
      ssl-key=server-key.pem
      ssl-ca=ca.pem
      ssl-cert=server-cert.pem
      

    Important

    In Percona XtraDB Cluster 8.0, the Encrypting Replication Traffic is enabled by default (via the pxc-encrypt-cluster-traffic variable).

    The replication traffic encryption cannot be enabled on a running cluster. If it was disabled before the cluster was bootstrapped, the cluster must to stopped. Then set up the encryption, and bootstrap (see Bootstrapping the First Node) again.

    See also

    More information about the security settings in Percona XtraDB Cluster * Security Basics * Encrypting PXC Traffic * SSL Automatic Configuration

    Template of the configuration file¶

    Here is an example of a full configuration file installed on CentOS to /etc/my.cnf.

    # Template my.cnf for PXC
    # Edit to your requirements.
    [client]
    socket=/var/lib/mysql/mysql.sock
    [mysqld]
    server-id=1
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    # Binary log expiration period is 604800 seconds, which equals 7 days
    binlog_expire_logs_seconds=604800
    ######## wsrep ###############
    # Path to Galera library
    wsrep_provider=/usr/lib64/galera4/libgalera_smm.so
    # Cluster connection URL contains IPs of nodes
    #If no IP is found, this implies that a new cluster needs to be created,
    #in order to do that you need to bootstrap this node
    wsrep_cluster_address=gcomm://
    # In order for Galera to work correctly binlog format should be ROW
    binlog_format=ROW
    # Slave thread to use
    wsrep_slave_threads=8
    wsrep_log_conflicts
    # This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
    innodb_autoinc_lock_mode=2
    # Node IP address
    #wsrep_node_address=192.168.70.63
    # Cluster name
    wsrep_cluster_name=pxc-cluster
    #If wsrep_node_name is not specified,  then system hostname will be used
    wsrep_node_name=pxc-cluster-node-1
    #pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
    pxc_strict_mode=ENFORCING
    # SST method
    wsrep_sst_method=xtrabackup-v2
    

    Next Steps: Bootstrap the first node¶

    After you configure all your nodes, initialize Percona XtraDB Cluster by bootstrapping the first node according to the procedure described in Bootstrapping the First Node.

    Essential configuration variables¶

    wsrep_provider

    Specify the path to the Galera library. The location depends on the distribution:

    • Debian and Ubuntu: /usr/lib/galera4/libgalera_smm.so

    • Red Hat and CentOS: /usr/lib64/galera4/libgalera_smm.so

    wsrep_cluster_name

    Specify the logical name for your cluster. It must be the same for all nodes in your cluster.

    wsrep_cluster_address

    Specify the IP addresses of nodes in your cluster. At least one is required for a node to join the cluster, but it is recommended to list addresses of all nodes. This way if the first node in the list is not available, the joining node can use other addresses.

    Note

    No addresses are required for the initial node in the cluster. However, it is recommended to specify them and properly bootstrap the first node. This will ensure that the node is able to rejoin the cluster if it goes down in the future.

    wsrep_node_name

    Specify the logical name for each individual node. If this variable is not specified, the host name will be used.

    wsrep_node_address

    Specify the IP address of this particular node.

    wsrep_sst_method

    By default, Percona XtraDB Cluster uses Percona XtraBackup for State Snapshot Transfer. xtrabackup-v2 is the only supported option for this variable. This method requires a user for SST to be set up on the initial node.

    pxc_strict_mode

    PXC Strict Mode is enabled by default and set to ENFORCING, which blocks the use of tech preview features and unsupported features in Percona XtraDB Cluster.

    binlog_format

    Galera supports only row-level replication, so set binlog_format=ROW.

    default_storage_engine

    Galera fully supports only the InnoDB storage engine. It will not work correctly with MyISAM or any other non-transactional storage engines. Set this variable to default_storage_engine=InnoDB.

    innodb_autoinc_lock_mode

    Galera supports only interleaved (2) lock mode for InnoDB. Setting the traditional (0) or consecutive (1) lock mode can cause replication to fail due to unresolved deadlocks. Set this variable to innodb_autoinc_lock_mode=2.

    Contact us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: 2023-01-20
    Percona LLC and/or its affiliates, © 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.