azure云数据库

In this article, we will review how to set up Geo-Replication on Azure SQL databases. Geo-Replication is an Azure SQL database feature that allows you to create a readable secondary database in the same region or cross-region. We can failover to the secondary database in case of an outage for a long time on the primary database server. We can also use this feature to migrate a database from one server to another server in the same or cross region with minimal downtime. Geo-replication uses the Always-on feature to replicate committed transactions to the secondary database asynchronously.

在本文中,我们将回顾如何在Azure SQL数据库上设置地理复制。 地理复制是Azure SQL数据库功能,允许您在同一区域或跨区域中创建可读的辅助数据库。 如果主数据库服务器上长时间中断,我们可以故障转移到辅助数据库。 我们还可以使用此功能以最少的停机时间将数据库从相同或跨区域的一台服务器迁移到另一台服务器。 地理复制使用始终在线功能将提交的事务异步复制到辅助数据库。

Let us go step by step to configure Geo-Replication on an Azure database. In this demo, I am using Azure single database.

让我们一步一步地在Azure数据库上配置地理复制。 在此演示中,我正在使用Azure单一数据库。

在Azure SQL数据库上配置地理复制 (Configuring the Geo-Replication on Azure SQL database)

Log in to the Azure portal and navigate to SQL databases. Click on the Azure SQL database on which you are going to configure the Geo-Replication.

登录到Azure门户并导航到SQL数据库。 单击您要在其上配置地理复制的Azure SQL数据库。

Click on the Geo-Replication tab in the database details page.

单击数据库详细信息页面中的“ 地理复制”选项卡。

Select the target region from the list of target regions shown. In this case, the primary database is located in West India and I selected the target region (secondary database region) as South India.

从显示的目标区域列表中选择目标区域。 在这种情况下,主数据库位于印度西部,我选择了目标区域(辅助数据库区域)作为南印度。

Click on the Target Server. All the available Azure database servers in the target region are shown in the list. Select one if you want to use an existing Azure database server or create a new Azure database server by clicking on Create a new Server. Enter the Azure SQL server name, admin login, and password. Click on Select and Ok.

单击目标服务器 。 目标区域中所有可用的Azure数据库服务器都显示在列表中。 如果要使用现有的Azure数据库服务器或通过单击创建新服务器创建新的Azure数据库服务器,请选择一个 。 输入Azure SQL服务器名称,管理员登录名和密码。 单击选择,然后单击确定

The Geo-Replication setup is progressing, and you can see it on the map. It shows a dotted line as shown in the below image when the setup is in progress. Once the setup is complete it shows a full line between the source and target regions.

地理复制设置正在进行中,您可以在地图上看到它。 进行设置时,它会显示一条虚线,如下图所示。 设置完成后,它将在源区域和目标区域之间显示一条完整的线。

In the Geo-Replication page under the map, we can see the details of primary and secondary databases and the status of the database.

在地图下方的“地理复制”页面中,我们可以看到主要和辅助数据库的详细信息以及数据库的状态。

We can also create Geo-Replication using below T-SQL script. The following T-SQL script should be executed on the master database at the Azure SQL primary server. Replace the database name and the secondary server name in the T-SQL script. If the database with the same name already exists on the secondary server, the below T-SQL script throws an error “The destination database name ‘ActiveGeoRepl’ already exists on the server

我们还可以使用下面的T-SQL脚本创建Geo-Replication。 以下T-SQL脚本应在Azure SQL主服务器上的master数据库上执行。 在T-SQL脚本中替换数据库名称和辅助服务器名称。 如果辅助服务器上已经存在具有相同名称的数据库,则以下T-SQL脚本将引发错误“ 服务器上的目标数据库名称'ActiveGeoRepl'已经存在

ALTER DATABASE AzureGeoRepl
ADD SECONDARY ON SERVER rbc2
WITH ( ALLOW_CONNECTIONS = ALL )

We can create up to four secondaries for each primary database. As the transactions are replicated asynchronously to the secondary database may lag the primary database at any point in time.

每个主数据库最多可以创建四个辅助数据库。 由于事务异步复制到辅助数据库,因此在任何时间点都可能落后于主数据库。

Geo-Replication supports only manual failover and the end-point connection must be changed in the application after the failover. The secondary must have the same firewall rules and the logins to run applications successfully without any discrepancies after the failover to the Azure SQL secondary database.

Geo-Replication仅支持手动故障转移,并且在故障转移后必须在应用程序中更改端点连接。 辅助节点必须具有相同的防火墙规则和登录名,才能在故障转移到Azure SQL辅助数据库后成功运行应用程序,而不会出现任何差异。

故障转移
(Failover
)

Execute the following T-SQL script for a planned failover which makes the secondary database online without data loss. This T-SQL script should be executed at the secondary server on the master database.

对计划的故障转移执行以下T-SQL脚本,该脚本可使辅助数据库联机而不会丢失数据。 此T-SQL脚本应在master数据库上的辅助服务器上执行。

ALTER DATABASE AzureGeoRepl FAILOVER

Once the above command is executed on the secondary server, it stops all the connections to the existing primary database, replicate all the transactions to the secondary database and make the secondary database online.

在辅助服务器上执行上述命令后,它将停止与现有主数据库的所有连接,将所有事务复制到辅助数据库,并使辅助数据库联机。

强制故障转移 (Forced Failover )

For a forced failover, click on the secondary database to which you want failover and click on Forced Failover. This will make your secondary database immediately online and start accepting connections. Forced failover may result in data loss.

要进行强制故障转移,请单击要故障转移到的辅助数据库,然后单击“ 强制故障转移” 。 这将使您的辅助数据库立即联机并开始接受连接。 强制故障转移可能会导致数据丢失。

Alternatively, we can use the following T-SQL script on the master database at the secondary server for a forced failover which immediately brings the secondary database online.

或者,我们可以在辅助服务器上的master数据库上使用以下T-SQL脚本进行强制故障转移,从而立即使辅助数据库联机。

ALTER DATABASE AzureGeoRepl FORCE_FAILOVER_ALLOW_DATA_LOSS

删除地理复制 (Removing Geo-Replication)

To remove Geo-replication on an Azure database, navigate to the database details page and click on Geo-Replication. Just under the map locate the secondary server and click on Stop Replication. Please refer to the below image.

若要删除Azure数据库上的地理复制,请导航到数据库详细信息页面,然后单击“地理复制”。 在地图下方,找到辅助服务器,然后单击“停止复制”。 请参考下图。

Alternatively, you can also use the following T-SQL script to remove Geo-Replication between primary and secondary databases. This T-SQL script should be executed on the master database at the primary server.

或者,您也可以使用以下T-SQL脚本删除主数据库和辅助数据库之间的地理复制。 此T-SQL脚本应在主服务器上的master数据库上执行。

Replace the database and the secondary Azure SQL server name with yours.

用您的数据库和辅助Azure SQL服务器名称替换。

ALTER DATABASE AzureGeoRepl
REMOVE SECONDARY ON SERVER rbc

辅助数据库上的地理复制。 (Geo-Replication on a secondary database.)

In case we want to have more than four secondary databases for a given primary database, configure the Geo-Replication on a secondary database so that the secondary database itself will have another secondary database. Execute the following T-SQL script on the master database at the secondary server to create a Geo-Replication from a secondary database to another secondary database.

如果给定的主数据库要有四个以上的辅助数据库,请在辅助数据库上配置地理复制,以便该辅助数据库本身将具有另一个辅助数据库。 在辅助服务器上的master数据库上执行以下T-SQL脚本,以创建从辅助数据库到另一个辅助数据库的地理复制。

ALTER DATABASE ActiveGeoRepl
ADD SECONDARY ON SERVER rbc3
WITH ( ALLOW_CONNECTIONS = ALL )

结论 (Conclusion)

In this article, we explored how to create Geo-Replication on an Azure SQL database, how to manually do a planned failover without data loss and forced failover which may have a data loss. In case you have any questions, please feel free to ask in the comment section below.

在本文中,我们探讨了如何在Azure SQL数据库上创建地理复制,如何在没有数据丢失的情况下手动执行计划的故障转移以及可能会丢失数据的强制故障转移。 如果您有任何疑问,请随时在下面的评论部分中提问。

翻译自: https://www.sqlshack.com/azure-sql-database-geo-replication/

azure云数据库

azure云数据库_Azure SQL数据库地理复制相关推荐

  1. azure云数据库_Azure SQL数据库中的地理复制

    azure云数据库 介绍 (Introduction) If you have an Azure SQL Database, it is possible to replicate the data ...

  2. azure云数据库_Azure SQL数据库的安全注意事项

    azure云数据库 You have to agree with me, when public clouds were introduced your thought was that you wi ...

  3. azure云数据库_Azure SQL数据库的性能调优

    azure云数据库 With the latest versions of Azure SQL database, Microsoft has introduced a number of new m ...

  4. azure云数据库_Azure SQL数据库中的高级数据安全性–数据发现和分类

    azure云数据库 Azure SQL supports in building and managing wide range of SQL databases, tools, frameworks ...

  5. azure云数据库_Azure SQL数据库中的漏洞评估和高级威胁防护

    azure云数据库 In today's time where data breaches are highly expected to happen, there is a high need to ...

  6. azure云数据库_Azure SQL数据库上的透明数据加密(TDE)

    azure云数据库 In this article, we will review on Transparent Data Encryption (TDE) on an Azure SQL datab ...

  7. 保姆级教程!手把手教你使用Longhorn管理云原生分布式SQL数据库!

    作者简介 Jimmy Guerrero,在开发者关系团队和开源社区拥有20多年的经验.他目前领导YugabyteDB的社区和市场团队. 本文来自Rancher Labs Longhorn是Kubern ...

  8. 百度网盘 备份mysql数据库_利用百度云免费备份SQL数据库

    我们开发了一个会员管理系统,随着使用的人越来越多,异地备份数据库就显得十分重要,万一硬盘出问题了怎么办呢.所以就着手做这个工作. 首先呢,找到了几个专门用来提供备份数据库的网站,一年好几百,好贵.放弃 ...

  9. azure 入门_Azure SQL数据库入门

    azure 入门 In this article, we will uncover the basics of the Azure SQL Database. 在本文中,我们将揭示Azure SQL数 ...

最新文章

  1. wemosD1_WIFI模块 与 arduino
  2. 织梦html权限设置,详细的Dede织梦目录权限安全设置教程
  3. elasticsearch基本查询二(英文分词)term和terms查询
  4. php 获取最后执行的sql,如何获取ThinkPHP框架最后一次执行SQL语句及变量调试
  5. 自己写Cache数据库之设计之初——想办法让16颗CPU扛住3w/s的压力?
  6. Overloud TH-U Complete for Mac - 吉他谱曲软件
  7. 使用Rufus制作安装U盘报错,使用UltraISO成功
  8. 卡密社区源码无加密完整版(php源码+mysql脚本)
  9. adb:设置手机屏幕亮度
  10. 如何实现java编写告白程序,程序员如何实现表白代码
  11. python双样本t检验_两样本t检验的scipy实现
  12. 视频号哪些领域值得做变现机会更大:国仁楠哥
  13. 【备战春招/秋招系列】美团Java面经总结终结篇 (附详解答案) 1
  14. 火狐浏览器打印时会出现边框线不显示(缩放页面也会出现)
  15. [MySQL]数据的增加(插入)、修改、删除与计算列
  16. 咕咕机G3vs喵喵机使用心得对比
  17. 怎么关闭linux电脑的热启动键,热启动计算机的按键是什么
  18. 领导拒绝涨薪?我直接跳槽,涨薪6k
  19. 在你转角看不到的温柔
  20. 模式识别中的最优分类超平面与线性支持向量机

热门文章

  1. hello python_Python-Hello world!
  2. Java中的序列问题-2
  3. 在安卓上运行 TensorFlow:让深度学习进入移动端
  4. 02_Storm集群部署
  5. WIN10 64位 JDK的安装
  6. 网友写的验证码生成方案,可防止绝大多数机械识别。
  7. [学习笔记] 七步从AngularJS菜鸟到专家(6):服务 [转]
  8. 前端工程打开速度优化的循序渐进总结
  9. WebClient上传文件至服务器和下载服务器文件至客户端
  10. js 内置对象的方法