1. 错误: 已将此(这些)订阅标记为不活动,必须将其重新初始化。需要删除NoSync 订阅,然后重新创建它们 use distribution go -- 查找状态不正常的发布 select status, * from dbo.MSsubscriptions where status 2 -- 修改状态 update dbo.MSsubscriptions s
1. 错误:已将此(这些)订阅标记为不活动,必须将其重新初始化。需要删除NoSync 订阅,然后重新创建它们
use distribution
go
--查找状态不正常的发布
select status,*from dbo.MSsubscriptions where status2
--修改状态
update dbo.MSsubscriptions set status=2where status2
观察复制链是否能正常运行,正常后用tablediff比较发布链中的表数据是否一致
还可以重新初始化快照,但是数据量大就是个悲剧。
2. 错误:表、存储过程不存在以及表结构不一致等
处理方法:
a. 表或存储过程不存在:
在订阅端对应的库中补齐缺失的对象;
有一种比较奇怪的现象是订阅端表明明存在,但是同步链依然报错,此时可能有两种情况:
第一: 表字段不一致,可以参照下面(b)的方式补齐表字段;
第二: 表字段也一致,但是依旧报错,可以采取三种方式解决:
a. 暂停同步链,然后再次开启,看是否能通过,如果不行,进行下面的步骤;
b. 勾选掉同步链中报错的这个表,然后观察同步链,此时去掉了这个表的发布,错误一般都能过去,
等到所有数据同步后,再将这个表勾选上,一般都能过;同步链正常后,在用TableDiff工具比较下
这个表的数据;
c. 如果b步骤依然报错,那就只能重建了。
b. 列名'xxx' 无效
可以通过以下语句查找缺失的字段对应的表
--查找某个发布链中的某个字段(Rp_XXXX 发布名xxx 字段名)
select a.name as table_name,b.name as column_name,(select'alter table '+a.name+' add '+b.name+''+
(casewhen name='nvarchar'thencast(b.max_length/2ASvarchar)
when name like'date%'or name='money'then''
else name end )
from sys.types where system_type_id=b.system_type_id ) as definition FROM dbo.sysarticles a WITH(NOLOCK) innerjoin sys.columns b WITH(NOLOCK)
on a.objid=b.object_idinnerjoin dbo.syspublications c with(nolock) on a.pubid=c.pubid
where c.name='Rp_XXXX'and b.name='xxx'
3. 错误:.主键冲突
处理方法:跳过错误
错误完成后,需要比较两边数据是否一致(比下数据量就行了)
---------------跳过订阅机器上面的错误------------------------
-----------------------在分发机器上--------------------------
--语法
sp_helpsubscriptionerrors [ @publisher = ]'publisher'
, [ @publisher_db = ]'publisher_db'
, [ @publication = ]'publication'
, [ @subscriber = ]'subscriber'
, [ @subscriber_db = ]'subscriber_db'
--get publisher subscriber
select*from MSsubscriber_info
--get publisher_db publication subscriber_db=publisher_db
select*from MSpublications
--example
sp_helpsubscriptionerrors 'SQLw2k8','dbtranpub','dbtranpub_pub','SQLw2k8Subscriber','dbtransub'
--获取xact_seqno 值
----------------------在订阅机器上---------------------------
sp_setsubscriptionxactseqno [ @publisher= ]'publisher',
[ @publisher_db= ]'publisher_db',
[ @publication= ]'publication',
[ @xact_seqno= ] xact_seqno
--example
sp_helpsubscriptionerrors 'SQLw2k8','dbtranpub','dbtranpub_pub',xact_seqno
-------------------------------------------------------------------------------------
4. 错误:应用复制的命令时在订阅服务器上找不到该行
a. 可以采用“主键冲突”错误的处理方式,跳过错误,然后再用tablediff比较两个表的数据差;
b. 在订阅端补充缺失的数据
--使用如下语句找出错误号
selecttop100 e.xact_seqno ,e.command_id,e.*
from dbo.MSdistribution_history h
join dbo.MSrepl_errors e on h.error_id=e.id
where comments notlike'%transaction%'--失败的代理
orderby id desc
--用上面查到的具体事务序列号,查看复制组件执行的具体命令
--在分发数据库上执行:sp_browsereplcmds,注意必须限定开始和结束xact_seqno
sp_browsereplcmds '0x0000003B00000020000500000000','0x0000003B00000020000500000000'
--结果如下
article_id command
1 {CALL [dbo].[sp_MSdel_dboUPCCodeTransaction] ('000000002 ')}
--找到对应的对象
select publisher_db,article From dbo.MSarticles where article_id=1and publication_id=(
select publication_id from MSpublications with(nolock) where publication='Rp_xxx')
--由sp_MSdel 可以知道,这条命令是一个删除语句,因为发布端的数据已经不存在,所以只能跳过;
--如果是修改,需要验证上述数据在故障订阅服务器上是否存在,如果不存在,则补上。
5. 错误:用户'xxx' 登录失败或者The process could not connect to Subscriber 'xxxx'.
处理方法: 检查账号是否正确,能够登录到发布和订阅服务器,而且有相应的权限。
6. 发布'xxx' 的初始快照尚不可用
保证SQLSERVERAGENT已经运行,复制=》发布内容=》发布项目=》右击右侧的订阅=》重新初始化
如果还不行,复制监视器--发布服务器--xxx--发布的项目--快照,看到进程未能创建文件“\\XXZ\SQLPUB\unc”,
到该文件夹重新配置sql的帐号对该文件夹权限为"完全"。
7. 进程未能从表“[dbo].[syncobj_0x3745373834413345]”向外大容量复制
在写BCP 数据文件时发生I/O 错误(源: ODBC SQL Server Driver (ODBC); 错误代码: 0)
解决方法:就是字符类型全部改为n类型的解决问题(char-nchar,varchar-nvarchar,ntext).
8. 错误消息:
"代理'xxxx' 在出错后正在重试。已重试了25 次。有关详细信息,请参阅Jobs 文件夹中的代理作业历史记录。”
发生这个错误一般都是在一台机器上面有比较多的发布链,错误原因在于数据库对Replication使用内存的限制,
我们需要更改这个限制来解决这个问题(最好是不要再一台机器上创建太多的发布链),方法如下:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems\
点开Windows项,找到下面这些内容
%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows Shareddiv=1024,20480,768
将最后的数字(不一定是这个数字,可能是等)改成1024 保存,重启即可。
Windows2008 server 如果不是amdin用户可能会不让打开注册表,如果是管理组权限的话,可以到
C:\windows\system32 下面找到regedit32.exe 文件,右键,然后将自己的账号添加到运行权限里面。
9.--Cannot drop the database XXX because it is being used for replication
exec sp_removedbreplication 'database'

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools
