Step7:sql replication under multiple instances of Server

Source: Internet
Author: User
Tags aliases

I. What is covered in this article (Contents)
    1. What is covered in this article (Contents)
    2. Background (contexts)
    3. Build Step (Procedure)
    4. Precautions (Attention)
two. Background (contexts)

There is a database task in Server A that requires some of the table partial fields to be published and subscribed to Server B's Tasksiteinfo database, but a server is a bit special because it has a named instance in addition to the default instance: TZR06\SQLSERVER2008R2, If it is the default instance to not have too many problems, now because there is a named instance in the process of creating a publication subscription, there are some exceptions, so this is done as a record;

three. Build Step (Procedure)

(i) Environmental information

System environment: Windows Server R2 + SQL server R2

Publisher: 192.168.100.6,1433, server name: tzr06

Publisher named instance: SQLSERVER2008R2

Publish database: Task

Distribution server: Same machine as publisher

Subscriber: 192.168.100.8,1433, server name: tzr08

Subscription database: Tasksubscribe

Database account Number: Replicationuser/replicationpassword

(ii) Construction process

As mentioned above, the publisher has a default instance and a named instance, the default instance of the database port is 1433, then I disable it, and then set the port of the named instance to 1433, so this need to use the alias to implement the publication subscription.

A. Publisher configuration

First, create the same account and password (Replicationuser/replicationpassword) on the publication database and the subscription database, and set the security object for the task database, and set up such an account so that it is separate from the account that the program connects to the database. Can do the authority on the control, easy to troubleshoot problems;

--Create a Publisher account password use [master]gocreate LOGIN [Replicationuser] with password=n ' Replicationpassword ', default_database=[ Master], Check_expiration=off, Check_policy=offgoexec master. sp_addsrvrolemember @loginame = n ' replicationuser ', @rolename = n ' sysadmin ' gouse [task]gocreate USER [Replicationuser] for LOGIN [Replicationuser]gouse [Task]goalter USER [Replicationuser] with Default_schema=[dbo]go

(Figure1: Account password)

In the E-disk directory to create a folder: E:\ReplData, and set this folder for the shared directory, shared users for bfadmin;

(Figure2: Folder permissions)

Need to set the SQL Server Agent login account for the above folder access user bfadmin;

(Figure3:sql Server Agent login account)

(Figure4: Test network share)

(FIGURE5: Distribution server)

If you set the snapshot folder path to: E:\ReplData, even if your publisher is the Distributor itself, if the Subscriber is another machine, The subscription agent will not be able to access the snapshot file in the request (pull) Subscription (if there is no such limit for push subscriptions), unless your Publisher, distributor, and Subscriber are the same machine; you should set the snapshot folder path to: \\tzr06\ Repldata;

(Figure6: Snapshot folder)

(Figure7: Select Publish database)

(Figure8: Transactional release)

(Figure9: Select object)

(Figure10: Select object)

(FIGURE11: Select object)

(Figure12: Initialize subscription)

(Figure13: Security Setting)

Use the Replicationuser account created above as the account number and password to connect to the publisher;

(FIGURE14: Set account password)

(FIGURE15: Publish option)

(Figure16: Publication name)

(Figure17: Viewing replication)

B. Subscriber Configuration

After creating the publisher (the Distributor is also created together), you are ready to create the subscriber, following the specific steps for subscriber settings:

--Create Subscriber account password use [master]gocreate LOGIN [Replicationuser] with password=n ' Replicationpassword ', default_database=[ Master], Check_expiration=off, Check_policy=offgoexec master. sp_addsrvrolemember @loginame = n ' replicationuser ', @rolename = n ' sysadmin ' gouse [tasksiteinfo]gocreate USER [ Replicationuser] for LOGIN [replicationuser]gouse [Tasksiteinfo]goalter USER [Replicationuser] with default_schema=[ Dbo]go

After creating the database account, we then create the subscription, as mentioned above on the publisher has a named instance, so this is to follow TZR06\SQLSERVER2008R2 to set the server name, but during the connection process, the following error occurred:

(Figure18: Find publisher error message)

Using the above configuration at the Subscriber to use "Connect to the server" can also be unable to log on to the publisher, the firewall's inbound rules have been added to allow port 1433, and at the publisher using the Netstat view port, there is also listening, why can not connect it? Later in the "Connect server" Join 1433 is possible to log in, as shown in:

(Figure19: Log on to the publisher)

Using the same method, the Publisher cannot be found, and a new error message appears, as shown in:

(FIGURE20: Find publisher error message)

Since the need to add port number, then we try to use aliases, in the 64-bit operating system, you need to set both 32-bit and 64-bit network configuration, set the alias is: TZR06

(FIGURE21: Alias parameter value)

(figure22:32-bit aliases)

(figure23:64-bit aliases)

(Figure24: Find publisher error message)

Is there a TZR06 conflict? The modified alias is: Tzr06task

(Figure25: Modify 32-bit and 64-bit aliases)

(Figure26: Find publisher error message)

When creating a publication at the publisher, if the SQL Server DB instance name does not match the server name, the above error occurs, so the following SQL statement is executed at the publisher:

/* Returns property information about the server instance Windows Server and instance information associated with the specified SQL Server instance */select CONVERT (sysname, serverproperty (' servername '));/* Returns the name of the local server running SQL Server if the default instance is connected, the @ @SERVERNAME only returns servername If a named instance is connected, the string returned by the @ @SERVERNAME function is servername\ InstanceName format identifies instance name */select @ @SERVERNAME as ' Server name '

The above results are:

(Figure27: Find publisher error message)

If the two values are different, that can be modified in the following way:

/*sql Server database instance name inconsistent with server name resolution */if serverproperty (' SERVERNAME ') <>@ @SERVERNAME  BEGIN    DECLARE @ Server SYSNAME    set @[email protected] @SERVERNAME    EXEC sp_dropserver @[email protected]      SET @server =cast ( Serverproperty (' SERVERNAME ') as SYSNAME)    EXEC sp_addserver @[email protected], @local = ' local ' END

Later asked Gao Wenjia, suddenly thought: "At the Distributor and subscribers to set the alias, alias should be consistent with the server instance name to" continue to try, modify the alias: tzr06\sqlserver2008r2

(Figure28: Modify 32-bit and 64-bit aliases)

(Figure29: Select publish)

(Figure30: Pull subscription)

(Figure31: Select subscription database)

(FIGURE32: Distribution Agent Security)

(Figure33: Set account password)

(Figure34: Synchronization Schedule)

(Figure35: Initialize)

(Figure36: Create subscription)

(Figure37: Local subscription)

four. Precautions (Attention)

1. If the snapshot file that you set up at the publisher at the beginning is a local path, such as set to E:\ReplData, the following error may occur:

(Figure38: The system cannot find the path specified)

This time you re-publish the subscription is not the default path can be set, can be modified? I didn't find a place to set it, but I can modify it in a different way, and modify the snapshot path in the publication properties:

(Figure39: Default folder)

(Figure40: Set folder)

To modify the snapshot folder for subscription properties at the Subscriber:

(Figure41: Alternate folder)

2. At the subscriber also need to set the SQL Server Agent login account for the above folder access user Bfadmin, or the following error will appear:

(Figure42: Error message)

You need to restart the SQL Server Agent service after setting up your account

(Figure43: Subscriber SQL Server Agent settings)

3. The subscriber cannot be "reinitialized" at the publisher, reporting the following error message, even if it is set at the publisher:

(Figure44: Error message)

The above error has not been resolved temporarily, but the copy of the named instance has been successful, although successful, but still want to recommend that you try not to install multiple instances in the production environment, to avoid unnecessary problems;

Step7:sql replication under multiple instances of Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.