首页 技术 正文
技术 2022年11月16日
0 收藏 815 点赞 4,955 浏览 4271 个字

先说三个大步骤:

搭Mysql5.7 Group Replication ,配置成单主模式

安装Mysqlshell,配innodbcluster

安装Mysql-router

第一步:搭Mysql5.7 Group Replication ,配置成单主模式

为了节省步骤,我们用RPM方式安装

yum install -y libaioyum install libnuma* -y
rpm -qa | grep -i mysql # 这一步找到旧的mysql
rpm -e mysql-libs-5.1.-.el6_8.x86_64 --nodeps #我测试的实例上只有这个,删了
rpm -ivh mysql-community-common-5.7.-.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.-.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.-.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.-.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.-.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-5.7.-.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.-.el6.x86_64.rpm
rpm -qa | grep mysql #验证

拷贝cnf.和服务文件

cp mysqld33* /etc/init.d/
cp -r mysql33* /home/wokofo/

配置文件:

[mysqld]
#skip-grant-tables=
datadir=/home/wokofo/mysql3306/data
socket=/home/wokofo/mysql3306/mysql.sock
log-error=/home/wokofo/mysql3306/mysqld.log
pid-file=/home/wokofo/mysql3306/mysqld.pid
port=
symbolic-links=
user = mysql
server_id =
skip_sslgtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE
relay_log_info_repository = TABLE
binlog_checksum = NONE
log_slave_updates = ON
log_bin = binlog
binlog_format = ROW
expire_logs_days=
relay_log=relay-log
character_set_server=utf8mb4
max_connections=
open_files_limit=
slow_query_log=long_query_time=1.000
skip_name_resolve=on
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
max_allowed_packet=transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name="81125aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address="172.16.81.127:13306"
loose-group_replication_group_seeds="172.16.81.125:13306,172.16.81.126:13306,172.16.81.127:13306"
loose-group_replication_ip_whitelist = "127.0.0.1,172.16.0.1/16"

启动服务:

在主节点上执行:

set sql_log_bin=;
grant replication slave,replication client on *.* to 'repluser'@'%' identified by '*************';
flush privileges;
set sql_log_bin=;install plugin group_replication soname 'group_replication.so';change master to master_user='repluser',master_password='***********************' for channel 'group_replication_recovery';
set global group_replication_bootstrap_group=ON;
START group_replication;
set global group_replication_bootstrap_group=OFF;
exit;

其他节点上执行:

change master to master_user='repluser',master_password='****************' for channel 'group_replication_recovery'; #这一步如果不是空库,需要自己调
set global group_replication_allow_local_disjoint_gtids_join=ON;
START group_replication;

任意节点上执行

select * from performance_schema.replication_group_members;

验证成功,步骤一完成,GR集群搭建成功

第二步:安装Mysqlshell,配innodbcluster

rpm -ivh mysql57-community-release-el6-.noarch.rpm
yum install -y mysql-shell
python -V #如果低于2.7需要升级
mysqlsh --uri dba@172.16.81.125:3306
Creating a Session to 'dba@172.16.81.125:3306'
Enter password:mysql-js> var cluster=dba.createCluster('fvt01',{adoptFromGR:true});
A new InnoDB cluster will be created on instance 'dba@172.16.81.125:3306'.Creating InnoDB cluster 'fvt01' on 'dba@172.16.81.125:3306'...
Adding Seed Instance...Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.mysql-js> cluster.status()
{
"clusterName": "fvt01",
"defaultReplicaSet": {
"name": "default",
"primary": "172.16.81.125:3306",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"172.16.81.125:3306": {
"address": "172.16.81.125:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"l-fvt-mysql2.beta0.cn2:3306": {
"address": "l-fvt-mysql2.beta0.cn2:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"l-fvt-mysql3.beta0.cn2:3306": {
"address": "l-fvt-mysql3.beta0.cn2:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
}
}
mysql-js> dba.configureLocalInstance("dba@127.0.0.1:3306")
Please provide the password for 'dba@127.0.0.1:3306':Detecting the configuration file...
Default file not found at the standard locations.
Please specify the path to the MySQL configuration file: /home/wokofo/mysql3306/my.cnf
Validating instance...The instance '127.0.0.1:3306' is valid for Cluster usage
You can now use it in an InnoDB Cluster.{
"status": "ok"
}
mysql-js> ctrl c
Bye!

第三步:安装Mysql-router

yum install mysql-routermysqlrouter --bootstrap 172.16.28.105
chown mysql:mysql /etc/mysqlrouter/mysqlrouter.confcd /usr/local/
mysqlrouter --bootstrap dba@172.16.81.125: --directory myrouter --user mysql --force
cd myrouter/cat mysqlrouter.confsh start.shnetstat -anp |grep router
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,077
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,401
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,813
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,896