简体   繁体   English

请求的操作需要在SQL Server中进行提升(以管理员身份运行)

[英]The requested operation requires elevation (Run as administrator) in SQL Server

I am trying to execute a xp_cmdshell command to change the ip of the SQL Server server. 我正在尝试执行xp_cmdshell命令来更改SQL Server服务器的IP。

The EXEC command is as follows: EXEC命令如下:

EXEC master.dbo.xp_cmdshell 'netsh interface ipv4 set address name="Ethernet" static 192.168.XXX.XXX 255.255.255.0 192.168.XXX.XXX'

The IP is X'ed for security reasons. 出于安全原因,此IP为X'ed。

The netsh command executes successfully under command console, but the SQL Server query generates the following error: netsh命令在命令控制台下成功执行,但是SQL Server查询生成以下错误:

The requested operation requires elevation (Run as administrator). 请求的操作需要提升(以管理员身份运行)。

The full query code is: 完整的查询代码为:

USE MASTER;
GO

CREATE LOGIN [backup-dt\itm] FROM WINDOWS;

EXEC sp_xp_cmdshell_proxy_account 'backup-dt\itm','Letmein@2018'

--Create the database role and assign rights to the role
CREATE ROLE [CmdShell_Executor] AUTHORIZATION [dbo]
GRANT EXEC ON xp_cmdshell TO [CmdShell_Executor]

--Then once done create users and assign to CmdShell_Executor
CREATE USER [Backup-dt\CmdShellExec] FROM LOGIN [Backup-dt\CmdShellExec];
EXEC sp_addrolemember [CmdShell_Executor],[Backup-dt\CmdShellExec];

grant execute on xp_cmdshell to [backup-dt\itm]
EXEC master.dbo.xp_cmdshell 'netsh interface ipv4 set address name="Ethernet" static 192.168.XXX.XXX 255.255.255.0 192.168.XXX.XXX'

Any idea how can I elevate the access to administrator and make this command execute successfully? 知道如何提高对管理员的访问权限并使该命令成功执行吗?

Thanks, 谢谢,

this code is going to be a part of another code which checks for another server's availability. 该代码将成为另一个代码的一部分,该代码检查另一台服务器的可用性。 If the other server fails for some reason, this server with change its IP to that server's IP to take over the database connectivity 如果其他服务器由于某种原因发生故障,则此服务器会将其IP更改为该服务器的IP以接管数据库连接

So Windows has a feature for this in Windows Failover Clustering . 因此Windows在Windows 故障转移群集中具有此功能。 It will monitor the health of multiple instances, and fail over resources (including IP addresses) to healthy nodes. 它将监视多个实例的运行状况,并将资源(包括IP地址)故障转移到运行状况良好的节点。

You can create a cluster just to manage a floating IP address, and have SQL Server instances running on both nodes. 您可以创建一个仅用于管理浮动IP地址的群集,并在两个节点上运行SQL Server实例。 But that's only a partial solution, as the SQL Servers may both actually be online in case of a network issue, and you'll have a split brain. 但这只是部分解决方案,因为在出​​现网络问题的情况下,SQL Server可能实际上都处于联机状态,并且您会产生分歧。

SQL Server integrates with Windows Failover Clustering to provide two complete, and widely-used HA solutions. SQL Server与Windows故障转移群集集成在一起,以提供两个完整且使用广泛的HA解决方案。 Failover Cluster Instances , which use shared (or replicated) storage, and Availability Groups (which don't need shared storage). 故障转移群集实例 ,它们使用共享(或复制)存储,以及可用性组 (不需要共享存储)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM