Ubuntu下安裝mariaDB 10.1 集羣

【環境】
Ubuntu 14.04
MariaDB 10.1 stable

【機器】
host-1: 10.0.5.11
host-2: 10.0.5.12
host-3: 10.0.5.13

<以下操作爲host-1 2 3都有>
MariaDB官方安裝嚮導:
https://downloads.mariadb.org/mariadb/repositories/#mirror=yamagata-university
安裝MariaDB 10.1

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/10.1/ubuntu trusty main'
sudo apt-get update
sudo apt-get install rsync mariadb-server

注意:
1.安裝過程會提示輸入MariaDB的root密碼
2.MariaDB 10.1及之後的版本默認自帶galera cluster, 不需要另行安裝。

配置MariaDB集羣用戶:

GRANT USAGE ON *.* to tt@'%' IDENTIFIED BY 'tt123';  
GRANT ALL PRIVILEGES on *.* to tt@'%';  
GRANT USAGE ON *.* to tt@'localhost' IDENTIFIED BY 'tt123';  
GRANT ALL PRIVILEGES on *.* to tt@'localhost';  
flush privileges;  

修改/etc/mysql/my.cnf文件中的[galera]部分如下:

[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://10.0.5.11,10.0.5.12,10.0.5.13"
wsrep_sst_auth=tt:tt123
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

注意:以上操作在host-1 2 3中均要執行

啓動測試:
確保所有節點mysql服務爲stop狀態
host-1執行:service mysql start --wsrep-new-cluster
host-2執行:service mysql start
host-3執行:service mysql start

驗證集羣是否成功:
在host-1中執行:

mysql -u root -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"' -p<password>

如顯示:

+--------------+
| cluster size |
+--------------+
| 3            |
+--------------+

如果數字爲3則表示集羣成功,如爲1則表示失敗。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章