Mariadb10 Galera 实验小结

Mariadb10 Galera 实验小结
三台服务器做此实验,信息以下:
IP 机器名称 操做系统版本 数据库版本
192.168.88.11 node1 Centos7.5_64 mariadb10
192.168.88.12 node2 Centos7.5_64 mariadb10
192.168.88.13 node3 Centos7.5_64 mariadb10
1、Mariadb10 Galera 初始化准备
一、初始化环境(三台机器上都操做)
A)安装相关的环境包:yum -y install vim wget lrzsz ntpdate
B)同步时间:ntpdate -u times.aliyun.com
C)修改各自主机名:(在每一个机器上设置好)
第一台机器:hostname node1 && echo ‘node1’> /etc/hostname 退出后从新登陆就能够了
第二台机器:hostname node2 && echo ‘node2’> /etc/hostname 退出后从新登陆就能够了
第三台机器:hostname node3 && echo ‘node3’> /etc/hostname 退出后从新登陆就能够了
D)vim /etc/hosts文件,加入如下内容:
192.168.88.11 node1
192.168.88.12 node2
192.168.88.13 node3
E)增长mariadb 10版本源
vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
pgcheck=0
说明:因为从maradb官方网站下载很慢,此处以国内镜像为源
F)安装MariaDB和Galera
yum -y install MariaDB-server MariaDB-client MariaDB-devel galera
G)MariaDB 10安装后初始化配置
systemctl start mysql
mysql_secure_installation
mysql -u root -p --登陆数据后进进行受权
MariaDB [(none)]> GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit
受权完成后把数据库服务停掉
systemctl stop mysql
2、在各个结点上进行Cluster的安装配置
A)on node1
编辑/etc/my.conf.d/server.conf
vim /etc/my.conf.d/server.conf 在 [galera]下面加入如下内容
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.88.12,192.168.88.13"
wsrep_node_name=node1
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
wsrep_cluster_name="MariaDB_Cluster"
wsrep_node_address=192.168.88.11
wsrep_sst_method=rsync
wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=1024M
wsrep_sst_auth=root:password
B)on node2
编辑/etc/my.conf.d/server.conf
vim /etc/my.conf.d/server.conf 在 [galera]下面加入如下内容
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.88.11,192.168.88.13"
wsrep_node_name=node2
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
wsrep_cluster_name="MariaDB_Cluster"
wsrep_node_address=192.168.88.12
wsrep_sst_method=rsync
wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=1024M
wsrep_sst_auth=root:password
C)on node3
编辑/etc/my.conf.d/server.conf
vim /etc/my.conf.d/server.conf 在 [galera]下面加入如下内容
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.88.11,192.168.88.12"
wsrep_node_name=node3
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
wsrep_cluster_name="MariaDB_Cluster"
wsrep_node_address=192.168.88.13
wsrep_sst_method=rsync
wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=1024M
wsrep_sst_auth=root:password
3、在各个结点上启动Cluster
A)在node1上启动Cluster: /usr/sbin/mysqld --wsrep-new-cluster --user=root
B)在node2上启动Cluster: /etc/init.d/mysql start
B)在node3上启动Cluster: /etc/init.d/mysql start
4、在各个结点上登陆Cluster进行验证
任意结点登陆数据库,获得如下结果说明Cluster成功
Mariadb10  Galera 实验小结
5、问题搜集
碰见的问题1: 备点加入集群一直失败
缘由:在生产环境中必须打开防火墙,可是我只开放了 4567 和 针对指定ip开放3306 端口,致使加入集群失败,须要开放 3306, 4444, 4567, 4568 四个端口才能够正常启动
碰见的问题2 :遇到如下提示
2019-02-20 13:59:56 140697295214848 [ERROR] WSREP: It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates. To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1 .
2019-02-20 13:59:56 140697295214848 [ERROR] WSREP: wsrep::connect(gcomm://192.168.8811,192.168.88.13) failed: 7
2019-02-20 3:59:56 140697295214848 [ERROR] Aborting
解决方案: 按照建议方式修改 vi /var/lib/mysql/grastate.dat
safe_to_bootstrap: 1
能够正常启动。
6、优缺点:引用自http://blog.sina.com.cn/s/blog_548c8a830102vrgw.htm0l
下篇文章写MySQL使用ProxySQL实现读写分离,以上是在项目文档基础上的我的总结,都是直接能够上手用的哈,固然IP地址所有更换为内网IP。node

相关文章
相关标签/搜索