You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.4 KiB
83 lines
2.4 KiB
6 years ago
|
#!/bin/bash
|
||
|
# forksand-mariadb-setup
|
||
|
#
|
||
|
# Script template for setting up MySQL compatible MariaDB Cluster
|
||
|
# on four nodes: sql1 sql2 sql3 sql4
|
||
|
#
|
||
|
# https://mariadb.com/kb/en/library/getting-started-with-mariadb-galera-cluster/
|
||
|
#
|
||
|
# Get repo mirror:
|
||
|
# https://downloads.mariadb.org/mariadb/repositories
|
||
|
|
||
|
exit 0
|
||
|
|
||
|
# As root
|
||
|
apt-get install software-properties-common dirmngr
|
||
|
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
|
||
|
add-apt-repository 'deb [arch=amd64] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.3/debian stretch main'
|
||
|
apt-get update
|
||
|
apt-get install mariadb-server
|
||
|
apt-get clean
|
||
|
|
||
6 years ago
|
# Set config like here:
|
||
|
# https://mariadb.org/installing-mariadb-galera-cluster-on-debian-ubuntu/
|
||
|
# /etc/mysql/my.cnf
|
||
|
# =================================================
|
||
|
[galera]
|
||
|
# Mandatory settings
|
||
|
wsrep_on=ON
|
||
|
wsrep_provider=/usr/lib/galera/libgalera_smm.so
|
||
|
wsrep_cluster_address="gcomm://10.42.1.171,10.42.1.172,10.42.1.173,10.42.1.174"
|
||
|
wsrep_cluster_name="XXX"
|
||
|
binlog_format=row
|
||
|
default_storage_engine=InnoDB
|
||
|
innodb_autoinc_lock_mode=2
|
||
|
wsrep_sst_method=rsync
|
||
|
query_cache_size=0
|
||
|
query_cache_type=0
|
||
6 years ago
|
#
|
||
6 years ago
|
# Allow server to accept connections on all interfaces.
|
||
|
#
|
||
|
bind-address=10.42.1.174
|
||
|
#
|
||
|
# Optional setting
|
||
|
#wsrep_slave_threads=1
|
||
|
#innodb_flush_log_at_trx_commit=0
|
||
|
|
||
|
# =================================================
|
||
|
|
||
|
service mysql stop
|
||
|
# on just sql1:
|
||
|
galera_new_cluster
|
||
|
|
||
|
# See if the cluster node comes up:
|
||
|
mysql -p -u root -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'
|
||
|
|
||
|
# Start another node, sql2:
|
||
|
service mysql start
|
||
|
|
||
|
# See if it came up:
|
||
|
mysql -p -u root -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'
|
||
|
|
||
|
# Then do sql3 sql4
|
||
|
service mysql start
|
||
|
|
||
|
# See if it came up:
|
||
|
mysql -p -u root -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'
|
||
6 years ago
|
|
||
|
###############################################
|
||
|
# run this to lock down:
|
||
|
mysql_secure_installation
|
||
|
|
||
|
|
||
|
###########################################
|
||
|
# If all cluster nodes get shutdown at the same time, the cluster needs to be boot strapped again.
|
||
|
# On just one node, the most advanced, if known (e.g. sql1):
|
||
|
galera_new_cluster
|
||
|
|
||
|
# On other nodes sql2 sql3 sql4
|
||
|
service mysql start
|
||
|
|
||
|
# Maybe need on most advanced node:
|
||
|
# sed -i -e 's/safe_to_bootstrap: 0/safe_to_bootstrap: 1/g' /var/lib/mysql/grastate.dat
|