摘要: SQL Server database mirroring with local user account(no domain name).
Instructions for use :
This chapter describes how to use the "machine account" (or no Domain Name Environment) to set the SQL Server mirroring
(Note: SQL Server mirroring setting There are three main ways:
1. In the environment can have a Domain Name through domains account to set
2. Domain Name without environment may account for each computer to set the machine
3. manner through credentials)
Environment Description:
The firstcharacter role: Principal Server
Computer Name: PC1
database name: TestDB
machine account: PC1admin1
database: SQL Server 2014 Developer Edition
operating system: Windows 7 Service Pack 1
a second
role role: Mirroring Server
Computer Name: PC2
Native account: PC2admin1
database: SQL Server 2014 Developer Edition
operating system: Windows 7 Service Pack 1
(Note: Principal and Mirroring to use the same version of SQL Server)
a third
character role: Witness Server
computer name: PC3
machine account: PC3admin1
database : SQL Server 2014 Express Edition
operating system: Windows 7 Service Pack 1
If there is a firewall remember to turn on SQL Server TCP Port (default: 1433) and mirroring endpoint Port (default: 5022)
Setting help:
PC1 will TestDB set of database mirroring.
Step 1-1.
The PC1, PC2 of the "SQL Server Services" and "SQL Server Agent service" login identities instead of machine account admin1 , as shown below:
Step 1-2.
PC3's "SQL Server Services" changed login identity machine account admin1 , as shown below:
Step 2.
The PC1 database TestDB do a full backup and a transaction record of the backup after the PC2 do a backup restore operation ,
when PC2 do to restore "full backup", please remember to restore to the "Options" page, select RESTORE WITH NORECOVERY do restore items ,As shown below:
PC2 do " transaction records" restore, please also remember to revert to the "Options" page, select RESTORE WITH NORECOVERY do restore items, as shown below:
If done successfully reducing action, "TestBD" database state PC2 would be " Restoring ... ", as shown below:
Step 3.
对 PC1、PC2、PC3 加入登入身份,分别是自己的本机账号 admin1(如:PC1要加入 PC1admin1,PC2要加入 PC2admin1,PC3要加入 PC3admin1),
如果SQL Server 已经有加入自己的本机账号 admin1,Step 3.就可以忽略不用重复做了,如下图:
Step 4.
在 PC1 做镜像设定动作,如下图(step by step):
由于在 No Domain Name 环境下,所以下图的服务账户无作用,因此皆留空白(在后面会透过手动方式对"端点"加入本机账号 admin1连入的权限)
按下"完成"按钮,即会跳到下图,这时候按下"不要启动镜像"按钮(因为后面步骤我们要手动对"端点"加入 本机账号admin1 连入的权限,所以等加入账号连入权限后再来操作此画面)
按下"不要启动镜像"按钮,即会跳到下图,这时候先不要按下任何按钮,先保留此画面(后面Step 6 会用到)
Step 5.
我们要手动对 "Mirror"端点 加入 本机账号admin1 可以连入的权限,
因此对 PC1 执行下面的 SQL命令
USE [master]
GRANT CONNECT ON ENDPOINT::[Mirror] TO [PC1admin1]
对 PC2 执行下面的 SQL命令
USE [master]
GRANT CONNECT ON ENDPOINT::[Mirror] TO [PC2admin1]
对 PC3 执行下面的 SQL命令
USE [master]
GRANT CONNECT ON ENDPOINT::[Mirror] TO [PC3admin1]
如下图:
Step 6.
就下来准备启动镜像,这时候我先回到 Step4 最后所停留的画面,如下图,按下 "启动镜像" 按钮
如果出现提示 "缺少完整域名(FQDN)" 时,请下按"是"按钮
启动成功后,PC1 的 TestDB 数据库状态为"主体,已同步处理",PC2 的 TestDB 数据库状态为"镜像,已同步处理/正在还原...",如下图
注:如果发生 1418 错误时,请重新检查 Step1 或 Step5 有没有遗漏做的动作,或是 Port 1433、5022 被防火墙挡住。
主要参考:
SQL Server - 如何建立 Database Mirroring
[Windows][SQL]架设 DB Mirroring 的环境在 Windows 2012 ( 1/2 )
[Windows][SQL]架设 DB Mirroring 的环境在 Windows 2012 ( 2/2 )
[SQL]在 Workgroup 环境下设定 SQL Server 数据库镜像 ( Database Mirroring )
SQL Server 2008R2 Mirroring with No Domain (SQL 镜像)
mirror:error-1418
※在此感谢所有的帮助者,感谢~
原文:大专栏 [MSSQL]利用 本机账号(No Domain Name 环境) 设定 SQL Server 镜像(Database Mirroring)