SQL Server - 链接服务器,查询一种方式可以,但另一种方式呢?

发布于 2024-10-07 11:08:01 字数 720 浏览 1 评论 0原文

我有两个 SQL Server,它们已使用 ServerA 中的 sp_addlinkedserver 'ServerB\Instance' 和 ServerB 中的 sp_addlinkedserver 'ServerA\Instance' 进行链接。

如果我从 ServerA 执行以下查询,则一切正常:

SELECT *
FROM [ServerB\Instance].Database.dbo.Table

如果我从 ServerB 执行以下查询,则会发生错误:

SELECT *
FROM [ServerA\Instance].Database.dbo.Table

错误:

消息 18456,级别 14,状态 1,第 1 行 用户“NT”登录失败 权威\匿名登录'。

在 ServerA 和 ServerB 上运行 SQL Server 的服务帐户已在两台服务器上获得提升的权限,试图解决该问题,但没有成功。

我已经完成了研究,但希望避免复杂的过程一种沟通方式就可以了。

I have two SQL Servers which have been linked using sp_addlinkedserver 'ServerB\Instance' from ServerA and sp_addlinkedserver 'ServerA\Instance' from ServerB.

If I execute the following query from ServerA then everything is okay:

SELECT *
FROM [ServerB\Instance].Database.dbo.Table

If I execute the following query from ServerB an error occurs:

SELECT *
FROM [ServerA\Instance].Database.dbo.Table

Error:

Msg 18456, Level 14, State 1, Line 1
Login failed for user 'NT
AUTHORITY\ANONYMOUS LOGON'.

The service accounts that SQL Server runs under on ServerA and ServerB have been given elevated permissions on both servers in an attempt to solve the issue but no success.

I have done research but want to avoid a convoluted process when communication one way is okay.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

提笔书几行 2024-10-14 11:08:01

我已经通过以下过程解决了这个问题:

  1. 删除了两个链接服务器。
  2. 从 ServerA RDP (SSMS) 为 ServerA 执行 sp_addlinkedserver,从 ServerB RDP (SSMS) 为 ServerB 执行 sp_addlinkedserver。

以前,我仅从一台服务器 RDP (SSMS) 会话为两台服务器执行 sp_addlinkedserver。从每个服务器执行已经解决了问题。如果有人可以添加评论来解释为什么会这样,我将非常感激。

I have solved this by following the process:

  1. Deleted both linked servers.
  2. Executed sp_addlinkedserver for ServerA from ServerA RDP (SSMS) and for ServerB from ServerB RDP (SSMS).

Previously I had executed sp_addlinkedserver for both servers from the one server RDP (SSMS) session only. Executing from each server has solved the problem. If someone can add comments as to why this is then I will be very grateful.

离不开的别离 2024-10-14 11:08:01

在 SQL Management Studio 中,查看从服务器 B 到服务器 A 的链接服务器的属性。您可以从那里查看一个安全“选项卡”。这将告诉您从 B 到 A 的连接正在使用的安全上下文。当您没有为链接服务器设置有效的安全上下文时,通常会发生您收到的错误。

它可以从 A 到 B 而不能从 B 到 A 工作的原因是您需要在每一端正确设置链接服务器。只为一件事做是不会有双赢的。

In SQL Management Studio, view the properties for the linked server from Server B to Server A. There's a security "tab" that you can view from there. That will tell you the security context the connection from B to A is using. The error you are getting normally occurs when you don't have a valid security context set for the linked server.

The reason that it can work from A to B and not B to A is that you need to set up the linked server correctly on each side. Just doing it for one is not going to work to go both ways.

梦归所梦 2024-10-14 11:08:01

您必须将本地用户映射到另一台服务器上的远程用户。
可以通过调用 sp_addremotelogin() 来执行此操作,如下所述:http://msdn。 microsoft.com/en-us/library/ms186338.aspx

You have to map your local user to a remote user on the other server.
Do can do this by calling sp_addremotelogin() as explained here: http://msdn.microsoft.com/en-us/library/ms186338.aspx

围归者 2024-10-14 11:08:01

要解决此问题,请使用下列方法之一:

  • 使用 sp_addlinkedsrvlogin 存储过程或“链接服务器属性”对话框中的“安全”选项卡,将服务器 A 上的客户端映射到服务器 B 上的标准安全登录。企业管理器。

  • 如果您在基于 Microsoft Windows 2000 的计算机上运行的 SQL Server 实例上运行分布式查询,请将 SQL Server 配置为使用命名管道服务器网络库(而不是使用 TCP)侦听客户端请求。 /IP Server 网络库或多协议服务器网络库。要为 SQL Server 配置服务器网络库,请使用服务器网络实用程序。

看一下:

http://support.microsoft.com/kb/238477

To work around this problem, use one of the following methods:

  • Map the clients on server A to a standard security login on server B, by using either the sp_addlinkedsrvlogin stored procedure or the Security tab of the Linked Server Properties dialog box in Enterprise Manager.

  • If you are running the distributed query on an instance of SQL Server that is running on a Microsoft Windows 2000-based computer, configure SQL Server to listen for client requests by using the Named Pipes Server network library, instead of using the TCP/IP Server network library or the Multiprotocol Server network library. To configure the Server network libraries for SQL Server, use the Server Network Utility.

Take a look at:

http://support.microsoft.com/kb/238477

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文