Skip to content

PERCONA XTRADB CLUSTER (GALERA)

It’s installed by standard percona-client + percona-server roles by defining certain variables. I.e.

Don’t forget to open network communication between the nodes, i.e. allow any communication between the nodes or at least: 3306, 4444, 4567, 4568 tcp a 4567 udp

Configuration

node 1

### fw
firewall_v4_host_rules:
  400 allow galera traffic:
    - -A INPUT -s IP/32 -m comment --comment "galera traffic" -j ACCEPT
    ...

### db cluster
# cluster name - unique id of each cluster,
# ansible uses it to identify cluster nodes
db_wsrep_cluster_name: "db1.cz.easy2.cloud"
# id
db_server_id: 1

node 2

### fw
firewall_v4_host_rules:
  400 allow galera traffic:
    - -A INPUT -s IP/32 -m comment --comment "galera traffic" -j ACCEPT
    ...

### db cluster
# cluster name - unique id of each cluster,
# ansible uses it to identify cluster nodes
db_wsrep_cluster_name: "db1.cz.easy2.cloud"
# id
db_server_id: 2

node 3

### fw
firewall_v4_host_rules:
  400 allow galera traffic:
    - -A INPUT -s IP/32 -m comment --comment "galera traffic" -j ACCEPT
    ...

### db cluster
# cluster name - unique id of each cluster,
# ansible uses it to identify cluster nodes
db_wsrep_cluster_name: "db1.cz.easy2.cloud"
# id
db_server_id: 3

Installation / Update of db1 cluster

Necessary are just firewall and percona roles for galera to operate:

ansible-play -i easy_cloud easy-db.yaml -l 'node-*.db1.easy2.cloud' -t firewall,percona-client,percona-server

The first installation fails during last restart (not in case of update), because galera bootstrap must be done manually by running:

/etc/init.d/mysql bootstrap-pxc # the node to use as the original data source, ususally the first node
/etc/init.d/mysql start         # other nodes

After that, ansible should be run once again and finish successfully:

ansible-play -i easy_cloud easy-db.yaml -l 'node-*.db1.easy2.cloud' -t percona-client,percona-server