Ubuntu下安装mariaDB 10.1 集群

来源:互联网 发布:电脑远程软件 编辑:程序博客网 时间:2024/06/06 10:47

【环境】
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-commonsudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943dbsudo 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 updatesudo 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 settingswsrep_on=ONwsrep_provider=/usr/lib/galera/libgalera_smm.sowsrep_cluster_address="gcomm://10.0.5.11,10.0.5.12,10.0.5.13"wsrep_sst_auth=tt:tt123binlog_format=rowdefault_storage_engine=InnoDBinnodb_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则表示失败。

0 0