16

I am trying to mirroring a database in sql server. I created a database and took a backup of it and restored on the another server. But after doing all operations and click on start mirroring, then it showing following error. I put "NO" to Witness server optionenter image description here.

I followed mirroring steps in this link Here it says, create an user on both principal and mirror server with the same credentials in STEP 3. Is it necessary to create same user on both servers? or any alternate solution is there?

1
  • I think the above problem was caused due to port numbers.because the same port numbers given to instance1 and instance2.The default port numbers for principle server is 5022,Mirror is 5023 and witness is 5024.so once check the port numbers.
    – sandy
    Dec 27, 2016 at 8:38

10 Answers 10

22

I also faced same problem. you need to check the following items once.

  1. Goto services.msc and check the sql server is running under which account. Make sure that sql server and sql server agent services should run with same credentials.

  2. in the mirror database server you should do the same step as step 1. Give the same credentials as in principal server. If that user is not present create a new one on the both servers with same credentials.

  3. Now got principal server and in sql server add the new login under Security-->Login. Give the server roles as Sysadmin and public. Add the same user on the mirror server also.

  4. Now do the mirror in the principal database. You did not get any error there.

3
  • You say "Make sure that sql server and sql server agent services should run with same credentials" on both the Principle and Mirror. I am not running in a Windows Active Directory Domain. My services have to run under local user accounts. Is your answer assuming that the users are Active Directory users?
    – Dave
    Mar 18, 2014 at 16:03
  • Thanks, running SQL server under domain account has fixed it for me. Are there any down sides instead of local account? Aug 7, 2014 at 9:47
  • by saying same credentials, is it needed to have the same password for the users? I tried and didnt succeed replicating. pricipal server users domain account and mirror uses local admin with the same name but probably different password. should that normally work? May 28, 2015 at 13:20
3

Same problem , error 1418. Did everything suggested here: link

In hindsight it was obvious. When completing the MIRRORING > CONFIGURE SECURITY WIZARD you get a page explaining the results. Looking at SQL1 and SQL2 nodes this line was the key:

On the principal server instance, SQL1
Listener Port: 5022
Encryption: **Yes**


On the mirror server instance, SQL2
Listener Port: 5022
Encryption: **No**

Solution. After finishing the wizard on all SQL nodes execute:

drop endpoint Mirroring
go


CREATE ENDPOINT Mirroring
STATE = STARTED
AS TCP ( LISTENER_PORT = 5022 )
FOR DATABASE_MIRRORING 
(ENCRYPTION = DISABLED,ROLE=ALL)
GO

Hit start mirroring, problem solved.

Hope that helps someone Scott

2

After exhausting all the options as mentioned above, I had a variation to the mirroring environment. We had a SQL server 2008 contributing to 2014 Server in Principal-Mirror configuration. The 2014 Sql server was also being used in AlwaysOn config for HA of some other Db's. The end points are now named differently on sql 2008 and sql 2014.

After getting the above mentioned error, I found that the Encryption for 2008 is RC4 and that for 2014 is AES. As a result, it was failing handshake with the SQL2014 endpoint. I changed the encryption to match that of the SQL 2008 using the below command and viola!!

ALTER ENDPOINT [Hadr_endpoint]
    FOR DATA_MIRRORING ( ENCRYPTION  = REQUIRED ALGORITHM RC4 )
1

You also may not be leaving the copy intended for mirroring in a restore state, which it must be left in to turn on mirroring.

Typically, the procedure for SQL Server mirroring is:

1) Backup the original database and copy it to the server intended for mirroring.

2) Backup the transaction log and copy it to the server intended for mirroring.

3) Chose restore database from the MMC and locate the backup of the database and restore it with options set to leave in non-functioning state with no rollback of transactions.

4) Chose restore and chose files and then select log files and restore the log file backup also with the option of no rolloback and non-functioning. It is the second radio button down under the options page on sql server 2008.

5) go to the original database copy server and turn on mirroring. You will need to use an account that has sysadmin rights on both servers for the mirroring conversations to start up.

0

I met this issue before, all the validation pass. Use a new endpoint at last, it works. The root cause is 5022 may block other session.

0

For me, I had this issue crop up and resolved it ultimately by dropping and recreating the mirroring endpoints (SSMS -> Server Objects -> Endpoints -> Database Mirroring)

0

My error 1418 was resolved by using the same drives letter on both servers...

Although MS suggests that you can use different letters, I decided to use the same drives letter...

From MS:

Also, we recommend that, if it is possible, the file path (including the drive letter) of the mirror database be identical to the path of the principal database. If the file paths must differ, for example, if the principal database is on drive 'F:' but the mirror system lacks an F: drive, you must include the MOVE option in the RESTORE statement.

0

In case none of the above worked, here is what caused my problem. Run the following query on both servers and look closely

SELECT @@Version

I had some updates on my principal server that were not installed on my mirror server.

Also, you can see additional info in SQL Server Log to reasons why the mirroring doesn't work. That's how I realized I had a different version on both servers.

0

On SQL Server 2016, the solution is to have your [domain account] as sysadmin on both principal and mirror server. Then create a new account as of the following

Principal server

use [master]
GO
CREATE LOGIN [domain\mirrorservername$] FROM WINDOWS
GO
GRANT CONNECT ON ENDPOINT::[Mirroring] TO [domain\mirrorservername$]
GO

Mirror Server

use [master]
GO
CREATE LOGIN [domain\principalservername$] FROM WINDOWS
GO
GRANT CONNECT ON ENDPOINT::[Mirroring] TO [domain\principalservername$]
GO

You need to create those account and grant CONNECT permission as those accounts are the ones used during the handshake between principal and mirror server.

For more details on the error, check your sql error logs.

Hope this post helps someone.

0

I had the same issue. I was trying to setup mirroring on Windows 2008 - R2, on a Domain setup. As suggested above by one of the experts, I checked the SQL Server 'logon' accounts for the SQLSERVER and SQLSERVERAGENT and used the same Domain account for the the SQL Server services on both machines. I was able to setup the mirroring.

Thanks for the help!

Not the answer you're looking for? Browse other questions tagged or ask your own question.