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则表示失败。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值