0 évaluation0% ont trouvé ce document utile (0 vote)
56 vues7 pages
Database mirroring involves maintaining two copies of a database on separate computers for high availability. The principal database is available to clients, while the mirror database applies transaction logs from the principal. Replication can be configured with database mirroring by setting up the mirror to use the same distributor and configuring replication agents to detect failover between the principal and mirror databases.
Database mirroring involves maintaining two copies of a database on separate computers for high availability. The principal database is available to clients, while the mirror database applies transaction logs from the principal. Replication can be configured with database mirroring by setting up the mirror to use the same distributor and configuring replication agents to detect failover between the principal and mirror databases.
Database mirroring involves maintaining two copies of a database on separate computers for high availability. The principal database is available to clients, while the mirror database applies transaction logs from the principal. Replication can be configured with database mirroring by setting up the mirror to use the same distributor and configuring replication agents to detect failover between the principal and mirror databases.
2 out of 5 rated this helpful - Rate this topic Database mirroring can be used in conjunction with replication to improve availability for the publication database. Database mirroring involves two copies of a single database that typically reside on different computers. At any given time, only one copy of the database is currently available to clients. This copy is known as the principal database. Updates made by clients to the principal database are applied on the other copy of the database, known as the mirror database. Mirroring involves applying the transaction log from every insertion, update, or deletion made on the principal database onto the mirror database. Replication failover to a mirror is fully supported for publication databases, with limited support for subscription databases. Database mirroring is not supported for the distribution database. For information about recovering a distribution database or subscription database without any need to reconfigure replication, see Back Up and Restore Replicated Databases. For information about mirroring the subscriber database, see the SQL Server Replication: Providing High Availability using Database Mirroring. Note After a failover, the mirror becomes the principal. In this topic, "principal" and "mirror" always refer to the original principal and mirror. Requirements and Considerations for Using Replication with Database Mirroring
Be aware of the following requirements and considerations when using replication with database mirroring: The principal and mirror must share a Distributor. We recommend that this be a remote Distributor, which provides greater fault tolerance if the Publisher has an unplanned failover. The Publisher and Distributor must be Microsoft SQL Server 2005 or a later version. Subscribers can be any version, but merge replication pull subscriptions from a version prior to SQL Server 2005 do not support failover; the agent in this case runs at the Subscriber and previous versions of the agent are not mirror aware. Replication to such Subscribers resumes if the database fails back from the mirror to the principal. Replication supports mirroring the publication database for merge replication and for transactional replication with read-only Subscribers or queued updating Subscribers. Immediate updating Subscribers, Oracle Publishers, Publishers in a peer-to-peer topology, and republishing are not supported. Metadata and objects that exist outside the database are not copied to the mirror, including logins, jobs, linked servers, and so on. If you require the metadata and objects at the mirror, you must copy them manually. For more information, see Management of Logins and Jobs After Role Switching (SQL Server). Configuring Replication with Database Mirroring
Configuring replication and database mirroring involves five steps. Each step is described in more detail in the following section. 1. Configure the Publisher. 2. Configure database mirroring. 3. Configure the mirror to use the same Distributor as the principal. 4. Configure replication agents for failover. 5. Add the principal and mirror to Replication Monitor. Steps 1 and 2 can also be performed in the opposite order. To configure database mirroring for a publication database 1. Configure the Publisher: a. We recommend using a remote Distributor. For more information about configuring distribution, see Configure Distribution. b. You can enable a database for snapshot and transactional publications and/or merge publications. For mirrored databases that will contain more than one type of publication, you must enable the database for both types at the same node using sp_replicationdboption. For example, you could execute the following stored procedure calls at the principal: c. exec sp_replicationdboption @dbname='<PublicationDatabase>', @optname='publish', @value=true d. exec sp_replicationdboption @dbname='<PublicationDatabase>', @optname='mergepublish', @value=true For more information about creating publications, see Publish Data and Database Objects. 2. Configure database mirroring. For more information, see Establish a Database Mirroring Session Using Windows Authentication (SQL Server Management Studio)and Setting Up Database Mirroring (SQL Server). 3. Configure distribution for the mirror. Specify the mirror name as the Publisher, and specify the same Distributor and snapshot folder that the principal uses. For example, if you are configuring replication with stored procedures, execute sp_adddistpublisher at the Distributor; and then execute sp_adddistributor at the mirror. For sp_adddistpublisher: o Set the value of the @publisher parameter to the network name of the mirror. o Set the value of the @working_directory parameter to the snapshot folder used by the principal. 4. Specify the mirror name for the PublisherFailoverPartner agent parameter. Agent This parameter is required for the following agents to identify the mirror after failover: o Snapshot Agent (for all publications) o Log Reader Agent (for all transactional publications) o Queue Reader Agent (for transactional publications that support queued updating subscriptions) o Merge Agent (for merge subscriptions) o SQL Server replication listener (replisapi.dll: for merge subscriptions synchronized using Web synchronization) o SQL Merge ActiveX Control (for merge subscriptions synchronized with the control) The Distribution Agent and Distribution ActiveX Control do not have this parameter because they do not connect to the Publisher. Agent parameter changes take effect the next time the agent is started. If the agent runs continuously, you must stop and restart the agent. Parameters can be specified in agent profiles and from the command prompt. For more information, see: o View and Modify Replication Agent Command Prompt Parameters (SQL Server Management Studio) o Replication Agent Executables Concepts We recommend adding the PublisherFailoverPartner to an agent profile, and then specifying the mirror name in the profile. For example, if you are configuring replication with stored procedures: -- Execute sp_help_agent_profile in the context of the distribution database to get the list of profiles. -- Select the profile id of the profile that needs to be updated from the result set. -- In the agent_type column returned by sp_help_agent_profile: -- 1 = Snapshot Agent; 2 = Log Reader Agent; 3 = Distribution Agent; 4 = Merge Agent; 9 = Queue Reader Agent.
exec sp_help_agent_profile;
-- Setting the -PublisherFailoverPartner parameter in the default Snapshot Agent profile (profile 1). -- Execute sp_add_agent_parameter in the context of the distribution database. exec sp_add_agent_parameter @profile_id = 1, @parameter_name = N'- PublisherFailoverPartner', @parameter_value = N'<Failover Partner Name>';
-- Setting the -PublisherFailoverPartner parameter in the default Merge Agent profile (profile 6). -- Execute sp_add_agent_parameter in the context of the distribution database. exec sp_add_agent_parameter @profile_id = 6, @parameter_name = N'- PublisherFailoverPartner', @parameter_value = N'<Failover Partner Name>'; 5. Add the principal and mirror to Replication Monitor. For more information, see Add and Remove Publishers from Replication Monitor.
How to: Add and Remove Publishers from Replication Monitor (Replication Monitor) SQL Server 2008 Other Versions
This topic has not yet been rated - Rate this topic The server from which you launch Replication Monitor is automatically added to the monitor if it is a Publisher. Additional Publishers can be added through the Add Publisherdialog box. After adding a Publisher, it is displayed in a group in the left pane of the monitor. The My Publishers group is included by default, but you can create new groups to manage one or more replication topologies. For information about starting Replication Monitor, see How to: Start Replication Monitor (Replication Monitor). To add a SQL Server Publisher 1. Right-click the Replication Monitor node or a Publisher group node in the left pane, and then click Add Publisher. 2. In the Add Publisher dialog box, click Add, and then click Add SQL Server Publisher. 3. In the Connect to Server dialog box, enter the name of the Publisher, and then select the authentication type. If you select SQL Server Authentication, enter a login and password. The credentials you specify are saved by Replication Monitor to use when connecting to this server in the future. The Windows account or SQL Server login specified must be a member of the sysadmin fixed server role or a member of the replmonitor fixed database role in the distribution database. 4. Click Connect. If the Publisher uses a remote Distributor, you will be prompted to connect to the Distributor in the Connect to Server dialog box. The credentials you specify are saved by Replication Monitor to use when connecting to this server in the future. The Windows account or SQL Server login specified must be a member of the sysadmin fixed server role or a member of the replmonitor fixed database role in the distribution database. 5. The name of the Publisher and Distributor are displayed in the Start monitoring the following Publisher(s) grid. 6. To specify refresh and connection options for the Publisher, select the Publisher in the grid, and modify options as necessary. For more information about refresh options, see Caching, Refresh, and Replication Monitor Performance. 7. Select the group under which the Publisher should be displayed in Replication Monitor. To create a new group, click New Group, and then enter a group name; select the group in the Show this Publisher(s) in the following group list. 8. Click OK. To add an Oracle Publisher 1. Right-click the Replication Monitor node or a Publisher group node in the left pane, and then click Add Publisher. 2. In the Add Publisher dialog box, click Add, and then click Add Oracle Publisher. 3. In the Connect to Server dialog box, enter the name of the Microsoft SQL Server Distributor associated with the Oracle Publisher, and then select the authentication type. If you select SQL Server Authentication, enter a login and password. The credentials you specify are saved by Replication Monitor to use when connecting to this server in the future. The Windows account or SQL Server login specified must be a member of the sysadmin fixed server role or a member of the replmonitor fixed database role in the distribution database. 4. Click Connect. 5. The name of the Publisher and Distributor are displayed in the Start monitoring the following Publisher(s) grid. 6. To specify refresh and connection options for the Publisher, select the Publisher in the grid, and modify options as necessary. For more information about refresh options, see Caching, Refresh, and Replication Monitor Performance. 7. Select the group under which the Publisher should be displayed in Replication Monitor. To create a new group, click New Group, and then enter a group name; select the group in the Show this Publisher(s) in the following group list. 8. Click OK. To add one or more Publishers that use the same Distributor 1. Right-click the Replication Monitor node or a Publisher group node in the left pane, and then click Add Publisher. 2. In the Add Publisher dialog box, click Add, and then click Specify a Distributor and Add Its Publishers. 3. In the Connect to Server dialog box, enter the name of the Distributor, and then select the authentication type. If you select SQL Server Authentication, enter a login and password. The credentials you specify are saved by Replication Monitor to use when connecting to this server in the future. The Windows account or SQL Server login specified must be a member of the sysadmin fixed server role or a member of the replmonitor fixed database role in the distribution database. 4. Click Connect. 5. The name of the Distributor and each Publisher are displayed in the Start monitoring the following Publisher(s) grid. If a Publisher has already been added to Replication Monitor, it does not appear in the grid. 6. To specify refresh and connection options for the Publisher, select the Publisher in the grid, and modify options as necessary. For more information about refresh options, see Caching, Refresh, and Replication Monitor Performance. 7. Select the group under which Publishers should be displayed in Replication Monitor. To create a new group, click New Group, and then enter a group name; select the group in the Show this Publisher(s) in the following group list. 8. Click OK. To modify settings for the Publisher and Publisher Groups 1. Right-click a Publisher in the left pane, and then click Publisher Settings. 2. Make any changes in the Publisher Settings dialog box: o To change the credentials that Replication Monitor uses to connect to a server, click Publisher Connection or Distributor Connection, and then enter credentials in the Connect to Server dialog box. o To move a Publisher from one group to another, select the Publisher in the Start monitoring the following Publisher(s) grid, and then select the new group in the Show this Publisher(s) in the following group list. 3. Click OK. To remove a Publisher from Replication Monitor 1. Right-click a Publisher in the left pane. 2. Click Remove. To add a Publisher group to Replication Monitor Publisher groups can be created only when adding a Publisher or modifying settings for a Publisher. See the how to procedures on adding a Publisher for more information. To remove a Publisher group from Replication Monitor 1. Move all Publishers to a different group or remove them from Replication Monitor. For more information, see previous procedures in this topic. 2. Right-click the Publisher group, and then click Remove.
(Contd from current article) Maintaining a Mirrored Publication Database
Maintaining a mirrored publication database is essentially the same as maintaining a non-mirrored database, with the following considerations: Administration and monitoring must occur at the active server. In SQL Server Management Studio, publications appear under the Local Publications folder only for the active server. For example, if you failover to the mirror, the publications are displayed at the mirror and are no longer displayed at the principal. If the database fails over to the mirror, you might need to manually refresh Management Studio and Replication Monitor for the change to be reflected. Replication Monitor displays Publisher nodes in the object tree for both the principal and the mirror. If the principal is the active server, publication information is displayed only under the principal node in Replication Monitor. If the mirror is the active server: o If an agent has an error, the error is indicated only on the principal node, not on the mirror node. o If the principal is unavailable, the principal and mirror nodes display identical lists of publications. Monitoring should be performed on the publications under the mirror node. When using stored procedures or Replication Management Objects (RMO) to administer replication at the mirror, for cases in which you specify the Publisher name, you must specify the name of the instance on which the database was enabled for replication. To determine the appropriate name, use the functionpublishingservername. When a publication database is mirrored, the replication metadata stored in the mirrored database is identical to the metadata stored in the principal database. Consequently, for publication databases enabled for replication at the principal, the Publisher instance name stored in system tables at the mirror is the name of the principal, not the mirror. This affects replication configuration and maintenance if the publication database fails over to the mirror. For example, if you are configuring replication with stored procedures on the mirror after a failover, and you want to add a pull subscription to a publication database that was enabled at the principal, you must specify the principal name rather than the mirror name for the @publisher parameter of sp_addpullsubscription orsp_addmergepullsubscription. If you enable a publication database at the mirror after failover to the mirror, the Publisher instance name stored in system tables is the name of the mirror; in this case, you would use the name of the mirror for the @publisher parameter. Note In some cases, such as sp_addpublication, the @publisher parameter is supported only for non-SQL Server Publishers; in these cases, it is not relevant for SQL Server database mirroring. To synchronize a subscription in Management Studio after a failover: synchronize pull subscriptions from the Subscriber; and synchronize push subscriptions from the active Publisher. Replication Behavior if Mirroring is Removed Keep the following issues in mind if database mirroring is removed from a published database: If the publication database at the principal is no longer mirrored, replication continues to work unchanged against the original principal. If the publication database fails over from the principal to the mirror and the mirroring relationship is subsequently disabled or removed, replication agents will not function against the mirror. If the principal is permanently lost, disable and then reconfigure replication with the mirror specified as the Publisher. If database mirroring is removed completely, the mirror database is in a recovery state and must be restored in order to become functional. The behavior of the recovered database with respect to replication depends on whether the KEEP_REPLICATION option is specified. This option forces the restore operation to preserve replication settings when restoring a published database to a server other than that on which the backup was created. Use the KEEP_REPLICATION option only when the other publication database is unavailable. The option is not supported if the other publication database is still intact and replicating. For more information about KEEP_REPLICATION, see RESTORE (Transact-SQL). Log Reader Agent Behavior
The following table describes Log Reader Agent behavior for the various operating modes of database mirroring. Operating mode Log Reader Agent behavior if the mirror is unavailable High-safety mode with automatic failover If the mirror is unavailable, the Log Reader Agent propagates commands to the distribution database. The principal cannot failover to the mirror until the mirror is back online and has all transactions from the principal. High-performance mode If the mirror is unavailable, the principal database is running exposed (that is, unmirrored). However, the Log Reader Agent only replicates those transactions that are hardened on the mirror. If service is forced and the mirror server assumes the role of the principal, the Log Reader Agent will work against the mirror and start picking up the new transactions. Be aware that replication latency will increase if the mirror falls behind the principal. High-safety mode without automatic failover All committed transactions are guaranteed to be hardened to disk on the mirror. The Log Reader Agent replicates only those transactions that are hardened on the mirror. If the mirror is unavailable, the principal disallows further activity in the database; therefore the Log Reader Agent has no transactions to replicate.