Creating a mirror for your Citrix database

This blog will show you how to setup a Microsoft SQL mirror for a Citrix database. To provide high availability in a Citrix environment Citrix supports several options which can be found in the edocs.
This blog is a guide to setup a mirror and is pure technical, so if you wonder what options there are read the eDocs, if you are wondering how to setup the mirror read further.


When you decided to create a mirror you still have to think about whether you want the fail-over to be automatic or not. If you want an automatic fail-over you need to integrate a Witness server, so next to the principal and the mirror a third server is added.

SQL server Preparation

Before you start clicking away you have to make sure you have the following preparations in place. Preparation steps involved are:
  • Disk and data directories
  • Service account
Make sure all three servers have the same disk and directory structure. for my servers the following configuration was used;
  • Data –  D:Data
  • Log – E:Log
  • Backup – D:Backup
The next preparation you need to take care of is the services account. Make sure the service accounts run with the same accounts, in my environment I used the domain service accounts.
The services affected are MSSQLSERVER and SQLSERVERAGENT. Make sure that these are correct on all three servers.
Make sure that the service accounts for the databases, the accounts that will manage the databases are available on each SQL server.
The last step in the SQL preparation is to make sure the database is on FULL recovery.

Mirror preparation

After we prepared the SQL server we need to prepare the database so that it’s ready to be mirrored. Preparation steps are:
  • Backup of database
  • Backup of transaction log
  • Restore of database on mirror
  • Restore of transaction log on mirror

We’re now on the principal server!

So let’s start with a backup, it’s a step by step guide so you can run through this if you know your SQL.

For this blog I used a new database for the Citrix database was mirrored already and I saw no reason to break that.

 From The database via TASK you select BACK-UP. You are taken to the next screen, Make sure you select FULL backup type here and start the backup, it will take mere seconds to complete.

Next step is to backup the transaction log of this database. Make sure you change the Backup type and the file name for this backup so that you don’t overwrite you previous backup.
After you’re done, copy the files to the mirror server and connect to that server via RDP.

We’re now on the mirror server!

So we’ve created the backup, now we will restore this database+transaction log on the mirror server. From the SQL console select TASK and go to RESTORE DATABASE.
Click on DEVICE and browse for the files you just copied to this server.

Click on the Options and change the recovery state to RESTORE WITH NORECOVERY.

After the restore is finished you get the message.

Next step is to restore the transaction log, so right click the database and navigate via TASK / RESTORE to Transaction Log.

Select From file or tape and browse for the transaction log backup file.

Click on the options and set the recovery state to “Leave… NORECOVERY”

 After the restore you get the message that it was successful, don’t worry about the restore message behind the database, it will stay there.

Oke, so now we have a database on both the principal and mirror server, the service accounts are available on all servers and we’re ready to go. Let’s build a mirror.

Mirror setup

To setup the mirror right click the database and navigate via TASK to Mirror.
You will see the following screen, your principal server is listed there and the rest is still empty. Click on CONFIGURE SECURITY to start the configuration.

A new wizard will start, this will configure the mirror configuration.

 Click on Next to start.

We want to use the Witness server so click on YES and then next.

Make sure you have all server marked.

First server is our principal server, check the server names before you continue or connect.
The Endpoint name is by default MIRRORING but can be changed, because here we only want to mirror the Citrix database I named it CitrixXenApp.

The second server is the mirror server, so make sure the mirror server is listed and click on connect.

You are prompted to log on to the server again make sure the mirror server is selected. Once the connection is successful the wizard continues.

The witness server is the last one, make sure the correct server is listed. Here I used a SQL Express version for the Witness so that was easy to remember.

 Again a pop-up and again a log on to the server.
The last screen of configuration is the screen with the service accounts, you have to define which service accounts you are using on each server. I used the same one on each server, it was a domain user account.

After you configured all that a nice overview is presented to show you what will happen next. So when you click finish the servers will be contacted and the mirror configuration will be configured.

If all goes well you will have all green marks. Click close to return to the first configuration screen.

Now it’s gets real, you are prompted to start the mirroring. So click on START MIRRORING to actually star the mirror.

It will take a few moments but when you configured all well, the mirror starts. You notice the pause button and the remove mirror button, that’s is a good indication of a successful mirror.

If you want to check if the mirror is running fine you can start the mirroring monitor. Browse to TASK and start LAUNCH DATABASE MIRRORING MONITOR

The mirroring monitor is started and you can see if the synchronization is working.

If you configured the database authentication wrong one of the servers might report to have an error. Click on ACTION and MANAGE SERVER INSTANCE CONNECTIONS to set the service accounts.

After fixing this all should be fine.
Hope this blog helps you setting up a database mirror. It’s not my daily task, not my task at all so I thought it might be helpful for you also.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.