Question

I'm trying to set up database mirroring in SQL Server 2008R2. I've taken a full backup and a transactional backup from my principal database and I've restored both WITH NORECOVERY.

However, my mirror database is now stuck in RECOVERING mode and when I hit "start mirroring" on my principal, it says it can't connect.

What am I doing wrong?

Edit: I should probably state that my database is rather large (the mdf file is about 4.8GB) so that could be why.

Edit2: I've also tried doing this with both firewalls turned off so I know it's not a firewall issue.

Edit3: I've run the SQL that Mark suggested. The principal results are here: http://piersonthe.net/principal.xls and mirror are here: http://piersonthe.net/mirror.xls

It's worth noting that I got the following error when I ran the query on the mirror: Msg 927, Level 14, State 2, Line 1 Database 'RHSCMSSites' cannot be opened. It is in the middle of a restore.

Was it helpful?

Solution

After all that one of the servers didn't have the SQL Server service running under the same user. I'm an idiot.

OTHER TIPS

Recovering is the correct state for the database to be in at the stage you've got to.

First, script the endpoints on both the mirror and principle and check that the ports are those you expect and that you can telnet to both ports from both servers. Double check that the endpoint state is 'Started'.

Second, if the endpoints are as expected and you've confirmed connectivity is ok, try initiating the mirror from TSQL. The sequence (after database and log restore) should be:

-- On MIRROR
ALTER DATABASE MyDatabase
    SET PARTNER = 'TCP://PrincipalServerX.MyCompany.com:5022’
GO

ALTER DATABASE MyDatabase
    SET PARTNER SAFETY OFF
GO

-- On PRINCIPAL
ALTER DATABASE MyDatabase
    SET PARTNER = 'TCP://MirrorServerX.MyCompany.com:5023’
GO

ALTER DATABASE MyDatabase
    SET PARTNER SAFETY OFF
GO

Edit: Steps above not helping, next up...

Can you run the following script on both servers and post the output:

SELECT
    e.name
  , e.endpoint_id
  , e.principal_id
  , e.protocol
  , e.protocol_desc
  , ec.local_net_address
  , ec.local_tcp_port
  , e.[type]
  , e.type_desc
  , e.[state]
  , e.state_desc
  , e.is_admin_endpoint
FROM
    sys.endpoints e
LEFT OUTER JOIN 
    sys.dm_exec_connections ec
ON  ec.endpoint_id = e.endpoint_id
GROUP BY
    e.name
  , e.endpoint_id
  , e.principal_id
  , e.protocol
  , e.protocol_desc
  , ec.local_net_address
  , ec.local_tcp_port
  , e.[type]
  , e.type_desc
  , e.[state]
  , e.state_desc
  , e.is_admin_endpoint

You shouldn't restore it with recovery, that leaves an active db. To apply transaction logs you need to use with norecovery (restoring) or with standby (read only).

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top