SQL Server 2008 镜像1418错误处理
阅读原文时间:2021年04月20日阅读:1

基本上做过SQL Server 2008镜像的人都遇到过以下这两种错误信息提示:
1.一个或多个服务器网络地址缺少完全限定域名(FQDN)。为每个服务器指定FQDN,然后再次单击“开始镜像”。
2.服务器网络地址"TCP://primary.test.com:5022"无法访问或不存在。请检查网络地址名称,并检查本地和远程端点的端口是否正常运行。(Microsoft SQL Server,错误:1418)
下面总结下自己处理这两个问题的方法,希望对和我一样遇到这些问题的兄弟姐妹们有所帮助
1. 关于第一个问题,解决方法很简单,提示此错误,意思是说你不在同一个网域,只是一个WORKGROUP,通常在同一个 网域不会有此错误出现,但SQL Server 2008镜像设置,并不一定需要在同一个网域中,只要修改电脑的DNS尾码即可,修改方式如下:
右键点击【计算机】选择属性,选择计算机名称tab,点击【其他】按钮,将DNS尾码设置成相同的值,如test.com,电脑名称若为primary,则完整的电脑名称就为primary.test.com, 将镜像server的DNS尾码设置成相同值
2.(Microsoft SQL Server,错误:1418)这个错误一定折磨了不少人,在遇到此问题时在网络上查找过很多,但都找到可用的解决方案,最后多亏一个懂MIS管理的同仁帮忙,错误原因及解决方式如下:

原因1.可能是TCP协议无法以电脑名称确定计算机的位置,不能找到对应的IP

解决方式:

修改系统盘下WINDOWS/system32/drivers/etc下面的文件hosts,在该文件下加入主体及镜像地址的IP及对应的电脑名称,格式如下:

127.0.0.1 localhost

192.168.1.100 primary.test.com

192.168.1.101 mirror.test.com

注意,在两台server上都要加,如果还有见证server,见证server上也要加入

原因2.如果按照上述方式还出现1418错误的话就可能是镜像server上恢复数据库时没有做交易记录(Transaction Log)的还原导致的,且还原时必须勾选WITH NORECOVERY选项。

解决方法:

step1 在主体server上做数据库的完整备份及交易记录备份
step2 将备份拷贝到镜像server上
step3 登镜像server的数据库,先用完整备份进行还原,再进行交易记录的还原,记住都要勾选WITH NORECOVERY,或用以下命令:
restore from disk='`````.bak' with norecofery
restore from disk='````_log.bak' with norecovery

SQL 2005 Mirroring Witness Connection Does Not Estalbish on one node

Symptom

When you've added an Witness Server to the mix, and you start to get the following error message in the Application Log. You are running all of the service under a specific domain user and everything runs but this. The Database Mirroring Monitor shows that Witness Connection is OFF (red X) on only one server.

Event Type: Information
Event Source: MSSQL$XYZ
Event Category: (4)
Event ID: 28048
Date: 11/27/2007
Time: 6:13:38 PM
User: N/A
Computer: SQLServer2
Description:

Database Mirroring login attempt by user 'mydomain\sqlservice.' failed with error: 'Connection handshake failed. The login 'mydomain\sqlservice' does not have CONNECT permission on the endpoint. State 84.'. [CLIENT: 10.1.2.3]

Cause

Root cause is really unknown. Probably a bad sequence of installing and configuring database mirroring. But the immediate cause that can be fixed is that the computer node which you have seen the event log is not granting the Connect permission on the Mirroring endpoint object in the securables for the log in account mentioned.

Fix

This is an issue of the Witness Server unable to establish a connection to the Principal or Mirror Server (whichever is broken). I was able to fix this by;

  1. Start the Microsoft SQL Server Management Studio
  2. Connect to the database server that has an issue.
  3. Go to the Security folder
  4. Add the login name that is indicated in the Event Log. In my example MYDOMAIN\sqlservice
  5. Select the account you've just added and open its property (i.e., right click it)
  6. Select Securables
  7. Press Add…
  8. Select (leave it selected as) Specific Objects…
  9. Perss OK
  10. Under Select Objects dialog box press Object Types…
  11. Check Endpoints
  12. Press Browse…
  13. Add [Mirroring] object.
  14. Once back in the main property window, check mark Grant

That has fixed it!

DECLARE @I INT SET @I=1
WHILE @I<3
BEGIN
  BACKUP LOG db TO DISK = N'F:\tr.bak'
  DBCC SHRINKFILE('logic_Log', 40960)
  SET @I=@I+1
END