MySQL InnoDB Replication部署方案與實踐

1. 概述

MySQL Innodb ReplicaSet 是 MySQL 團隊在 2020 年推出的一款產品,用來幫助用戶快速部署和管理主從復制,在數據庫層仍然使用的是主從復制技術。

ReplicaSet 主要包含三個組件:MySQL Router、MySQL Server 以及 MySQL Shell 高級客戶端。

MySQL Shell 負責管理 ReplicaSet 包括部署、切換、節點加入等,都可以通過內置 AdminAPI 自動化完成。

MySQL Router 是一款輕量級中間件,可在應用程序和 ReplicaSet 之間提供透明路由和讀寫分離功能。

2. 適用場景

InnoDB ReplicaSet至少由兩臺MySQL服務器實例組成,提供MySQL主從復制功能。InnoDB ReplicaSet基于異步的主從復制實現,因此適用于用戶對高可用性要求不高的環境。可以通過MySQL Shell快速搭建及管理主從復制,避免了搭建主從復制時大量的手動操作。

InnoDB ReplicaSet的不足之處有:

  • 不支持自動故障轉移。主庫不可用時,需要通過AdminAPI手動發起故障轉移。

  • 發生計劃外的服務不可用時,可能會丟失部分數據。由于主備之間是異步復制,主庫發生故障時,未提交的事務會丟失。

  • 發生計劃外的服務不可用時,可能會產生數據不一致。例如由于網絡原因導致主庫連不上,將備庫提升為主庫后,可能會同時存在兩個主庫,即發生“腦裂”。

  • 不支持多主模式,即同一時刻只有一個主庫可寫。

  • 讀擴展受限,不能像組復制那樣對流量進行控制。

  • 所有的備庫都從同一個主庫復制數據。在有大量的小更新時,可能會對主庫造成影響。

  • 僅支持MySQL 8.0及其以后的版本。

  • 僅支持基于GTID的日志復制。

  • 僅支持基于行的日志復制(Row-Based Replication, RBR),不支持基于SQL語句的復制(Statement-Based Replication, SBR)。

  • 不支持復制過濾。

  • RS為一個主庫加多個從庫的架構。需要通過MySQL Router監視RS中的實例,因此從庫的數量不能無限制增加。

  • 必須通過MySQL Shell配置和管理,包括復制用戶的創建。

3. 安裝部署

IProlehostname版本OS
192.168.10.31Mastermysql-rs-1MySQL 8.2Centos_7.9_x86_x64
192.168.10.32Secondarymysql-rs-2MySQL 8.2Centos_7.9_x86_x64

3.1. 安裝MySQL servers

分別在兩個MySQL服務器下載MySQL Server安裝包,并進行安裝。

# 配置主機名
echo "192.168.10.31 ? mysql-rs-1" >> /etc/hosts
echo "192.168.10.32 ? mysql-rs-2" >> /etc/hosts
?
# 192.168.10.31執行
hostnamectl set-hostname mysql-rs-1
bash
# 192.168.10.32執行
hostnamectl set-hostname mysql-rs-2
bash
# 下載rpm安裝包
wget https://cdn.mysql.com//Downloads/MySQL-8.2/mysql-8.2.0-1.el7.x86_64.rpm-bundle.tar
?
# 解壓
tar -xvf mysql-8.2.0-1.el7.x86_64.rpm-bundle.tar
?
# 卸載mariadb
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
?
# 安裝MySQL
yum localinstall -y *.rpm

分別配置root密碼:

[root@mysql-rs-2 server]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.2.0
?
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
?
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
?
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
?
mysql> 
mysql> 
mysql> alter user root@'localhost' identified by 'Abcd@1234';
Query OK, 0 rows affected (0.00 sec)
?
mysql> create user root@'%' identified by 'Abcd@1234';
Query OK, 0 rows affected (0.01 sec)

3.2. 安裝mysqlsh

# 下載mysqlshell
wget https://cdn.mysql.com//Downloads/MySQL-Shell/mysql-shell-8.2.0-1.el7.x86_64.rpm
# 安裝mysqlshell
rpm -ivh mysql-shell-8.2.0-1.el7.x86_64.rpm

驗證mysql shell鏈接數據庫

[root@mysql-rs-1 software]# mysqlsh --mysql -u root -h localhost -C
Please provide the password for 'root@localhost': ************
Save password for 'root@localhost'? [Y]es/[N]o/Ne[v]er (default No): 
Error during auto-completion cache update: You must reset your password using ALTER USER statement before executing this statement.
MySQL Shell 8.2.0
?
Copyright (c) 2016, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
?
Type '\help' or '\?' for help; '\quit' to exit.
Creating a Classic session to 'root@localhost?compression=REQUIRED'
Your MySQL connection id is 8
No default schema selected; type \use <schema> to set one.MySQL  localhost  JS > 

3.3. 配置實例

在其中一個主機上啟動mysqlsh連接

[root@mysql-rs-1 software]# mysqlsh root@mysql-rs-1:3306
MySQL Shell 8.2.0
?
Copyright (c) 2016, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
?
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'root@mysql-rs-1:3306'
Fetching schema names for auto-completion... Press ^C to stop.
Your MySQL connection id is 21
Server version: 8.2.0 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.

分別給root用戶授權:

GRANT CLONE_ADMIN, CONNECTION_ADMIN, CREATE USER, EXECUTE, FILE, GROUP_REPLICATION_ADMIN, PERSIST_RO_VARIABLES_ADMIN, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, REPLICATION_APPLIER, REPLICATION_SLAVE_ADMIN, ROLE_ADMIN, SELECT, SHUTDOWN, SYSTEM_VARIABLES_ADMIN ON *.* TO 'root'@'%' WITH GRANT OPTION;
GRANT DELETE, INSERT, UPDATE ON mysql.* TO 'root'@'%' WITH GRANT OPTION;
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, REFERENCES, SHOW VIEW, TRIGGER, UPDATE ON mysql_innodb_cluster_metadata.* TO 'root'@'%' WITH GRANT OPTION;
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, REFERENCES, SHOW VIEW, TRIGGER, UPDATE ON mysql_innodb_cluster_metadata_bkp.* TO 'root'@'%' WITH GRANT OPTION;
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, REFERENCES, SHOW VIEW, TRIGGER, UPDATE ON mysql_innodb_cluster_metadata_previous.* TO 'root'@'%' WITH GRANT OPTION;

在MySQL Shell中執行:

配置mysql-rs-1:

 MySQL  mysql-rs-1:3306 ssl  JS > dba.configureReplicaSetInstance('root@mysql-rs-1:3306', {clusterAdmin: "rs_admin"})
Configuring local MySQL instance listening at port 3306 for use in an InnoDB ReplicaSet...
?
This instance reports its own address as mysql-rs-1:3306
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.
Assuming full account name 'rs_admin'@'%' for rs_admin
Password for new account: *********
Confirm password: *********
?
applierWorkerThreads will be set to the default value of 4.
?
NOTE: Some configuration options need to be fixed:
+----------------------------------------+---------------+----------------+--------------------------------------------------+
| Variable ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | Current Value | Required Value | Note ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+----------------------------------------+---------------+----------------+--------------------------------------------------+
| binlog_transaction_dependency_tracking | COMMIT_ORDER  | WRITESET ? ? ? | 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 ? ? ? ? ? ? | <unique ID> ?  | Update read-only variable and restart the server |
+----------------------------------------+---------------+----------------+--------------------------------------------------+
?
Some variables need to be changed, but cannot be done dynamically on the server.
Do you want to perform the required configuration changes? [y/n]: y
Do you want to restart the instance after configuring it? [y/n]: y
?
Creating user rs_admin@%.
Account rs_admin@% was successfully created.
?
Configuring instance...
?
WARNING: '@@binlog_transaction_dependency_tracking' is deprecated and will be removed in a future release. (Code 1287).
The instance 'mysql-rs-1:3306' was configured to be used in an InnoDB ReplicaSet.
Restarting MySQL...
NOTE: MySQL server at mysql-rs-1:3306 was restarted.

配置mysql-rs-2:

 MySQL  mysql-rs-1:3306 ssl  JS > dba.configureReplicaSetInstance('root@mysql-rs-2:3306', {clusterAdmin: "rs_admin"})
Please provide the password for 'root@mysql-rs-2:3306': *********
Save password for 'root@mysql-rs-2:3306'? [Y]es/[N]o/Ne[v]er (default No): Y
Configuring MySQL instance at mysql-rs-2:3306 for use in an InnoDB ReplicaSet...
?
This instance reports its own address as mysql-rs-2:3306
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.
Assuming full account name 'rs_admin'@'%' for rs_admin
Password for new account: *********
Confirm password: *********
?
applierWorkerThreads will be set to the default value of 4.
?
NOTE: Some configuration options need to be fixed:
+----------------------------------------+---------------+----------------+--------------------------------------------------+
| Variable ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | Current Value | Required Value | Note ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+----------------------------------------+---------------+----------------+--------------------------------------------------+
| binlog_transaction_dependency_tracking | COMMIT_ORDER  | WRITESET ? ? ? | 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 ? ? ? ? ? ? | <unique ID> ?  | Update read-only variable and restart the server |
+----------------------------------------+---------------+----------------+--------------------------------------------------+
?
Some variables need to be changed, but cannot be done dynamically on the server.
Do you want to perform the required configuration changes? [y/n]: y
Do you want to restart the instance after configuring it? [y/n]: y
?
Creating user rs_admin@%.
Account rs_admin@% was successfully created.
?
Configuring instance...
?
WARNING: '@@binlog_transaction_dependency_tracking' is deprecated and will be removed in a future release. (Code 1287).
The instance 'mysql-rs-2:3306' was configured to be used in an InnoDB ReplicaSet.
Restarting MySQL...
NOTE: MySQL server at mysql-rs-2:3306 was restarted.

3.4. 創建ReplicationSet

創建ReplicationSet,默認會將當前進入的實例為主庫實例:

 MySQL  mysql-rs-1:3306 ssl  JS > dba.createReplicaSet('ReplicaSet')
A new replicaset with instance 'mysql-rs-1:3306' will be created.
?
* Checking MySQL instance at mysql-rs-1:3306
?
This instance reports its own address as mysql-rs-1:3306
mysql-rs-1:3306: Instance configuration is suitable.
?
* Checking connectivity and SSL configuration...
* Updating metadata...
?
ReplicaSet object successfully created for mysql-rs-1:3306.
Use rs.addInstance() to add more asynchronously replicated instances to this replicaset and rs.status() to check its status.
?
<ReplicaSet:ReplicaSet> 

3.5. 將另一個實例加入到創建的 ReplicaSet

 MySQL  mysql-rs-1:3306 ssl  JS > var rs = dba.getReplicaSet()You are connected to a member of replicaset 'ReplicaSet'.MySQL  mysql-rs-1:3306 ssl  JS > rs.addInstance('mysql-rs-2:3306')
Adding instance to the replicaset...
?
* Performing validation checks
?
This instance reports its own address as mysql-rs-2:3306
mysql-rs-2:3306: Instance configuration is suitable.
?
* Checking async replication topology...
?
* Checking connectivity and SSL configuration...
?
* Checking transaction state of the instance...
?
NOTE: The target instance 'mysql-rs-2:3306' has not been pre-provisioned (GTID set is empty). The Shell is unable to decide whether replication can completely recover its state.
The safest and most convenient way to provision a new instance is through automatic clone provisioning, which will completely overwrite the state of 'mysql-rs-2:3306' with a physical snapshot from an existing replicaset member. To use this method by default, set the 'recoveryMethod' option to 'clone'.
?
WARNING: It should be safe to rely on replication to incrementally recover the state of the new instance if you are sure all updates ever executed in the replicaset were done with GTIDs enabled, there are no purged transactions and the new instance contains the same GTID set as the replicaset or a subset of it. To use this method by default, set the 'recoveryMethod' option to 'incremental'.
?
?
Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone): 
* Updating topology
Monitoring Clone based state recovery of the new member. Press ^C to abort the operation.
Clone based state recovery is now in progress.
?
NOTE: A server restart is expected to happen as part of the clone process. If the
server does not support the RESTART command or does not come back after a
while, you may need to manually start it back.
?
* Waiting for clone to finish...
NOTE: mysql-rs-2:3306 is being cloned from mysql-rs-1:3306
** Stage DROP DATA: Completed
** Clone Transfer ?FILE COPY ?############################################################  100%  CompletedPAGE COPY ?############################################################  100%  CompletedREDO COPY ?############################################################  100%  Completed
* Clone process has finished: 76.80 MB transferred in about 1 second (~76.80 MB/s)
?
** Changing replication source of mysql-rs-2:3306 to mysql-rs-1:3306
** Waiting for new instance to synchronize with PRIMARY...
** Transactions replicated ?############################################################  100% 
?
The instance 'mysql-rs-2:3306' was added to the replicaset and is replicating from mysql-rs-1:3306.
?
* Waiting for instance 'mysql-rs-2:3306' to synchronize the Metadata updates with the PRIMARY...
** Transactions replicated ?############################################################  100% 

3.6. 查看副本集狀態

 MySQL  mysql-rs-1:3306 ssl  JS > var rs = dba.getReplicaSet()
You are connected to a member of replicaset 'ReplicaSet'.MySQL  mysql-rs-1:3306 ssl  JS > rs.status()
{"replicaSet": {"name": "ReplicaSet", "primary": "mysql-rs-1:3306", "status": "AVAILABLE", "statusText": "All instances available.", "topology": {"mysql-rs-1:3306": {"address": "mysql-rs-1:3306", "instanceRole": "PRIMARY", "mode": "R/W", "status": "ONLINE"}, "mysql-rs-2:3306": {"address": "mysql-rs-2:3306", "instanceRole": "SECONDARY", "mode": "R/O", "replication": {"applierStatus": "APPLIED_ALL", "applierThreadState": "Waiting for an event from Coordinator", "applierWorkerThreads": 4, "receiverStatus": "ON", "receiverThreadState": "Waiting for source to send event", "replicationLag": null, "replicationSsl": "ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2", "replicationSslMode": "REQUIRED"}, "status": "ONLINE"}}, "type": "ASYNC"}
}

3.7. 配置MySQL Router

# 下載MySQL Router
wget https://cdn.mysql.com//Downloads/MySQL-Router/mysql-router-community-8.2.0-1.el7.x86_64.rpm
# 安裝
rpm -ivh mysql-router-community-8.2.0-1.el7.x86_64.rpmMySQL  mysql-rs-1:3306 ssl  JS > var rs = dba.getReplicaSet()
You are connected to a member of replicaset 'ReplicaSet'.MySQL  mysql-rs-1:3306 ssl  JS > rs.setupRouterAccount('rs_router1')
?
Missing the password for new account rs_router1@%. Please provide one.
Password for new account: *********
Confirm password: *********
?
?
Creating user rs_router1@%.
Account rs_router1@% was successfully created.

3.8. 引導啟動MySQL Router

[root@mysql-rs-1 software]# mysqlrouter --bootstrap root@mysql-rs-1:3306 --user mysqlrouter
Please enter MySQL password for root: 
# Bootstrapping system MySQL Router 8.2.0 (MySQL Community - GPL) instance...
?
- Creating account(s) (only those that are needed, if any)
- Verifying account (using it to run SQL queries that would be run by Router)
- Storing account in keyring
- Adjusting permissions of generated files
- Creating configuration /etc/mysqlrouter/mysqlrouter.conf
?
Existing configuration backed up to '/etc/mysqlrouter/mysqlrouter.conf.bak'
?
# MySQL Router configured for the InnoDB ReplicaSet 'ReplicaSet'
?
After this MySQL Router has been started with the generated configuration
?$ /etc/init.d/mysqlrouter restart
or$ systemctl start mysqlrouter
or$ mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf
?
InnoDB ReplicaSet 'ReplicaSet' can be reached by connecting to:
?
## MySQL Classic protocol
?
- Read/Write Connections: localhost:6446
- Read/Only Connections:  localhost:6447
- Read/Write Split Connections: localhost:6450
?
## MySQL X protocol
?
- Read/Write Connections: localhost:6448
- Read/Only Connections:  localhost:6449

3.9. 讀寫分離驗證

檢查ReplicaSet,可以看到主節點(讀寫)為mysql-rs-1:3306,從節點(只讀)為mysql-rs-2:3306

 MySQL  mysql-rs-1:3306 ssl  JS > rs.status()
{"replicaSet": {"name": "ReplicaSet", "primary": "mysql-rs-1:3306", "status": "AVAILABLE", "statusText": "All instances available.", "topology": {"mysql-rs-1:3306": {"address": "mysql-rs-1:3306", "instanceRole": "PRIMARY", "mode": "R/W", "status": "ONLINE"}, "mysql-rs-2:3306": {"address": "mysql-rs-2:3306", "instanceRole": "SECONDARY", "mode": "R/O", "replication": {"applierStatus": "APPLIED_ALL", "applierThreadState": "Waiting for an event from Coordinator", "applierWorkerThreads": 4, "receiverStatus": "ON", "receiverThreadState": "Waiting for source to send event", "replicationLag": null, "replicationSsl": "ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2", "replicationSslMode": "REQUIRED"}, "status": "ONLINE"}}, "type": "ASYNC"}
}

檢查mysqlrouter,可以看到MySQL Router讀寫端口為6450

 MySQL  mysql-rs-1:3306 ssl  JS > rs.listRouters()
{"replicaSetName": "ReplicaSet", "routers": {"mysql-rs-1::system": {"hostname": "mysql-rs-1", "lastCheckIn": "2023-11-14 11:40:21", "roPort": "6447", "roXPort": "6449", "rwPort": "6446", "rwSplitPort": "6450", "rwXPort": "6448", "version": "8.2.0"}}
}

下面通過MySQL Router的讀寫端口6450連接mysql數據庫:

[root@mysql-rs-1 ~]# mysqlsh mysql://root@mysql-rs-1:6450 --sql
MySQL Shell 8.2.0
?
Copyright (c) 2016, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
?
Type '\help' or '\?' for help; '\quit' to exit.
Creating a Classic session to 'root@mysql-rs-1:6450'
Fetching global names for auto-completion... Press ^C to stop.
Your MySQL connection id is 0
Server version: 8.2.0 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.MySQL  mysql-rs-1:6450 ssl  SQL > 

查詢數據,發現當前節點為從節點:

 MySQL  mysql-rs-1:6450 ssl  SQL > select @@hostname, @@port;
+------------+--------+
| @@hostname | @@port |
+------------+--------+
| mysql-rs-2 | ? 3306 |
+------------+--------+
1 row in set (0.0035 sec)
Statement ID: 13700

開啟事務,會自動切換到主節點:

 MySQL  mysql-rs-1:6450 ssl  SQL > start transaction;
Query OK, 0 rows affected (0.0031 sec)
Statement ID: 20477MySQL  mysql-rs-1:6450 ssl  ★  SQL > select @@hostname, @@port;
+------------+--------+
| @@hostname | @@port |
+------------+--------+
| mysql-rs-1 | ? 3306 |
+------------+--------+
1 row in set (0.0007 sec)
Statement ID: 20563

提交或者回滾事務后,自動切換到從節點:

 MySQL  mysql-rs-1:6450 ssl  ★  SQL > rollback;
Query OK, 0 rows affected (0.0006 sec)
Statement ID: 21909MySQL  mysql-rs-1:6450 ssl  SQL > select @@hostname, @@port;
+------------+--------+
| @@hostname | @@port |
+------------+--------+
| mysql-rs-2 | ? 3306 |
+------------+--------+
1 row in set (0.0020 sec)
Statement ID: 15489

只讀事務中,也會切換到從節點:

 MySQL  mysql-rs-1:6450 ssl  SQL > start transaction read only;
Query OK, 0 rows affected (0.0029 sec)
Statement ID: 16970MySQL  mysql-rs-1:6450 ssl  ☆  SQL > select @@hostname, @@port;
+------------+--------+
| @@hostname | @@port |
+------------+--------+
| mysql-rs-2 | ? 3306 |
+------------+--------+
1 row in set (0.0010 sec)
Statement ID: 16996

用戶還可以在會話中使用ROUTER SET access_mode=命令來定義應用要連接的實例類型:

 MySQL  mysql-rs-1:6450 ssl  SQL > router set access_mode='read_write';
Query OK, 0 rows affected (0.0004 sec)MySQL  mysql-rs-1:6450 ssl ?-  SQL > select @@hostname, @@port;
+------------+--------+
| @@hostname | @@port |
+------------+--------+
| mysql-rs-1 | ? 3306 |
+------------+--------+
1 row in set (0.0017 sec)
Statement ID: 25535MySQL  mysql-rs-1:6450 ssl  SQL > router set access_mode='read_only';
Query OK, 0 rows affected (0.0006 sec)MySQL  mysql-rs-1:6450 ssl ?-  SQL > select @@hostname, @@port;
+------------+--------+
| @@hostname | @@port |
+------------+--------+
| mysql-rs-2 | ? 3306 |
+------------+--------+
1 row in set (0.0043 sec)
Statement ID: 18508

4. 總結

總之,MySQL Router 8.2支持讀寫分離。這是一項有價值的功能,可以優化數據庫性能和可擴展性,而無需在應用程序中進行任何更改。這種配置使您能夠將所有讀流量引導到只讀實例,將所有寫流量引導到讀寫實例。這不僅增強了用戶的整體體驗,還簡化了數據庫管理和部署。

讀寫實例是主實例或源實例。只讀實例是副本(InnoDB集群的非主實例、ReplicaSet的非主實例或復制集群中的非主實例)。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/215731.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/215731.shtml
英文地址,請注明出處:http://en.pswp.cn/news/215731.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

eventBus父組件$emit一次子組件多次收到¥

eventBus父組件$emit一次子組件多次收到$on 參考&#xff08;EventBus踩坑1-CSDN博客&#xff09; 父組件emit出了事件&#xff0c;這個過程需要一定時間&#xff0c;這段時間過長&#xff0c;子組件還未接收到父組件的emit&#xff0c;父組件認為子組件沒有收到&#xff0c;…

12 位多通道國產芯片ACM32F403/F433 系列,支持 MPU 存儲保護功能,應用于工業控制,智能家居等產品中

ACM32F403/F433 芯片的內核基于 ARMv8-M 架構&#xff0c;支持 Cortex-M33 和 Cortex-M4F 指令集。芯片內核 支持一整套DSP指令用于數字信號處理&#xff0c;支持單精度FPU處理浮點數據&#xff0c;同時還支持Memory Protection Unit &#xff08;MPU&#xff09;用于提升應用的…

Java - Mybatis借助PageHelper實現分頁,集成SpringBoot

未使用SpringBoot 第?步&#xff1a;引?依賴 <dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>5.3.1</version> </dependency> 第?步&#xff1a;在mybatis-config.xml…

PyTorch張量:內存布局

你可能對 torch 上的某些函數感到困惑&#xff0c;它們執行相同的操作但名稱不同。 例如&#xff1a; reshape()、view()、permute()、transpose() 等。 這些函數的做法真的不同嗎&#xff1f; 不&#xff01; 但為了理解它&#xff0c;我們首先需要了解一下張量在 pytorch 中…

1 CPU實現的基本框圖

匯編語言 && 指令格式 CPU設計的框架&#xff1a;三級流水線 ROM存放指令和數據&#xff0c;大端模式&小端模式&#xff0c;地址對齊 取指 譯碼&#xff1a; 執行&#xff1a; 匯編語言 & 指令格式 流水線實現工作機制 模塊功能劃分&接口信號 參考…

Linux中用rpm管理軟件

本章主要介紹使用rpm對軟件包進行管理 使用rpm查詢軟件的信息使用rpm安裝及卸載軟件使用rpm對軟件進行更新使用rpm對軟件進行驗證 rpm 全稱是redhat package manager&#xff0c;后來改成rpm package manager&#xff0c;這是根據源 碼包編譯出來的包。先從光盤中拷貝一個包&…

strict-origin-when-cross-origin

嚴格限制同源策略 &#xff08;1&#xff09;允許服務器的同源IP地址訪問 &#xff08;2&#xff09;允許Referer --- 后端服務器要配置

linux sed命令刪除一行/多行_sed刪除第一行/linux刪除文件某一行

sed系列文章 linux常用命令(9)&#xff1a;sed命令(編輯/替換/刪除文本)linux sed命令刪除一行/多行_sed刪除第一行/linux刪除文件某一行 文章目錄 sed系列文章一、sed刪除某一行內容/刪除最后一行二、sed刪除多行三、擴展3.1、-i命令 本文主要講解如何刪除txt文件中的某一行內…

vite+ts——user.ts——ts接口定義+axios請求的寫法

import axios from axios; import qs from query-string; import {UserState} from /store/modules/user/types;export interface LoginData{username:string;password:string;grant_type?:string;scope?:string;client_id?:string;client_secret?:string;response_type?:…

企業使用APP自動化測試工具的重要因素

隨著移動應用市場的蓬勃發展&#xff0c;企業對高質量、高效率的軟件交付提出了更高的要求。在這個背景下&#xff0c;APP自動化測試工具成為了企業不可或缺的一部分。以下是企業采用APP自動化測試工具的關鍵因素&#xff1a; 1. 快速且可重復的測試執行 自動化測試工具能夠快速…

Docker入門概念

文章目錄 容器&#xff08;container&#xff1a;容器/集裝箱&#xff09;技術虛擬機解決了哪些部署問題docker解決了哪些部署問題docker是如何做到容器間運行時環境隔離的docker基本概念docker基本使用 容器&#xff08;container&#xff1a;容器/集裝箱&#xff09;技術 容…

奧威亞視頻云平臺VideoCover.aspx 接口任意文件上傳漏洞復現 [附POC]

文章目錄 奧威亞視頻云平臺VideoCover.aspx 接口任意文件上傳漏洞復現 [附POC]0x01 前言0x02 漏洞描述0x03 影響版本0x04 漏洞環境0x05 漏洞復現1.訪問漏洞環境2.構造POC3.復現0x06 修復建議奧威亞視頻云平臺VideoCover.aspx 接口任意文件上傳漏洞復現 [附POC] 0x01 前言 免責…

做數據分析為何要學統計學(5)——什么問題適合使用卡方檢驗?

卡方檢驗作為一種非常著名的非參數檢驗方法&#xff08;不受總體分布因素的限制&#xff09;&#xff0c;在工程試驗、臨床試驗、社會調查等領域被廣泛應用。但是也正是因為使用的便捷性&#xff0c;造成時常被誤用。本文參閱相關的文獻&#xff0c;對卡方檢驗的適用性進行粗淺…

原來使用代碼也可以畫時序圖,用這個Mermaid就行,真香

本文首發于我的個人掘金博客&#xff0c;看到很多人都比較喜歡這篇文章&#xff0c;分享給大家。 個人博客主頁&#xff1a;https://www.aijavapro.cn 個人掘金主頁&#xff1a;juejin.cn/user/2359988032644541/posts 個人知識星球: 覺醒的新世界程序員 一、背景 在軟件開發和…

spring數據校驗

我是南城余&#xff01;阿里云開發者平臺專家博士證書獲得者&#xff01; 歡迎關注我的博客&#xff01;一同成長&#xff01; 一名從事運維開發的worker&#xff0c;記錄分享學習。 專注于AI&#xff0c;運維開發&#xff0c;windows Linux 系統領域的分享&#xff01; 本…

數據庫(一)| 數據庫概述、基本概念、關系型數據庫特點、超鍵候選碼等

文章目錄 1 數據庫的一些基礎概念1.1 數據庫和數據庫管理系統1.2 關系模式和關系實例1.3 數據庫模式和數據庫實例 2 數據庫組織形式2.1 數據采用文件的缺點2.2 使用數據庫管理系統的 優點 3 關系型數據庫特點4 三個層次的數據抽象Data Abstraction5 超鍵、候選碼、主碼、外碼 1…

php之jwt使用

PHP JWT&#xff08;JSON Web Token&#xff09;是一種用于身份驗證和授權的開放標準。JWT是一個包含有關用戶或實體身份信息的安全令牌&#xff0c;它由三部分組成&#xff1a;頭部&#xff08;Header&#xff09;、載荷&#xff08;Payload&#xff09;和簽名&#xff08;Sig…

計算機網絡編程

網絡編程 Java 是第一大編程語言和開發平臺。它有助于企業降低成本、縮短開發周期、推動創新以及改善應用服務。如今全球有數百萬開發人員運行著超過 51 億個 Java 虛擬機&#xff0c; Java 仍是企業和開發人員的首選開發平臺。 課程內容的介紹 1. 計算機網絡基礎 2. So…

數據結構基礎介紹

一.起源及重要性 1968 年&#xff0c;美國的高德納 Donakl E . Kn uth 教授在其所寫的《 計算機程序藝術》第一卷《基本算法 》 中&#xff0c;較系統地闡述了數據的邏輯結構和存儲結構及其操作&#xff0c; 開創了數據結構的課程體系 &#xff0c;數據結構作為一門獨立的…

B029-JDBC增強

目錄 PreparedStatement 查詢1.sql注入2.Statement分析 (面試題)3.PreparedStatement (面試題) 登錄功能的完善事務鏈接池概念實現DBCP連接池實現第一種配置方式第二種配置方式 返回主鍵BaseDao的抽取 PreparedStatement 查詢 1.sql注入 就是在sql的字符串拼接的時候&#xf…