Replication Configuration

Length: 964 words; Published: October 20, 2014; Topic: General; Level: Beginner

In addition to the configuration for the database server, there are some specific options that you need to set to enable write-set replication. You must apply these changes to the configuration file (that is, my.cnf) for each node in the cluster.

  • wsrep_cluster_name: Use this parameter to set the logical name for the cluster. You must use the same name for each node in the cluster. The connection will fail on nodes that have different values for this parameter.

  • wsrep_cluster_address: Use this parameter to define the IP addresses for the cluster in a comma-separated list.

    Note

    There are additional schemata and options available through this parameter. For more information on the syntax, see Cluster Addresses below.

  • wsrep_node_name: Use this parameter to define the logical name for the individual node—for convenience.

  • wsrep_node_address: Use this parameter to set explicitly the IP address for the individual node. It is used when auto-guessing does not produce desirable results.

[mysqld]
wsrep_cluster_name=MyCluster
wsrep_cluster_address="gcomm://192.168.0.1,192.168.0.2,192.168.0.3"
wsrep_node_name=MyNode1
wsrep_node_address="192.168.0.1"

Backend Schema

There are two backend schemata available with Galera Cluster.

  • dummy: This provides a pass-through back-end for testing and profiling purposes. It does not connect to other nodes and will ignore any values given to it.
  • gcomm: This provides the group communications back-end for use in production. It accepts an address and has several settings that may be enabled through the option list, or by using the wsrep_provider_options parameter.

Cluster Addresses

For the cluster address section, you have to provide a comma-separate list of IP addresses for all of the nodes in the cluster. You would do this using the wsrep_cluster_address parameter. Cluster addresses are listed in the configuration file using a particular syntax, like so:

<backend schema>://<cluster address>[?<option1>=<value1>[&<option2>=<value2>]]

Below is an example of how this line from the configuration file might look:

wsrep_cluster_address="gcomm://192.168.0.1,192.168.0.2,192.168.0.3"

Here, the backend schema is gcomm. The cluster addresses (that is, 192.168.0.1, etc.) are listed next, separted by commas. You can add options after that, within the quotes. You would start with a question mark, followed by each option setting. Option key/value pairs are separated by an ampersand. This is covered in the Options section below.

The IP addresses given in the configuration file should include any current members of the cluster. The list may also include the IP addresses of any possible cluster members. Members can belong to no more than one Primary Component;

If you start a node without proving an IP address for this parameter, the node will assume that it is the first node of a new cluster. It will initialize the cluster as though you launched mysqld with the mysqld_bootstrap command.

Options

When setting the IP address in the configuration file using the wsrep_cluster_address parameter, you can also set some options. You can set backend parameters, such as the listen address and timeout values.

Note

The wsrep_cluster_address options list is not durable. The node must resubmit the options on each connection to a cluster. To make these options durable, set them in the configuration file using the wsrep_provider_options parameter.

The options set in the URL take precedent over parameters set elsewhere. Parameters you set through the options list are prefixed by evs (that is, Extended Virtual Synchrony), pc (that is, Primary Component) and gmcast.

For more information on the available parameters, see Galera Parameters.

When listing options, start with a question mark after the IP address list. Then provide the options in a key=value format. Key/value pairs must be separated by an ampersand. Below is an example of how this might look:

wsrep_cluster_address="gcomm://192.168.0.1, 192.168.0.2, 192.168.0.3 ? gmcast.segment=0 & evs.max_install_timeouts=1"

In this example, the segment option for gcomm and the max_install_timeouts option for evs are set.

Incidentally, if the listen address and port are not set in the parameter list, gcomm will listen on all interfaces. The listen port will be taken from the cluster address. If it is not specified in the cluster address, the default port is 4567.