Ubuntu下安装mariaDB 10.1 集群

前端之家收集整理的这篇文章主要介绍了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

  1. sudo apt-get install software-properties-common
  2. sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
  3. 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'
  1. sudo apt-get update
  2. sudo apt-get install rsync mariadb-server

注意:
1.安装过程会提示输入MariaDB的root密码
2.MariaDB 10.1及之后的版本默认自带galera cluster,不需要另行安装。

配置MariaDB集群用户

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

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

  1. [galera]
  2. # Mandatory settings
  3. wsrep_on=ON
  4. wsrep_provider=/usr/lib/galera/libgalera_smm.so
  5. wsrep_cluster_address="gcomm://10.0.5.11,10.0.5.12,10.0.5.13"
  6. wsrep_sst_auth=tt:tt123
  7. binlog_format=row
  8. default_storage_engine=InnoDB
  9. innodb_autoinc_lock_mode=2
  10. #
  11. # Allow server to accept connections on all interfaces.
  12. #
  13. bind-address=0.0.0.0
  14. #
  15. # Optional setting
  16. #wsrep_slave_threads=1
  17. #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中执行:

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

显示

  1. +--------------+
  2. | cluster size | +--------------+
  3. | 3 | +--------------+

如果数字为3则表示集群成功,如为1则表示失败。

猜你在找的Ubuntu相关文章