Ultra-detailed! ! sql server database synchronization publish-subscribe network segments without public network ip FAQ

Problem Description

Host 1: release end

Ali cloud server - a public network ip

 

Host 2: subscribe end

Notebook - no public network ip

 

Small amount of data, mainly familiar publish-subscribe operational processes.

After the host 2 host only as a local backup 1, to amend data on the cloud server, sql server through the publish-subscribe feature local data synchronization.

Step by step under no introduction, step by step, this can be seen below

https://blog.csdn.net/u012861467/article/details/76411216

 

----------------------------------------------------------------------------------------------

Question 1

Ali cloud sql server configured, you can not use sql server native client remote login.

Check the following

1. To Ali cloud console firewall, open port 1433 Ali cloud (default sql server access ports)

This is very important, a lot of tutorial does not mention! ! !

 

 

2. put sql manager sql server agent two hosts in sql server service opens (originally disabled)

 

 

 

3. To turn on the remote server sql server username and password login, and set up a proxy account and password

 

At this point, it should be the ip address in the notebook sql server, and the proxy account and password just set the server to log into the cloud.

 

--------------------------------------------------------------------------------------

Question 2

Publish and subscribe processes

I would be the first in the cloud sql server clients

Copy --- release --- New Publication

 

1. Select which release

 

 

 

This point can be the difference between four kinds of queries issued their own

To Note: When a transactional publication, is published table have a primary key

 

2. How to connect the published end

 

 

 

 

网上一般推荐是在云端和本地端都新建一个用户名,密码一样的windows账户,然后这里选择在windows账户下运行。

我这里使用sql server登录名

这里注意---登录名是sql server的登录名(就是一般是sa的那个)

 

-------------------------

以上是发布端

-------------------------

订阅端

1.使用别名

 

 

 

 

在这一步选择发布服务器时,要使用实际的服务器名称(使用windows方式登录时的名称),不能使用ip地址。

这里要在订阅服务器中添加发布服务器的别名,具体操作看下面

https://blog.csdn.net/u010457730/article/details/97276313

 

2.推送订阅还是请求订阅

 

 

 

这里我有个不懂的问题,之后会讲到。

 

3.连接到分发服务器

 

 

 

这里注意,要填写分发服务器的sql server登录名。

是登录名,sa那个

登录名不是服务器名,这点切记。

 

到这一步时,查看一下订阅服务器的同步状态

 

 

 

看看是否打钩了----这代表前面的设置正确,订阅服务器能访问到发布端。

本人一开始因为设置时填写错了用户名,在查看同步状态这里还是报错的。

 

--------------------------------------------------------------------------------

接下来,可以看看订阅服务器的数据是不是被同步了,如未同步,看看订阅端的作业历史记录

 

 

 

 

有可能还是报错

但是这个报错信息是什么玩意嘛???

“复制代理遇到问题。有关详细信息,请参阅上一个作业步骤历史记录消息或复制监视器”

 

原来要在发布端找具体错误信息。。。

 

 

 

 

启动发布端的复制监视器

在左侧选好具体的发布后,双击右侧中所有订阅中的错误的订阅,查看具体报错

 

 

 

真相大白--

由于出现操作系统错误 3,进程无法读取文件D:\XXXX\X.pre

 

原因原来是--这个路径是发布端存放快照文件的位置,但是由于不是网络文件夹,不能被访问。

这里提供一种简单的解决办法

参照这位的做法

https://www.cnblogs.com/mrray/archive/2011/03/17/1987123.html

 

直接把发布端的快照文件夹--名称为repldata的拷贝到订阅端的某个文件位置

再在订阅端修改快照位置

复制--本地订阅---具体的订阅---右键---属性

把快照文件夹位置修改为本地的那个位置。

很神奇的是,只需要修改一次就好。

 

 

到这一步,我的问题就解决了,以下是几点问题和思考

1.坑很多,但多查询相关资料,总是能够解决的。这个信心是一次次解决问题中锻炼出来的。

2.自身理论基础欠缺时,一些配置性操作就容易出问题。比如说不了解发布订阅的具体机制,就很难想到出现快照文件夹无法访问这个问题。

3.我的情景比较特殊,一台有公网ip,一台没有。我在网上看到的情况,一般要么是局域网,要么两台主机都是有公网ip的(这意味着发布端,订阅端都能用唯一的ip地址访问对方)。所以我一直怀疑我这种网络结构从原理上就不能使用发布订阅这种方式(因为发布端无法“找到”订阅端)。这也是我在配置中选择了从订阅端运行代理,因为订阅端是肯定能“找到”有公网ip的发布端的。这个问题还要细研究。

4.这四种发布-订阅的方式有什么区别?快照文件夹是什么原理?这是两个需要搞清楚的问题。

5.sql server这个这么常见的功能为什么如此多的坑。。。可能还是我太菜了。但起码这个问题是解决了,我又成长了一点点。

Guess you like

Origin www.cnblogs.com/take-it-easy/p/11688946.html