使用新发布的快照初始化订阅Initialize a Subscription with a Snapshot for a New Publication
03/23/2020
本文内容
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)SQL ServerSQL Server (all supported versions) Azure SQL 托管实例Azure SQL Managed InstanceAzure SQL 托管实例Azure SQL Managed Instance适用于:Applies to: SQL ServerSQL Server(所有支持的版本)SQL ServerSQL Server (all supported versions) Azure SQL 托管实例Azure SQL Managed InstanceAzure SQL 托管实例Azure SQL Managed Instance
本文描述初始化复制发布时发生的过程。This article describes the processes that occur when a replication publication is initialized. 初始快照将应用于订阅服务器。An initial snapshot is applied to the Subscribers.
新发布的快照Snapshot for a new publication
默认情况下,在创建发布后捕获快照。By default, a snapshot is captured after a publication is created.
快照将复制到快照文件夹。The snapshot is copied to the snapshot folder. 对于使用“新建发布向导”创建的合并发布,将发生此默认行为。This default behavior occurs for merge publications that are created by using the New Publication Wizard.
快照应用于订阅服务器Snapshot is applied to Subscriber
新快照由代理应用于订阅服务器。The new snapshot is applied to the Subscriber by an agent. 应用发生在订阅的初始同步期间。The applying occurs during the initial synchronization of the subscription. 应用哪个代理取决于发布的类型:Which agent does the applying depends on the type of publication:
对于事务和快照发布 :For transactional and snapshot publications:
分发代理。The Distribution Agent.
对于合并发布 :For merge publications:
合并代理。The Merge Agent.
发布的类型Type of publication
下表显示了每种发布类型的快照内容。The following table displays the contents of the snapshot, for each type of publication.
快照用于的发布类型Publication type that the snapshot is for
快照的内容Contents of the snapshot
快照发布Snapshot publication
事务发布Transactional publication
不使用参数化筛选器的合并发布Merge publication that doesn't use parameterized filters
架构Schema
大容量复制程序 (BCP) 文件中的数据Data, in files for the bulk copy program (BCP)
约束Constraints
扩展属性Extended properties
索引Indexes
触发器Triggers
复制所需的系统表System tables needed for replication
使用参数化筛选器的合并发布Merge publication that does use parameterized filters
架构快照(复制脚本、已发布对象,但没有数据)Schema snapshot (replication scripts, published objects, but no data)
属于订阅分区的数据Data that belongs to the subscription's partition
使用参数化筛选器的合并发布的两部分过程Two-part process with merge publication that uses parameterized filters
对于使用参数化筛选器的合并发布,将使用以下两部分过程创建快照:For a merge publication that uses parameterized filters, the snapshot is created by using the following two-part process:
此时会创建一个架构快照,其中包含以下项:A schema snapshot is created, which contains the following items:
复制脚本。Replication scripts.
已发布对象的架构。Schema of the published objects.
(但没有数据。)(But no data.)
然后,使用快照初始化每个订阅。Each subscription is then initialized with a snapshot. 快照包括以下项:The snapshot includes the following items:
脚本和架构(从架构快照复制)。Scripts and schema, copied from the schema snapshot.
属于订阅分区的数据。Data that belongs to the subscription's partition.
复制类型Type of replication
快照中包含的文件类型取决于复制类型和发布中的项目。The file types contained in the snapshot depend on the type of replication, and on the articles in your publication.
复制类型Type of Replication
常用快照文件Common Snapshot Files
快照复制或Snapshot Replication, or
事务复制Transactional Replication
• 架构 (.sch)• Schema (.sch)
• 数据 (.bcp)• Data (.bcp)
• 约束和索引 (.dri)• Constraints and indexes (.dri)
• 压缩的快照文件 (.cab)• Compressed snapshot files (.cab)
• 触发器 (.tag),仅用于更新订阅服务器• Triggers (.tag), only to update a Subscriber
• 约束 (.idx)。• Constraints (.idx).
合并复制Merge Replication
• 架构 (.sch)• Schema (.sch)
• 数据 (.bcp)• Data (.bcp)
• 约束和索引 (.dri)• Constraints and indexes (.dri)
• 压缩的快照文件 (.cab)• Compressed snapshot files (.cab)
• 触发器 (.trg)• Triggers (.trg)
• 系统表数据 (.sys)• System table data (.sys)
• 冲突表 (.cft)。• Conflict tables (.cft).
快照文件夹Snapshot folder
通过将文件复制到默认的快照文件夹,或复制到用于快照的备用文件夹,可以传输这些文件 。The files are transferred by being copied to the default snapshot folder, or to the alternate folder for snapshots.
配置分发服务器时指定快照文件夹。The snapshot folder is specified when the Distributor is configured. 创建发布时指定备用文件夹。The alternate folder is specified when the publication is created.
中断后恢复传输Resume transfer after interruption
如果传输由于不可靠的连接而中断,则网络连接恢复后将自动恢复将文件传输到快照文件夹的过程。Transfer of files to a snapshot folder automatically resumes if the transfer is interrupted by an unreliable connection.
为提高效率,恢复时不会重新发送中断前已传输完毕的任何文件。For efficiency, the resumption does not resend any files that were already fully transferred before the interruption.
快照选项Snapshot Options
使用快照初始化订阅时,有几个选项可用。There are several options available when initializing a subscription with a snapshot. 可以:You can:
指定一个备用快照文件夹位置,以替代默认的快照文件夹位置或者与之并存。Specify an alternate snapshot folder location instead of, or in addition, to the default snapshot folder location. 有关详细信息,请参阅修改快照选项。For more information, see Modify snapshot options.
压缩快照,以便在可移动介质上进行存储或者通过速度较低的网络进行传输。Compress snapshots for storage on removable media or for transfer over a slow network. For more information, see Compressed Snapshots.
在应用快照之前或之后执行 Transact-SQL 脚本。Execute Transact-SQL scripts before or after the snapshot is applied.
使用文件传输协议 (FTP) 传输快照文件。Transfer snapshot files using File Transfer Protocol (FTP). 有关详细信息,请参阅通过 FTP 传输快照。
另请参阅See Also