Mysql
Cluster Galera
sources.list
https://downloads.mariadb.org/mariadb/repositories/#mirror=urbach&distro=Debian
Bootstrapping a new cluster
1 | $ mysqld --wsrep-new-cluster & |
Adding node to a cluster
1 | $ mysqld --wsrep_cluster_address=gcomm://192.168.0.1 # DNS names work as well |
Cluster state
1 | mysql> show global status like '%wsrep%'; |
Cluster conf
[mysqld]
#mysql settings
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
#galera settings
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name=”my_wsrep_cluster”
wsrep_cluster_address=”gcomm://172.16.8.5,172.16.8.6,172.16.8.4”
wsrep_sst_method=rsync
more conf
- choose your donor
wsrep_sst_donor=”10.0.100.10,10.0.100.8”
obsolete query cache was disable prior to “5.5.40-galera”, “10.0.14-galera” and “10.1.2”.
query_cache_size=0
query_cache_type=0(http://www.ovaistariq.net/597/understanding-innodb-transaction-isolation-levels/)
MariaDB> select @@global.tx_isolation;
transaction-isolation = REPEATABLE-READ(https://mariadb.com/kb/en/mariadb/wsrep_provider_options/)
wsrep_provider_options =”gcs.fc_limit=256 ; gcache.size=2G”(https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/#wsrep_causal_reads) (default OFF)
wsrep_causal_reads = OFF(https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/#wsrep_slave_threads)
wsrep_slave_threads = 8(https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/#wsrep_sst_method)
wsrep_sst_auth = debian-sys-maint:C1WXqAscHm9mTi8r
wsrep_sst_method = xtrabackup-v2
Doc
Troubleshooting
- En cas de :
/usr//bin/wsrep_sst_rsync: 269: /usr//bin/wsrep_sst_rsync: [[: not found
remplacer /bin/sh par /bin/bash dans le shebang
- Si le start timeout à cause d’une sync trop long
ajouter TimeoutStartSec=0 au [Service] systemd
- Si tous les noeuds tombent en même temps.
~# mysqld –wsrep-cluster-address=”gcomm://“
- Si aucun des noeud ne veut boostrap starter :
dans
/var/lib/mysql/grastate.dat
passer “safe_to_bootstrap: 0” à 1