1.安装MariaDB 和Galera
见另外一篇博客
2.环境修改
2.1 防火墙和SELinux
这里不做说明,参照网上教程,和官方的配置
2.2. 创建用于节点同步的账号
[root@localhost ~]# mysql -uroot -p
MariaDB [(none)]> grant usage on *.* to sst@'%' identified by 'ssTT-488';
MariaDB [(none)]> flush privileges;
2.3. 修改mysql默认字符集
MariaDB [(none)]> show variables like 'character%';
MariaDB [(none)]> set character_set_server = utf8;
MariaDB [(none)]> set character_set_database = utf8;
3.配置相关的参数
http://galeracluster.com/documentation-webpages/training/tutorials/migration.html
http://galeracluster.com/documentation-webpages/training/tutorials/configuration.html
http://galeracluster.com/documentation-webpages/training/tutorials/wsrep-configuration.html
https://mariadb.com/kb/en/library/configuring-mariadb-galera-cluster/
注意:
1.启动第一个节点用的是命令:galera_new_cluster
2.遇到错误查看日志:journalctl -xe
3.参照的一篇博客:https://www.cnblogs.com/liujiduo/p/5066803.html
4.没有很多东西了,配置文件 /etc/my.cnf 很重要
4.相关命令实例 文件位置 /etc/my.cnf
[mysqld]
binlog_format = ROW
#bind-address = 192.168.126.129
default_storage_engine = innodb
innodb_autoinc_lock_mode = 2
innodb_flush_log_at_trx_commit = 0
innodb_buffer_pool_size = 122M
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_provider_options ="gcache.size = 300M; gcache.page_size = 300M"
wsrep_cluster_name ="MyCluster"
wsrep_cluster_address="gcomm://192.168.126.129"
wsrep_sst_method = rsync
wsrep_node_name = Node11
wsrep_node_address ="192.168.126.129"
wsrep_sst_auth=sst:ssTT-488
wsrep_on=ON
注意:1.wsrep_provider 路径以系统中实际文件路径为准
2.wsrep_cluster_address 后面的参数没有空格,实例中有的是有空格的,把空格去掉
5.检查是否启动成功
命令:mysql -u root -p 登录MariaDB 数据库