Tuesday, May 20, 2008

Sql Server Mirroring

I have just finished DAT327 - Microsoft SQL Server 2005 Always-On Demo Fest from Teched 2007. This was a marathon screencast but very worthwhile.

This was on mirroring, which I as a developer have not been responsible for. However, it was brilliant to see a comprehensive screencast on this.

The primary severs in mirroring are the: principal (primary), mirror (secondary) and witness. The witness is extremely light weight and is used for checking to see if the principal and mirror are available. The good news is the witness can run on any edition of sql server including express (FREE).

The mirror needs to be prepared as a mirroring server. On of the steps is restore the database to the mirror server and must use Recover Completion State = No Recover. No Recover says do not bring this database online, leave it inaccessible to users but able to receive transactions.

Explicit Redirection allows changing the connection string using the following syntax:
;failover partner =

The code will now try to connect to server1 or server2, and run against whichever server is available.

Say server1 is principal, server2 is mirror and server3 is the witness.

If there is a Failover, the connections are broken, transaction are rolled back, and will have to reconnect.

Scenario1: Server1 goes down - The application will work, the principal then would be server2.

Scenario2: Mirror goes down -The application will work, the principal will remain server1. However logs will grow as log file will be needed when server2 becomes available again to ensure server can catchup.

Lots of other good stuff in this screencast.

No comments: