I’m looking at you through the glass…mirror failover

Happy Holidays to the Kingdom! I know many will be going on vacation so I wanted to do an easy post that wouldn’t break anyone’s brain. Also, I am having problems with my brain and have been having tests done so mirroring just seemed to fit today. When it first appeared, I didn’t see much use for it, but now that I use it often, I love it. So Fail over that magic mirror. This script assumes the default configuration port of 5022.

You can check your endpoints this way:

select @@SERVERNAME, * from sys.endpoints
go

Here is how you would create an endpoint if it didn’t already exist.

select @@SERVERNAME, * from sys.endpoints
go
CREATE ENDPOINT Mirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5022)
FOR DATABASE_MIRRORING (ROLE=PARTNER)
go

This is how you would fail over or fail back to a database.

:connect
ALTER DATABASE SET PARTNER FAILOVER

Finally, if you want to bring a previously mirrored database online this is super simple.

Restore Database With Recovery;

Love your magic mirror and it will love you too! Happy Holidays to all!

About andreaallred

SQL Server and helping people is my passion. If I can make someone laugh, I know I have made a difference.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s