NDB
InnoDB
dba
dba.createCluster()
dba
object.help('methodname')
MySQL的JS > dba.help('getCluster')
从检索元数据store.syntax DBA群集。getcluster([名] [选项]),名称:参数指定要返回的群集的名称。选项:字典与额外的options.returns没有指定的名字或默认cluster.descriptionif名称识别聚类对象或为空,默认群集将被返回。如果名字是指定的,以显示名称不群被发现,一个误差提高。选项字典接受connecttoprimary选项,默认的真实并指出内核自动连接到在以下情形下的主要成员,cluster.exceptions metadataerror:如果元数据访问。如果元数据更新操作失败。在下列情况下argumenterror:如果群集名称是空的。如果群集名无效。如果群集是不存在的。在下列情况下运行时出错:如果当前连接不能用于组复制。
dba.checkInstanceConfiguration()
InnoDB
MyISAM
InnoDB
$ /usr/bin/env python
/usr/bin/python
SUPER
CREATE
clusterAdmin
Cluster.addInstance()
your_user
格兰特选择mysql_innodb_cluster_metadata。* your_user@'%'
格兰特performance_schema.global_status来选择; your_user@'%'
格兰特performance_schema.replication_applier_configuration来选择; your_user@'%'
格兰特performance_schema.replication_applier_status来选择; your_user@'%'
格兰特performance_schema.replication_applier_status_by_coordinator来选择; your_user@'%'
格兰特performance_schema.replication_applier_status_by_worker来选择; your_user@'%'
格兰特performance_schema.replication_connection_configuration来选择; your_user@'%'
格兰特performance_schema.replication_connection_status来选择; your_user@'%'
格兰特performance_schema.replication_group_member_stats来选择; your_user@'%'
格兰特performance_schema.replication_group_members来选择; your_user@'%'
格兰特performance_schema.threads来选择; your_user@'%'
授予期权;
report_host
ic-
number
SELECT coalesce(@@report_host, @@hostname);
SET
PERSIST
dba.configureInstance()
dba.createCluster()
Cluster
.addInstance()
Cluster
.removeInstance()
Cluster
.rejoinInstance()
persisted_globals_load
WARNING: On instance 'localhost:3320' membership change cannot be persisted since MySQL version 5.7.21 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please use the <Dba>.configureLocalInstance command locally to persist the changes.
mysqld-auto.cnf
mysql-auto.conf
--log-level
内核> mysqlsh --log-level=DEBUG3
DEBUG3
--log-level
Debug:
execute_sql( ... )
%APPDATA%\MySQL\mysqlsh\mysqlsh.log
mysql-js> dba.verbose=2
dba.configureInstance()
dba.configureInstance()
dba.configureInstance()
[ dba.configureinstance( instance
] [, options
])
instance
options
mycnfPath
outputMycnfPath
password
clusterAdmin
clusterAdminPassword
clearReadOnly
super_read_only
interactive
restart
password
dba.configureInstance()
dba.configureInstance()
Variable
Current Value
Required Value
dba.configureInstance()
dba.configureInstance()
RESTART
RESTART
RESTART
dba.configureInstance()
clusterAdmin
mysql-js> dba.configureInstance('ic@ic-1:3306', \
{clusterAdmin: 'icadmin@ic-1%',clusterAdminPassword: 'password
'});
clusterAdmin
mysql-js> dba.configureLocalInstance('root@localhost:3306')
Please provide the password for 'root@localhost:3306':
Please specify the path to the MySQL configuration file: /etc/mysql/mysql.conf.d/mysqld.cnf
Validating instance...
The configuration has been updated but it is required to restart the server.
{
"config_errors": [
{
"action": "restart",
"current": "OFF",
"option": "enforce_gtid_consistency",
"required": "ON"
},
{
"action": "restart",
"current": "OFF",
"option": "gtid_mode",
"required": "ON"
},
{
"action": "restart",
"current": "0",
"option": "log_bin",
"required": "1"
},
{
"action": "restart",
"current": "0",
"option": "log_slave_updates",
"required": "ON"
},
{
"action": "restart",
"current": "FILE",
"option": "master_info_repository",
"required": "TABLE"
},
{
"action": "restart",
"current": "FILE",
"option": "relay_log_info_repository",
"required": "TABLE"
},
{
"action": "restart",
"current": "OFF",
"option": "transaction_write_set_extraction",
"required": "XXHASH64"
}
],
"errors": [],
"restart_required": true,
"status": "error"
}
mysql-js>
super_read_only=ON
super_read_only=OFF
dba.createCluster()
dba.createCluster(
name
)name
mysql-js> var cluster = dba.createCluster('testCluster')
Validating instance at ic@ic-1:3306...
This instance reports its own address as ic-1
Instance configuration is suitable.
Creating InnoDB cluster 'testCluster' on 'ic@ic-1: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.
super_read_only=ON
super_read_only=OFF
status()
server_uuid
cluster.addInstance(
instance
)instance
mysql-js> cluster.addInstance('ic@ic-2:3306')
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.
Please provide the password for 'ic@ic-2:3306': ********
Adding instance to the cluster ...
Validating instance at ic-2:3306...
This instance reports its own address as ic-2
Instance configuration is suitable.
The instance 'ic@ic-2:3306' was successfully added to the cluster.
status()
MySQL的JS > cluster.status()
{“:”testcluster集群名“{”、“defaultreplicaset”:“名字”:“默认”,“主”:“本地:3310”、“SSL”:“需要”、“状态”:“不好_ _ tolerance”、“statustext”:“is not to any故障容错群集。“拓扑”:{“localhost”:3310:{“地址”:“本地:3310”、“模式”:“readreplicas R / W”、“角色”:“{ }”:“有”,“状态”:“网络”},“localhost”:3320 {“地址”:“本地:3320”、“模式”:“R”或“{ },readreplicas”:“角色”:“有”,“身份”}:“在线”、“groupinformationsourcemember”:“MySQL”:/ /根本地:3310”}
super_read_only=ON
super_read_only=OFF
dba
shell> mysqlsh
\js
\sql
mysql-js> dba.deploySandboxInstance(3310)
deploySandboxInstance()
port
port
mysql-js> dba.deploySandboxInstance(port_number
)
mysql-js>dba.deploySandboxInstance(
mysql-js>3320
)dba.deploySandboxInstance(
3330
)
mysql-js> \connect root@localhost:3310
\connect
mysql-js> shell.connect('root@localhost:3310')
dba.createCluster()
MySQL的JS > var cluster = dba.createCluster('testCluster')
createCluster()
cluster
testCluster
super_read_only=ON
super_read_only=OFF
mysql-js> cluster.addInstance('root@localhost:3320')
mysql-js> cluster.addInstance('root@localhost:3330')
localhost
addInstance()
status()
adoptFromGR
gr-member-2
dba.createCluster()
mysql-js> var cluster = dba.createCluster('prodCluster', {adoptFromGR: true});
A new InnoDB cluster will be created on instance 'root@gr-member-2:3306'.
Creating InnoDB cluster 'prodCluster' on 'root@gr-member-2: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.
super_read_only=ON
super_read_only=OFF
--bootstrap
--bootstrap
--bootstrap
内核> mysqlrouter --bootstrap ic@ic-1:3306 --user=mysqlrouter
mysqlrouter.conf
--bootstrap
mysqlrouter.conf
bootstrap_server_addresses
[metadata_cache:prodCluster]router_id=1bootstrap_server_addresses=mysql://ic@ic-1:3306,mysql://ic@ic-2:3306,mysql://ic@ic-3:3306user=mysql_router1_jy95yozko3k2metadata_cluster=prodClusterttl=300
bootstrap_server_addresses
--bootstrap
bootstrap_server_addresses
6446
6447
64460
64470
--conf-base-port
group_replication_single_primary_mode
routing_strategy
--bootstrap
内核> mysqlrouter &
--directory
shell> mysqlsh --uri root@localhost:6442
port
MySQL的JS > \sql
切换到SQL模式…命令结束;MySQL的SQL > select @@port;
-------- | @ @港| -------- | 3310 | --------
server_uuid
dba.killSandboxInstance()
MySQL的JS > dba.killSandboxInstance(3310)
\sql
port
SELECT
MySQL的JS > \sql
切换到SQL模式…命令结束;MySQL的SQL > SELECT @@port;
错误:2013(hy000):查询全球会议期间丢失连接到MySQL服务器断开了。正在尝试重新连接到' root@localhost:6446…全球会议成功连接MySQL的SQL >。 SELECT @@port;
-------- | @ @港| -------- | 3330 | -------- 1行集(0秒)
--bootstrap
dba.configureInstance()
mysql-js> dba.checkInstanceConfiguration('ic@ic-1:3306')
Please provide the password for 'ic@ic-1:3306': ***
Validating MySQL instance at ic-1:3306 for use in an InnoDB cluster...
This instance reports its own address as ic-1
Clients and other cluster members will communicate with it through this address by default.
If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
Some configuration options need to be fixed:
+--------------------------+---------------+----------------+--------------------------------------------------+
| Variable | Current Value | Required Value | Note |
+--------------------------+---------------+----------------+--------------------------------------------------+
| binlog_checksum | CRC32 | NONE | Update the server variable |
| enforce_gtid_consistency | OFF | ON | Update read-only variable and restart the server |
| gtid_mode | OFF | ON | Update read-only variable and restart the server |
| server_id | 1 | | Update read-only variable and restart the server |
+--------------------------+---------------+----------------+--------------------------------------------------+
Please use the dba.configureInstance() command to repair these issues.
{
"config_errors": [
{
"action": "server_update",
"current": "CRC32",
"option": "binlog_checksum",
"required": "NONE"
},
{
"action": "restart",
"current": "OFF",
"option": "enforce_gtid_consistency",
"required": "ON"
},
{
"action": "restart",
"current": "OFF",
"option": "gtid_mode",
"required": "ON"
},
{
"action": "restart",
"current": "1",
"option": "server_id",
"required": ""
}
],
"errors": [],
"status": "error"
}
dba.checkInstanceConfiguration()
config_error
dba.configureLocalInstance()
dba.configureInstance()
dba.createCluster()
Cluster
.addInstance()
Cluster
.removeInstance()
Cluster
.rejoinInstance()
--uri
instance
内核> sudo -i mysqlsh --uri=
instance
\connect
instance
instance
MySQL dba.configurelocalinstance JS >(@:3306 IC IC 2)
dba.createCluster()
name
options
MySQL的JS > var cluster1 = dba.getCluster()
name
connectToPrimary
true
false
connectToPrimary
connectToPrimary
connectToPrimary
MySQL的JS > shell.connect(secondary_member)
MySQL的JS > var cluster1 = dba.getCluster(testCluster, {connectToPrimary:false})
super_read_only=ON
status()
ONLINE
status()
MySQL的JS > var cluster = dba.getCluster()
MySQL的JS > cluster.status()
{ "clusterName": "testcluster", "defaultReplicaSet": { "name": "default", "primary": "ic-1:3306", "ssl": "REQUIRED", "status": "OK", "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.", "topology": { "ic-1:3306": { "address": "ic-1:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "ic-2:3306": { "address": "ic-2:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "ic-3:3306": { "address": "ic-3:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE" } } }, "groupInformationSourceMember": "mysql://ic@ic-1:3306"}
cluster.status()
dba.createCluster()
REQUIRED
memberSslMode
addInstance()
group_replication_ssl_mode
ONLINE
OFFLINE
RECOVERING
UNREACHABLE
ERROR
ERROR
super_read_only
ERROR
super_read_only=OFF
(MISSING)
MISSING
R/W
cluster.describe()
MySQL的JS > cluster.describe();
{“clusterName”:“testcluster”、“defaultreplicaset”:{“名字”:“默认”、“拓扑”:[ {“地址”:“ic-1:3306”、“标签”:“ic-1:3306”、“角色”:“哈”},{“地址”:“ic-2:3306”、“标签“:”ic-1:2306”、“角色”:“哈”},{“地址”:“ic-3:3306”、“标签”:“ic-3:3306”、“角色”:“哈”} } } ]
super_read_only
super_read_only=OFF
dba.configureInstance()
dba.configureLocalInstance()
dba.createCluster()
dba.rebootClusterFromCompleteOutage()
dba.dropMetadataSchema()
super_read_only=ON
super_read_only=OFF
MySQL的JS > var myCluster = dba.createCluster('testCluster')
一个新的InnoDB集群将实例“IC”ic-1:3306 '创建。MySQL实例在IC @ ic-1:3306”目前已设置为防止无意更新应用的super_read_only系统变量。你必须先取消它能够执行任何改变这种情况。更多信息见:http:/ / dev.mysql。COM /医生/ refman / EN /服务器系统变量。HTML # sysvar_super_read_only.note:有公开的会议“IC”ic-1:3306’。你可能想杀死这些会话以防止他们表演意想不到的更新:1打开会话(S)“IC”ic-1:3306 '。你想禁用super_read_only并继续吗?【Y | n ]:
y
super_read_only=OFF
super_read_only=OFF
true
instance
dba.stopSandboxInstance(
instance
)instance
dba.startSandboxInstance(
instance
)
dba.killSandboxInstance(
instance
)
dba.deleteSandboxInstance(
instance
)
Cluster
.removeInstance(instance
)
MySQL的JS > cluster.removeInstance('root@localhost:3310')
实例将从群集中删除InnoDB。根据instancebeing种子或没有,元数据的会话可能成为无效。如果是这样的话,pleasestart新会话的元数据存储的R / W的实例,试图从组复制组…离开实例的本地:3310成功从群集中删除。
interactive
cluster
dba.gtidWaitTimeout
dba.gtidWaitTimeout
false
force
force
Cluster
instance
force
dba.createCluster()
groupName
group_replication_group_name
localAddress
cluster.addInstance()
host
port
group_replication_local_address
groupSeeds
cluster.addInstance()
host2:port2
group_replication_group_seeds
cluster.rejoinInstance()
cluster.rejoinInstance()
super_read_only=ON
super_read_only=OFF
cluster.forceQuorumUsingPartitionOf()
/ /打开一个clustermysql JS > cluster = dba.getCluster("prodCluster")
/ /群集失去仲裁,其状态显示/“身份”:“no_quorum MySQL js“> cluster.forceQuorumUsingPartitionOf("localhost:3310")
恢复replicaset默认从损失的群体,由[本地分区:3310 ]请提供密码“root@localhost:3310:******恢复InnoDB集群…InnoDB集群成功恢复使用实例的root@localhost分区:3310”。警告:为避免脑裂的情况,确保所有其他成员的replicaset除去或加入到组,恢复。
dba.rebootClusterFromCompleteOutage()
mysql-js> dba.startSandboxInstance(3310)mysql-js> dba.startSandboxInstance(3320)mysql-js> dba.startSandboxInstance(3330)
mysql-js> shell.connect('root@localhost:3310');
mysql-js> var cluster = dba.rebootClusterFromCompleteOutage();
super_read_only=ON
super_read_only=OFF
dba.dropMetadataSchema()
dba.dropMetadataSchema()
cluster.rescan()
cluster.rescan()
cluster.rejoin('ic@ic-4:3306')
cluster.checkInstanceState()
mysql-js> cluster.checkInstanceState('ic@ic-4:3306')
Cluster.dissolve()
dba.createCluster()
MySQL的JS > session
<ClassicSession:root@localhost:3310>mysql-js>cluster.dissolve({force:true})
集群成功溶解。复制是残疾但用户数据被原封不动。
cluster.dissolve()
ipWhitelist
dba.createCluster()
dba.createCluster()
AUTO
REQUIRED
createCluster({memberSslMode:'DISABLED'})
createCluster({memberSslMode:'REQUIRED'})
createCluster({memberSslMode:'AUTO'})
cluster.addInstance()
createCluster()
memberSslMode
dba.createCluster()
deploySandboxInstance()
ignoreSslError
createCluster()
rejoinInstance()
ipWhitelist
group_replication_ip_whitelist
MySQL的JS > cluster.addInstance("ic@ic-3:3306", {ipWhitelist: "203.0.113.0/24, 198.51.100.110"})
203.0.113.0/24
shell> mysqlsh -f setup-innodb-cluster.jss
os.argv
print('MySQL InnoDB cluster sandbox set up\n'); print('==================================\n'); print('Setting up a MySQL InnoDB cluster with 3 MySQL Server sandbox instances.\n'); print('The instances will be installed in ~/mysql-sandboxes.\n'); print('They will run on ports 3310, 3320 and 3330.\n\n'); var dbPass = shell.prompt('Please enter a password for the MySQL root account: ', {type:"password"}); try { print('\nDeploying the sandbox instances.'); dba.deploySandboxInstance(3310, {password: dbPass}); print('.'); dba.deploySandboxInstance(3320, {password: dbPass}); print('.'); dba.deploySandboxInstance(3330, {password: dbPass}); print('.\nSandbox instances deployed successfully.\n\n'); print('Setting up InnoDB cluster...\n'); shell.connect('root@localhost:3310', dbPass); var cluster = dba.createCluster("prodCluster"); print('Adding instances to the cluster.'); cluster.addInstance({user: "root", host: "localhost", port: 3320, password: dbPass}); print('.'); cluster.addInstance({user: "root", host: "localhost", port: 3330, password: dbPass}); print('.\nInstances successfully added to the cluster.'); print('\nInnoDB cluster deployed successfully.\n'); } catch(e) { print('\nThe InnoDB cluster could not be created.\n\nError: ' + + e.message + '\n'); }
dba.deploySandboxInstance()
dba.checkInstanceConfiguration()
a
b
dba.configureInstance()
--defaults-extra-file
group_replication_group_seeds