当前位置: 代码网 > it编程>数据库>MsSqlserver > SQL Server复制删除发布时遇到错误18752的问题及解决方法

SQL Server复制删除发布时遇到错误18752的问题及解决方法

2024年05月18日 MsSqlserver 我要评论
朋友反馈他无法删除一台sql server数据库上的发布,具体情况为删除一个sql server replication的发布时,遇到下面错误title: microsoft sql server m

朋友反馈他无法删除一台sql server数据库上的发布,具体情况为删除一个sql server replication的发布时,遇到下面错误

title: microsoft sql server management studio
------------------------------

无法删除发布“repl_itsms”。

------------------------------
additional information:

执行 transact-sql 语句或批处理时发生了异常。 (microsoft.sqlserver.connectioninfo)

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

only one log reader agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. if you executed a log-related procedure, drop the connection with session id 75 over which the procedure was executed or execute sp_replflush over that connection before starting the log reader agent or executing another log-related procedure.
only one log reader agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. if you executed a log-related procedure, drop the connection with session id 75 over which the procedure was executed or execute sp_replflush over that connection before starting the log reader agent or executing another log-related procedure.
only one log reader agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. if you executed a log-related procedure, drop the connection with session id 75 over which the procedure was executed or execute sp_replflush over that connection before starting the log reader agent or executing another log-related procedure.
only one log reader agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. if you executed a log-related procedure, drop the connection with session id 75 over which the procedure was executed or execute sp_replflush over that connection before starting the log reader agent or executing another log-related procedure.
only one log reader agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. if you executed a log-related procedure, drop the connection with session id 75 over which the procedure was executed or execute sp_replflush over that connection before starting the log reader agent or executing another log-related procedure.
在执行 'sp_droppublication' 的过程中出错。调用 'sp_replcmds' 失败,错误代码: '18752',返回代码: '1'。
已将数据库上下文更改为 "itsms"。 (microsoft sql server, error: 18752)

for help, click: http://go.microsoft.com/fwlink?prodname=microsoft%20sql%20server&prodver=15.00.4312&evtsrc=mssqlserver&evtid=18752&linkid=20476

好久没有维护sql server数据库了,感觉生疏了很多,检查后发现其实出现这个错误,是因为一次只能有一个日志读取器代理或日志相关过程(sp_repldone、sp_replcmds 和 sp_replshowcmds)连接到某个数据库。 如果执行了一个日志相关过程,那么在启动日志读取器代理或者执行另一个日志相关过程之前,请删除执行第一个过程时所用的连接,或者在该连接上执行 sp_replflush。

其实,官方文档[1]关于错误代码18752有详细的说明,只要详细阅读文档,就能知道如何解决这个错误了。这里特此记录一下。具体如下所示:

说明

有多个当前连接正在尝试执行以下任一日志相关过程: sp_repldone、 sp_replcmds或 sp_replshowcmds。 sp_repldone (transact-sql) 和 sp_replcmds (transact-sql) 存储过程是日志读取器代理用于查找和更新已发布数据库中复制事务的相关信息的存储过程。 sp_replshowcmds (transact-sql) 存储过程用于排查某些类型的事务复制问题。

在以下情形下将引发此错误:

  • 如果某个已发布数据库的日志读取器代理正在运行,而另一个日志读取器代理试图在同一个数据库上运行,则对第二个代理引发此错误,并且此错误将出现在代理历史记录中。

  • 有时看起来像是有多个代理,则可能其中一个代理是执行孤立进程的结果。

  • 如果启动了已发布数据库的日志读取器代理,而用户在同一个数据库上执行 sp_repldone、 sp_replcmds或 sp_replshowcmds ,则在执行存储过程的应用程序(如 sqlcmd)中将引发此错误。

  • 如果已发布数据库的日志读取器代理不在运行状态,而用户在执行 sp_repldone、 sp_replcmds或 sp_replshowcmds 后没有关闭用于执行此过程的连接,则当日志读取器代理尝试连接到数据库时将引发此错误。

用户操作

以下步骤可以帮助您解决这个问题。 如果任何一个步骤能正确启动日志读取器代理,则没有必要完成剩余的步骤。

  • 检查日志读取器代理的历史记录,查找可能导致此错误的其他任何错误。 有关在复制监视器中查看代理状态和错误详细资料的信息,请参阅使用复制监视器查看信息和执行任务。

  • 检查 sp_who (transact-sql) 的输出,了解连接到已发布数据库的特定进程标识号 (spid) 。 关闭所有可能运行 sp_repldone、 sp_replcmds或 sp_replshowcmds的连接。

  • 重新启动日志读取器代理。 有关详细信息,请参阅启动和停止复制代理 (sql server management studio).

  • 在分发服务器上重新启动 sql server 代理服务(使之在群集中脱机或联机)。 如果计划的作业有可能在任何其他 实例中执行了sp_repldone 、 sp_replcmds 或 sp_replshowcmds sql server ,则也要为那些实例重新启动 sql server 代理。 有关详细信息,请参阅启动、停止或暂停 sql server 代理服务。

  • sp_replflush (发布服务器上对发布数据库执行 transact-sql) ,然后重启日志读取器代理。

  • 如果错误继续出现,请增加代理的日志记录并指定日志的输出文件。 此操作可能会提供找到该错误和/或其他错误消息的步骤,具体取决于错误的上下文。

其实这里的解决方法也很简单,就是执行命令sp_replflush后,就可以正常的删除复制的发布了。

参考资料

[1]

1: https://learn.microsoft.com/zh-cn/sql/relational-databases/replication/mssql-eng018752?view=sql-server-ver16

到此这篇关于sql server复制删除发布时遇到错误18752的文章就介绍到这了,更多相关sql server错误18752内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com