ScarShow

< IS >

MariaDB Galera Cluster 10.0 Setting

Setting Environment

Repository

Ubuntu Trusty

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/10.0/ubuntu trusty main'

Debian Wheezy

sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/10.0/debian wheezy main'

Install MariaDB Galera Cluster

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mariadb-galera-server galera rsync

Setting Cluster Node

Create Cluster User for All Node

GRANT USAGE ON *.* to CLUSTER_USER@'%' IDENTIFIED BY 'CLUSTER_PASS';
GRANT ALL PRIVILEGES on *.* to CLUSTER_USER@'%';
GRANT USAGE ON *.* to CLUSTER_USER@'localhost' IDENTIFIED BY 'CLUSTER_PASS';
GRANT ALL PRIVILEGES on *.* to CLUSTER_USER@'localhost';

Stop All Cluster Node

sudo service mysql stop

Setting MaraiDB Cluster

[mysqld]
# Mysql Settings
binlog_format = ROW
default-storage-engine = innodb
innodb_autoinc_lock_mode = 2
query_cache_size = 0
query_cache_type = 0
bind-address = 0.0.0.0

# Galera Settings
wsrep_node_address = "NODE_IP"
wsrep_provider = /usr/lib/galera/libgalera_smm.so
wsrep_cluster_name = "CLUSTER_NAME"
wsrep_cluster_address = "gcomm://OTHER_NODE_IP:4567"
wsrep_sst_auth = CLUSTER_USER:CLUSTER_PASS
wsrep_sst_method = rsync

Open 3 Ports in Firewall

  • 3306: MariaDB
  • 4444: RSync
  • 4567: Galera Cluster

Start Cluster Node

First Cluster Node

sudo service mysql start --wsrep-new-cluster

Other Cluster Node

sudo service mysql start

Fix Bug

If you shutdown cluster node with failed, then copy /etc/mysql/debian.cnf from the first node to the other node.

sudo service mysql stop
[FAIL] Stopping MariaDB database server: mysqld failed!

Finally

Have Fun!