MYSQL InnoDB Cluster

https://dev.mysql.com/doc/refman/5.7/en/group-replication.html

GroupReplication的原理

https://dev.mysql.com/doc/refman/5.7/en/mysql-innodb-cluster-introduction.html

介绍mysql基于innodb引擎的集群

https://dev.mysql.com/doc/refman/5.7/en/mysql-innodb-cluster-userguide.html

mysql基于innodb引擎的集群的用户手册

https://dev.mysql.com/doc/refman/5.7/en/mysql-innodb-cluster-sandbox-deployment.html

mysql基于innodb引擎的集群的沙箱部署方案

 

账号、密码:root root

MYSQL InnoDB Cluster_第1张图片

Beginning configuration step: Preparing InnoDB cluster admin tools...
Preparing InnoDB cluster admin tools...
Creating InnoDB cluster admin tools temp folder...
Extracting InnoDB cluster admin tools...
InnoDB cluster admin tools were extracted successfully.
InnoDB cluster admin tools prepared successfully.
Ended configuration step: Preparing InnoDB cluster admin tools...

Beginning configuration step: Creating sandbox InnoDB cluster instances(check the Log tab for details)
Creating sandbox InnoDB cluster instances...
MySQL InnoDB Cluster Sandbox Setup
==================================
Setting up a MySQL InnoDB cluster with 9 MySQL Server sandbox instances.
The instances will be installed in: 
  Unix-like systems: ~/mysql-sandboxes.
  Windows: %userprofile%\MySQL\mysql-sandboxes
The instances will be running on ports 3310, 3320, 3330, 3340, 3350, 3360, 3370, 3380, 3390.
Deploy sandbox instance at port 3310...
Deploy sandbox instance at port 3320...
Deploy sandbox instance at port 3330...
Deploy sandbox instance at port 3340...
Deploy sandbox instance at port 3350...
Deploy sandbox instance at port 3360...
Deploy sandbox instance at port 3370...
Deploy sandbox instance at port 3380...
Deploy sandbox instance at port 3390...
INFO: Sandbox instances deployed successfully.
Sandbox InnoDB cluster instances created successfully.
Ended configuration step: Creating sandbox InnoDB cluster instances(check the Log tab for details)

Beginning configuration step: Configuring sandbox InnoDB cluster(check the Log tab for details)
Configuring sandbox InnoDB cluster...
Setting up InnoDB cluster...
Waiting till seed instance reaches ONLINE status.
Seed instance reached ONLINE status.
Adding instances to the cluster...
Instances successfully added to the cluster.
Waiting till all instances reach ONLINE status...........
Some instances have not reached ONLINE status yet. Please allow more time for them to catch up to the seed instance.
SUCCESS: InnoDB cluster deployed successfully. Call ic.status() to get status information about the cluster.
Sandbox InnoDB cluster configured successfully.
Deleting InnoDB cluster admin tools temporary directory...
Deleted the InnoDB cluster admin tools temporary directory successfully...
Ended configuration step: Configuring sandbox InnoDB cluster(check the Log tab for details)

Beginning configuration step: Writing configuration file
Ended configuration step: Writing configuration file

Beginning configuration step: Updating Start Menu Link
Attempting to verify command-line client shortcut.
Verified command-line client shortcut.
Verified command-line client shortcut.
Ended configuration step: Updating Start Menu Link
The InnoDB cluster 'sandboxCluster' is available on the following ports:

     localhost:3310 through localhost:3390

To connect with the MySQL Shell execute the following command:

     mysqlsh root@localhost:3310

To bootstrap the MySQL Router execute the following command:

     mysqlrouter --bootstrap root@localhost:3310 --directory router-sandbox

 MYSQL InnoDB Cluster_第2张图片

MYSQL InnoDB Cluster_第3张图片

Beginning configuration step: Removing MySQL Router Windows service [if necessary]
Service successfully removed.

Ended configuration step: Removing MySQL Router Windows service [if necessary]

Beginning configuration step: Creating MySQL Router configuration files
Please enter MySQL password for root: 

Bootstrapping MySQL Router instance at C:/ProgramData/MySQL/MySQL Router...
MySQL Router  has now been configured for the InnoDB cluster 'sandboxCluster'.

The following connection information can be used to connect to the cluster.

Classic MySQL protocol connections to cluster 'sandboxCluster':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447

X protocol connections to cluster 'sandboxCluster':
- Read/Write Connections: localhost:6448
- Read/Only Connections: localhost:6449

Existing configurations backed up to C:/ProgramData/MySQL/MySQL Router/mysqlrouter.conf.bak

Ended configuration step: Creating MySQL Router configuration files

Beginning configuration step: Installing MySQL Router Windows service
Service successfully installed.

Starting MySQL Router Windows service...
Ended configuration step: Installing MySQL Router Windows service

Mysql shell在JavaScript模式下,管理维护集群的命令。

mysql-js> \?
===== Global Commands =====
\help       (\?,\h)    Print this help.
\sql                   Switch to SQL processing mode.
\js                    Switch to JavaScript processing mode.
\py                    Switch to Python processing mode.
\source     (\.)       Execute a script file. Takes a file name as an argument.
\                      Start multi-line input when in SQL mode.
\quit       (\q,\exit) Quit MySQL Shell.
\connect    (\c)       Connect to a server.
\warnings   (\W)       Show warnings after every statement.
\nowarnings (\w)       Don't show warnings after every statement.
\status     (\s)       Print information about the current global connection.
\use        (\u)       Set the current schema for the active session.

For help on a specific command use the command as \? 

===== Global Objects =====
dba        Enables you to administer InnoDB clusters using the AdminAPI.
mysql      Used to work with classic MySQL sessions using SQL.
mysqlx     Used to work with X Protocol sessions using the MySQL X DevAPI.
session    Represents the currently open MySQL session.
shell      Gives access to general purpose functions and properties.
sys        Gives access to system specific parameters.

Please note that MySQL Document Store APIs are subject to change in future
releases.

For more help on a global variable use .help(), e.g. dba.help()

mysql-js> \c root@localhost:3310
Creating a Session to 'root@localhost:3310'
Enter password: ****
Your MySQL connection id is 156
Server version: 5.7.21-log MySQL Community Server (GPL)
No default schema selected; type \use  to set one.
mysql-js> var cluster = dba.getCluster()
mysql-js> cluster.status()
{
    "clusterName": "sandboxCluster",
    "defaultReplicaSet": {
        "name": "default",
        "primary": "localhost:3310",
        "status": "OK",
        "statusText": "Cluster is ONLINE and can tolerate up to 4 failures.",
        "topology": {
            "localhost:3310": {
                "address": "localhost:3310",
                "mode": "R/W",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3320": {
                "address": "localhost:3320",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3330": {
                "address": "localhost:3330",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3340": {
                "address": "localhost:3340",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3350": {
                "address": "localhost:3350",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3360": {
                "address": "localhost:3360",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3370": {
                "address": "localhost:3370",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3380": {
                "address": "localhost:3380",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3390": {
                "address": "localhost:3390",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            }
        }
    }
}
mysql-js>

 

mysql启用了mysql X Protocol和classic两种协议,支持Client与Server建立会话。

  • The mysqlx module contains a complete development API to interact with MySQL Servers using a session through the X Protocol.
  • The mysql module contains a lightweight development API to interact with MySQL Servers using a classic session.

MYSQL InnoDB Cluster_第4张图片

上述组复制方案,采用的标准的一主多从复制方案的集群配置。

多主复制以及循环复制的配置方案,可参考:https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-replication-multi-master.html

 

一篇更全面的参考文章:https://mysqlserverteam.com/mysql-innodb-cluster-setting-up-innodb-cluster-on-windows/

 

你可能感兴趣的:(数据库,shell,javascript,ViewUI)