mysql shell安装 mysql8.0 MGR
1.节点信息
hostname
IP地址
mysql MGR
mysql1
172.16.230.51
mysql2
172.16.230.52
mysql3
172.16.230.53
2.三个节点安装mysql8实例
3.每个节点初始化mysql账号
create user 'fengjian'@'%' identified by '123456';
grant all on *.* to 'fengjian'@'%' with grant option;
4. 下载mysqlshell
[root@mysql1 ~]# wget https://cdn.mysql.com//Downloads/MySQL-Shell/mysql-shell-8.0.23-linux-glibc2.12-x86-64bit.tar.gz
[root@mysql1 ~]# tar -zxvf mysql-shell-8.0.23-linux-glibc2.12-x86-64bit.tar.gz
[root@mysql1 ~]# mv mysql-shell-8.0.23-linux-glibc2.12-x86-64bit /usr/local/mysqlshell
[root@mysql3 ~]# chown -R mysql.mysql /usr/local/mysqlshell
5.拷贝mysqlshell到其他节点
[root@mysql1 ~]#scp - /usr/local/mysqlshell root@172.16.230.52:/usr/local/
[root@mysql2 ~]#chown -R mysql.mysql /usr/local/mysqlshell
[root@mysql1 ~]# scp - /usr/local/mysqlshell root@172.16.230.52:/usr/local/
[root@mysql3 ~]# chown -R mysql.mysql /usr/local/mysqlshell
6.利用mysqlshell构建MGR
[root@mysql1 ~]# /usr/local/mysqlshell/bin/mysqlsh
# 链接一个mysql节点
shell.connect('fengjian@172.16.230.51:3306')
#定义一个集群
var cluster = dba.createCluster('SenyintCluster')
# 其他节点实例加入到集群
cluster.addinstance('fengjian@172.16.230.52:3306')
cluster.addinstance('fengjian@172.16.230.53:3306')
#查看集群状态
cluster.status()
# 当链接超时需要 重新链接
MySQL 172.16.230.51:3306 ssl JS shell.connect('fengjian@172.16.230.51:3306')
#cluster 表示获取
var cluster = dba.getCluster('SenyintCluster')
报错信息:
MySQL 172.16.230.51:3306 ssl JS var cluster=dba.createCluster('SenyintCluster')
A new InnoDB cluster will be created on instance '172.16.230.51:3306'.
Validating instance configuration at 172.16.230.51:3306...
This instance reports its own address as mysql1:3306
NOTE: Some configuration options need to be fixed:
+-----------------------------+---------------+----------------+----------------------------+
| Variable | Current Value | Required Value | Note |
+-----------------------------+---------------+----------------+----------------------------+
| slave_preserve_commit_order | OFF | ON | Update the server variable |
+-----------------------------+---------------+----------------+----------------------------+
NOTE: Please use the dba.configureInstance() command to repair these issues.
ERROR: Instance must be configured and validated with dba.checkInstanceConfiguration() and dba.configureInstance() before it can be used in an InnoDB cluster.
Dba.createCluster: Instance check failed (RuntimeError)
修复:
set global slave_preserve_commit_order = 1;
数据复制:分两种情况
1. 正常复制通道group_replication_applier状态: online无延迟状态下复制
2. 延迟复制通道 group_replication_recovery出现在复制延迟扬中,MGR节点退化recovery状态,SQL_Thread从relay_log中应用数据.
多主模式如何实现多点写入(multi-master)
1.修改了每个节点的 auto_increment_offset, auto_increment_increment
2.每个节点一个独立的GTID区间
3.实现同一条数据,同时一时间只能在一个节点上update,同时下次修改必须保证前面的数据应用完毕
MySQL 172.16.230.51:3306 ssl JS cluster.status()
{
"clusterName": "SenyintCluster",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql1:3306",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"mysql1:3306": {
"address": "mysql1:3306",
"mode": "R/W",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.22"
},
"mysql2:3306": {
"address": "mysql2:3306",
"mode": "R/O",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.22"
},
"mysql3:3306": {
"address": "mysql3:3306",
"mode": "R/O",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.22"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "mysql1:3306"
}
mysqlshell 切换成multi-master模式
MySQL 172.16.230.51:3306 ssl JS cluster.switchToMultiPrimaryMode()
Switching cluster 'SenyintCluster' to Multi-Primary mode...
Instance 'mysql1:3306' remains PRIMARY.
Instance 'mysql2:3306' was switched from SECONDARY to PRIMARY.
Instance 'mysql3:3306' was switched from SECONDARY to PRIMARY.
The cluster successfully switched to Multi-Primary mode.
mysql shell安装 mysql8.0 MGR 相关文章
安装dockerdocker安装MySql、Redis
安装docker 进入docker官网找到安装的centos系统,按官方文档进行安装,链接地址是https://docs.docker.com/engine/install/centos/ #卸载旧版本$ sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker
Django-manage.py shell命令
1、进入shell模式 python3 manage.py shell 2、基本数据访问 from loginApp.models import Event,Guest #导入loginAPP应用下的models.py中的event和guest表Event.objects.all() #获取event表中的所有对象Guest.objects.all() 2、插入数据 e1 = Event(id=2,na
超详细的MySQL数据库优化知识梳理
1 常见问题 阻塞 慢查询 2 可以从以下几个方面入手 服务器硬件优化 系统配置优化 数据库结构优化 SQL和索引 通常优化3和4 3 慢查询日志 show variables like 'slow_query_log';# 开启慢查询日志set global slow_query_log=on;# 查询慢查询日志文件存放的位置
MySQL-DDL:逻辑库与表管理
DDL语句 数据库模式定义语言 DDL ( Data Definition Language ),用于描述数据库中要存储的实体,包括结构定义、操作方法定义等。 1、逻辑库管理 语句 说明 CREATE DATABASE 逻辑库名; 创建逻辑库 SHOW DATABASES; 显示所有逻辑库 DROP DATABASE 逻辑库名;
MySQL数据库的安装与使用
MySQL数据库 概要 一、 MySQL数据库的概述二、 MySQL数据库的搭建(重点)三、 MySQL数据库软件的使用四、 MySQL数据类型五、 MySQL数据库数据的操作(重点) 一、初识MySQL数据库 1. 数据库的概述 1 数据库:Database 长期存储在计算机内的,有组织的,可共享的
ClickHouse集群搭建(二)
分布式集群安装 在上一章我们已经完成 ClickHouse 分布式集群安装,也创建本地表和分布式表进行了测试,但是,假如停掉一个节点会发生神马情况? node03 上 kill 掉 clickhouse-server 进程 [root@node03 ~]# ps -ef | grep clickhouseclickho+ 2233 1 73 13:
eladmin后台管理系统
分享的项目从安装部署到代码具体功能都有很详细都说明 eladmin 是一款基于 Spring Boot 2.1.0 、 Jpa、 Spring Security、redis、Vue 的前后端分离的后台管理系统,项目采用分模块开发方式, 权限控制采用 RBAC,支持数据字典与数据权限管理,支持一键生成前
mysql中时间的使用
1、mysql中获取当前日期 1、SELECT CURRENT_TIMESTAMP() 返回:2021-02-10 15:03:472、SELECT CURRENT_TIME() 返回:15:04:383、SELECT CURRENT_DATE() 返回:2021-02-104、SELECT NOW() 返回:2021-02-10 15:06:335、SELECT CURDATE() 返回:2021-02-106、S
十二、执行计划分析
MySQL在执行语句时会使用多种算法方案,最终会从中选择效率最高的方案执行我们的sql语句。 获取执行方案 #将sql语句放在desc后面,可以得到该sql语句的执行计划,并不是执行sql语句,对系统性能无影响mysql desc select * from vote_record where user_id='t
jdbc连接MySql数据库
jdbc连接MySql数据库 package com.zhy;import com.mysql.jdbc.Driver;import java.sql.*;/** * @author ZHY * @data 2021/2/15 */public class TestJdbc { public static void main(String[] args) throws ClassNotFoundException, SQLException { //0、配置