azure云数据库

SQL Data Sync allows you to synchronize data across multiple Azure SQL databases and on-premises SQL Server databases.

SQL Data Sync允许您跨多个Azure SQL数据库和本地SQL Server数据库同步数据。

In this article, how to synchronize Azure SQL database with on-premises SQL Server database will be shown.

在本文中,将显示如何将Azure SQL数据库与本地SQL Server数据库同步。

More about SQL Data Sync can be found on the What is SQL Data Sync page.

有关“ SQL数据同步”的更多信息,请参见“ 什么是SQL数据同步”页面。

Set up synchronization

设置同步

In the browser, navigate to Azure portal, and locate the SQL databases tab:

在浏览器中,导航到Azure门户 ,然后找到“ SQL数据库”选项卡:

On the SQL databases page, select the hub database for Data Sync; in this case, the AdventureWorks database will be used. Once the database is selected on the right side under the SETTINGS list, find the Sync to other databases command:

在“ SQL数据库”页面上,选择 用于数据同步的中心数据库; 在这种情况下,将使用AdventureWorks数据库。 在“ 设置”列表下右侧选择数据库后,找到“ 同步到其他数据库”命令:

Click on the Sync to other databases command and the Data Sync page will open in which the configuration of data synchronization will be started:

单击“ 同步到其他数据库”命令,将打开“ 数据同步”页面,其中将开始配置数据同步:

As it can be seen on this page, currently there is no any sync group and any sync agent. The sync agent needs to be installed on-premises database server. More about sync agent will be discussed later in this article.

如在此页面上可以看到的,当前没有任何同步组和任何同步代理。 同步代理需要安装在本地数据库服务器上。 有关同步代理的更多信息将在本文后面讨论。

To start configuration, click the New Sync Group button and the New sync group page opens:

要开始配置,请单击“ 新建同步组” 按钮,然后打开新同步组页面:

In the Sync Group Name box, enter the name for the new sync group (e.g. SyncAzureDatabaseToOnPremisesDatabase).

在“ 同步组名称”框中,输入新同步组的名称(例如SyncAzureDatabaseToOnPremisesDatabase )。

Under the Sync Metadata Database group, choose the New database or Using existing database radio button.

在“ 同步元数据数据库”组下,选择“ 新建数据库”或“ 使用现有数据库”单选按钮。

For this example, the New database radio button will be used to create a new database in which will be placed sync metadata and logs.

在此示例中,将使用“ 新建数据库”单选按钮创建一个新数据库,在该数据库中放置同步元数据和日志。

Select (click) Create new database, the SQL Database tab will open:

选择(单击)“ 创建新数据库” ,“ SQL数据库”选项卡将打开:

In the Name box, enter a new name (Sync Database) for the sync metadata database, configure the other options on this page and press the OK button.

在“ 名称”框中,为同步元数据数据库输入一个新名称(“ 同步数据库” ),在此页面上配置其他选项,然后按“ 确定”按钮。

Under the Automatic Sync section, choose whether the data synchronization should be automatic – by pressing the On button or manually – by pressing the Off button.

在“ 自动同步”部分下,选择数据同步是自动的(通过按“ 打开”按钮还是手动的)通过按“ 关闭”按钮。

If the On button is pressed, the Sync Frequency section will appear. Here can be set how frequent the data synchronization will occur:

如果按按钮,将出现“ 同步频率”部分。 可以设置数据同步发生的频率:

For the example purpose, 5 Minutes will be set.

出于示例目的,将设置5分钟

Under the Conflict Resolution, one of two options can be chosen in case a conflict occurs:

在“ 冲突解决”下,可以选择两个选项之一,以防发生冲突:

The first option is the Hub win. If this option is chosen and the confits occur, the data in the hub database overwrite the conflicting data in the member database.

第一种选择是赢得枢纽 。 如果选择此选项并发生提交,则中心数据库中的数据将覆盖成员数据库中的冲突数据。

The second option is Member win. In a conflict situation, the data in the member database will overwrite the data in the hub database.

第二种选择是会员获胜 。 在冲突情况下,成员数据库中的数据将覆盖中心数据库中的数据。

As an example, in the Conflict Resolution, drop down box the Hub win option will be chosen.

例如,在“ 冲突解决”中的下拉框中,将选择“ 集线器获胜”选项。

After pressing the OK button, the new sync group will start creating.

按下确定按钮后,新的同步组将开始创建。

After creating sync group, the Add sync members section will be enabled for configuration. Under Hub Database, enter the existing username and password for the SQL Database server on which the Hub database is created:

创建同步组后,将启用“ 添加同步成员”部分进行配置。 在“ 集线器数据库”下,输入创建集线器数据库SQL数据库服务器的现有用户名和密码:

Under the Member Database section, an azure database can be added as a member by selecting Add an Azure Database or a on-premises SQL Server database can be added by selecting Add an On-Premises Database. Since we want to sync data with a on-premises SQL Server database, under the Member Database section, select Add an On-Premises Database, the Configure On-Premises tab will appear:

在“ 成员数据库”部分下,可以通过选择“ 添加Azure数据库”将Azure数据库添加为成员。 或可以通过选择添加本地数据库来添加本地SQL Server数据库。 由于我们要与本地SQL Server数据库同步数据,因此,在“ 成员数据库”部分下,选择“ 添加本地数据库” ,将出现“ 配置本地”选项卡:

To start configuration synchronization between the Hub database and on-premises SQL database, select Choose the Sync Agent Gateway; the Select Sync Agent tab will appear:

要开始在集线器数据库和本地SQL数据库之间进行配置同步,请选择选择同步代理网关选择同步代理选项卡将出现:

If the local sync agent is already installed and set on the machine, on the Select Sync Agent tab, pick the Existing agents radio button and from the combo box choose the agent.

如果本地同步代理已在计算机上安装并设置,请在“ 选择同步代理”选项卡上,选择“ 现有代理”单选按钮,然后从组合框中选择代理。

In case where the sync agent is not set, choose the Create a new agent radio button. Additional three steps under the Select Sync Agent tab will appear:

如果未设置同步代理,请选择“ 创建新代理”单选按钮。 “ 选择同步代理”选项卡下将显示另外三个步骤:

In the first step, the Client Sync Agent needs to be installed on the machine where the on-premises SQL Server is located. Sync Agent is used to communicate between Hub and on-premises SQL Server database.

第一步,需要将客户端同步代理安装在本地SQL Server所在的计算机上。 同步代理用于在集线器和本地SQL Server数据库之间进行通信。

设置SQL Azure数据同步代理 (Set up the SQL Azure Data Sync Agent)

Click the Download link to download the SQL Azure Data Sync Agent:

点击下载 链接以下载SQL Azure数据同步代理

The installing (configuring) process will start:

安装(配置)过程将开始:

Press the Next button to continue. On the License Agreement and Privacy Information window, read the agreement and if you agree, select the I Agree radio button and press the Next button:

下一步按钮继续。 在“ 许可协议和隐私信息”窗口上,阅读协议,如果同意,请选择“ 我同意”单选按钮,然后按“ 下一步”按钮:

On this page, enter the Windows credentials and press the Next button:

在此页面上,输入Windows凭据 ,然后按下一步按钮:

In the Folder box, enter the location where the Microsoft SQL Data Sync Agent will be installed and press the Next button to continue:

在“ 文件夹”框中,输入将安装Microsoft SQL Data Sync Agent的位置,然后按“ 下一步”按钮继续:

This page indicates that the installation packed is ready to be installed, press the Next button to install the sync agent:

此页面表明已打包安装安装,请按下一步按钮安装同步代理:

The last page indicates that the installation process is successfully finished:

最后一页指示安装过程已成功完成:

Press the Close button to close the installation window and, in the Start menu, find and launch the Microsoft SQL Data Sync Agent:

按“ 关闭”按钮关闭安装窗口,然后在“ 开始”菜单中找到并启动Microsoft SQL Data Sync Agent:

The Microsoft SQL Data Sync window will appear:

将出现“ Microsoft SQL数据同步”窗口:

Now, back to the Azure portal and, in the Agent Name box, enter the name for the sync agent and press the Create and Generate Key button:

现在,返回到Azure门户,然后在“ 代理名称”框中输入同步代理的名称,然后按“ 创建并生成密钥”按钮:

After a while, the agent key will be generated in the Generate an agent key box:

一段时间后,将在“ 生成代理密钥”框中生成代理密钥

Copy that key and go to the Microsoft SQL Data Sync window and press the Submit Agent Key button. The Sync Metadata Database Configuration window will appear:

复制该密钥,然后转到Microsoft SQL Data Sync窗口,然后按Submit Agent Key按钮。 将出现“ 同步元数据数据库配置”窗口:

In the Agent Key field, paste the copied agent key and in the Login and Password fields, enter the existing credentials for the Azure SQL Database server where the Hub database is located:

在“ 代理密钥”字段中,粘贴复制的代理密钥,然后在“ 登录名”和“ 密码”字段中,输入集线器数据库所在的Azure SQL数据库服务器的现有凭据:

To test if everything is ok, press the Test Connection button. If everything is ok, the following message will appear:

要测试一切正常,请按“ 测试连接”按钮。 如果一切正常,将出现以下消息:

Please note, when doing sync with on-premises SQL Server member database with the hub database, in the firewall settings, the outbound TCP rule with 1433 port needs to be added in order to allow communication between them:

请注意,在与内部SQL Server成员数据库和中心数据库进行同步时,在防火墙设置中,需要添加具有1433端口的出站TCP规则,以允许它们之间进行通信:

Otherwise, the following error message box may appear:

否则,可能会出现以下错误消息框:

More about setting Inbound and Outbound rules can be found on the How to connect to a remote SQL Server page.

有关设置入站和出站规则的更多信息,请参见“ 如何连接到远程SQL Server”页。

Also, this error may appear when the Azure firewall is not set. To resolve this, go to Azure portal and, under SQL servers, find the Firewalls and virtual networks option and, from there, add IP address that is shown in the error message box:

此外,未设置Azure防火墙时,可能会出现此错误。 要解决此问题,请转到Azure门户,然后在SQL Server下找到“ 防火墙和虚拟网络”选项,然后从那里添加错误消息框中显示的IP地址:

Once these rules are set on the Microsoft SQL Data Sync window, press the OK button to continue.

Microsoft SQL数据同步窗口上设置了这些规则后,请按OK(确定)按钮继续。

Now, on the Microsoft SQL Data Sync window, click the Register button, the SQL Server Configuration window will appear:

现在,在“ Microsoft SQL数据同步”窗口上,单击“ 注册”按钮, 将出现SQL Server配置”窗口:

In this window, how the connection with the SQL Server will be established can be chosen by using SQL or Windows authentication. As an example, the Windows authentication is chosen. In the Server fields, type the name of SQL Server on which is located a database that is chosen to be synchronized with Azure hub database and, in the Database field, enter the name of the database.

在此窗口中,可以使用SQLWindows身份验证选择如何建立与SQL Server的连接。 例如,选择Windows身份验证。 在“ 服务器”字段中,键入SQL Server的名称,在该SQL Server上选择了要与Azure Hub数据库同步的数据库,然后在“数据库”字段中,输入数据库的名称。

For example, the AdventureWorksOnPremises empty database is chosen:

例如,选择了AdventureWorksOnPremises空数据库:

When the fields under the SQL Server Configuration window are filed in, click the Test Connection button to verify that the connection is successful. After verifying the connection, click the Save button:

填写“ SQL Server配置”窗口下的字段后,单击“ 测试连接”按钮以验证连接是否成功。 验证连接后,单击“ 保存”按钮:

The AdventureWorksOnPremises database will appear in the Databases list of the Microsoft SQL Data Sync window:

AdventureWorksOnPremises数据库将出现在“ Microsoft SQL数据同步”窗口的“数据库”列表中:

Now, the Microsoft SQL Data Sync window can be closed.

现在,可以关闭“ Microsoft SQL数据同步”窗口。

Again, go back to Azure portal and, on the Select Sync Agent tab, press the OK button:

再次,返回到Azure门户,然后在“ 选择同步代理”选项卡上,按“ 确定”按钮:

Now, under the Configure On-Premises tab, select Select the Database, the SelectDatabase tab will appear. On the Sync Member Name box, enter the name for the new sync member. Under the On-premises databases connected to this agent combo box, select the SQL Server database (AdventureWorksOnPremises) and, under the Sync Directions combo box, choose how the data synchronization will be performed.

现在, 配置内部部署选项卡下,选择选择数据库 ,该SelectDatabase标签将会出现。 在“同步成员名称”框中,输入新同步成员的名称。 在“ 连接到此代理的本地数据库”组合框下,选择“ SQL Server”数据库( AdventureWorksOnPremises ),然后在“ 同步方向”组合框下,选择如何执行数据同步。

One of the following options can be selected:

可以选择以下选项之一:

  • Bi-directional Sync: data changes in either on-premises SQL Server database or the hub database are written to the other database. 双向同步:将本地SQL Server数据库或中心数据库中的数据更改写入另一个数据库。
  • To the Hub: data changes in the on-premises SQL Server database are written to the hub database, but changes in the hub database are not written to on-premises SQL Server 到集线器:将本地SQL Server数据库中的数据更改写入集线器数据库,但不将集线器数据库中的更改写入本地SQL Server
  • From the Hub: data changes in the hub database are written to the on-premises SQL Server, but changes from the on-premises SQL Server are not written to the hub database. 从集线器:集线器数据库中的数据更改将写入本地SQL Server,但本地SQL Server的更改不会写入集线器数据库。

In this example, the data synchronization will be performed from the hub database to the on-premises database, which means that the From the Hub option will be chosen in the Sync Directions combo box:

在此示例中,将从中心数据库到本地数据库执行数据同步,这意味着将在“ 同步方向”组合框中选择“ 来自中心”选项

Press the OK button on the SelectDatabase and Configure On-Premises tabs and wait a couple of seconds for the new member to be crated:

按下“选择数据库”和“ 配置本地”选项卡上的“ 确定”按钮,并等待几秒钟以创建新成员:

On the Select sync members tab, press the OK button to close this tab. After a couple of seconds, the Configure sync group will be highlighted:

在“ 选择同步成员”选项卡上,按“确定”按钮以关闭此选项卡。 几秒钟后,“ 配置同步”组将突出显示:

Under the Tables tab in the Select a database combo box, choose the database and press the Refresh Shema button. After a while, under the Select tables to sync list, the tables will appear. Select the tables that want to synchronize. In the Select fields to sync list, all columns from the tables that are selected in the Select tables to sync list will be listed. By default, all available columns under the Select fields to sync list are selected. The columns that don’t want to be synchronized can be uncheck, but make sure that the columns with Primary Key stay checked:

在“ 选择数据库”组合框的“ 表”选项卡下,选择数据库,然后按“ 刷新 Shema”按钮。 稍后,在“ 选择要同步的表”列表下,将出现这些表。 选择要同步的表。 在“ 选择要同步的字段”列表中,将列出在“ 选择要同步的表”列表中选择的表中的所有列。 默认情况下, 选择“选择要同步的字段”列表下的所有可用列。 可以取消选中不想同步的列,但是请确保具有“ 主键”的列保持选中状态:

After everything is set, press the Save button.

设置完所有内容后,按“ 保存”按钮。

Now, all that can be done is to wait 5 minutes which is set in the Sync Frequency section to trigger synchronization or by clicking the Sync button to trigger synchronization immediately:

现在,所有要做的就是等待5分钟,这是在“ 同步频率”部分中设置的以触发同步,或者通过单击“ 同步”按钮立即触发同步:

In the Logs list, it can be checked if synchronization goes well or with errors. To check if the data appear in the on-premises SQL Server database, connect to SQL Server where is located the sync member database and, in Object Explorer, check if the desired tables appear in the list under the Tables folder:

在“ 日志”列表中,可以检查同步是否顺利或出现错误。 若要检查数据是否显示在本地SQL Server数据库中,请连接到同步成员数据库所在SQL Server,然后在“ 对象资源管理器”中检查所需的表是否出现在“ 表”文件夹下的列表中

In case some other problems with SQL Data Sync happen, please visit the Troubleshoot issues with SQL Data Sync page

如果发生SQL Data Sync的其他问题,请访问“ SQL Data Sync的故障排除”页面

翻译自: https://www.sqlshack.com/how-to-sync-azure-sql-databases-and-on-premises-databases-with-sql-data-sync/

azure云数据库

azure云数据库_如何使用SQL Data Sync同步Azure SQL数据库和本地数据库相关推荐

  1. azure云 试用_真实世界的云迁移:Azure前门,用于全局HTTP和基于路径的负载平衡

    azure云 试用 As I've mentioned lately, I'm quietly moving my Website from a physical machine to a numbe ...

  2. java azure blob 查询_快速入门:适用于 Java 的 Azure Blob 存储客户端库 v8 | Microsoft Docs...

    您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn. 快速入门:使用 Jav ...

  3. 从高德上同步省市区行政区划数据到本地数据库demo

      本地数据库表结构: create table tbl_sys_area_bak (id int not nullprimary key,parent_ids varchar(255) null c ...

  4. java 登录按钮响应数据库_用户登录功能的实现—从前端到后台(包括数据库)...

    温馨提示:本文难度有点大,建议收藏后在阅读! 首先给大家分享一件糗事! 本来今天这篇文会很长的 写到一半突然发现 还没有给大家分享 数据库 jdbc MVC模式 直接就来分享实战了 我的锅! 源码会分 ...

  5. 织梦没备份MYSQL数据库_织梦模板小白讲堂五:dedecms如何备份mysql数据库

    这篇文章主要为大家详细介绍了织梦模板小白讲堂五:dedecms如何备份mysql数据库,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴. 在众多问题中,织梦模板小编 ...

  6. 构建azure对话机器人_如何在5分钟内使用Azure创建聊天机器人

    构建azure对话机器人 介绍 (Introduction) As we enter an era of artificial intelligence and serverless computin ...

  7. 在飞腾平台安装MySQL数据库_银河麒麟4.0.2(飞腾平台) 安装MySQL数据库

    1.安装操作系统:银河麒麟4.0.2-arm-desktop 2.更换系统源 vi /etc/apt/source.list deb http://mirrors.aliyun.com/debian/ ...

  8. 使用Red Gate Sql Data Compare 数据库同步工具进行SQL Server的两个数据库的数据比较、同步...

    Sql Data Compare 是比较两个数据库的数据是否相同.生成同步sql的工具. 这一款工具由Red Gate公司出品,我们熟悉的.NET Reflector就是这个公司推出的,它的SQLTo ...

  9. mysql做kv数据库_如何将SQL数据映射到KV数据库

    日常吐槽 国外文章也不是都是好文章啊,不要见到英文就觉得高大上了-- 前言 越来越多的关系型数据库底层选择基于KV构建,例如TiDB的TiKV(RocksDB),cockroach的levelDB,M ...

最新文章

  1. bilibili深入理解计算机系统笔记(1):汇编模拟器能跑了
  2. 单片机数码管从00到99C语言_MSP430单片机轻松入门与实践 — 畅学单片机
  3. Quiz 92 - twisted
  4. JQuery中serialize()、serializeArray()和param()的使用方法
  5. 全款房抵押贷款利息和抵押率各是多少?
  6. read cache_通过READ-BEHIND CACHE控制您的慢速生产者
  7. UVA - 540:Team Queue
  8. 叮咚周边优惠卡券小程序V6.0.4 完整安装包
  9. linux下C\C++ 开发小笔记
  10. 【Flink】Flink netty 通讯 PartitionRequestClient NettyPartitionRequestClient
  11. java 关键字null
  12. 【数位dp】HDOJ2089:不要62( 真· 数位dp入门题目)
  13. 学生签到系统c代码_学生信息管理系统C代码
  14. java 人脸活体检测_人脸识别活体检测测试案例
  15. 项目合同管理 考纲与考试要点
  16. linux下iso镜像的制作工具,ISO镜像文件制作转换工具(AnyToISO)
  17. js操作图片像素进行编辑
  18. 实习总结与收获(2021.6.7-2021.8.27)
  19. 猴子选大王(Java)
  20. SQL协同Excel制表统计各学院一二三等奖

热门文章

  1. Maven入门:使用Nexus搭建Maven私服及上传下载jar包
  2. Codevs 3342 绿色通道
  3. Oracle视图分类及各种操作讲解(超级好文)
  4. 获取一个目录下的所有文件
  5. 操作手机数据库的uri
  6. 剑指offer——替换字符串
  7. sqlserver得到行号
  8. 不用更改注册表就可以更改桌面所在的位置
  9. 35岁以上还没结婚的男女们,过的如何?
  10. 豆腐怎么做小朋友才喜欢吃?