Sei sulla pagina 1di 21

Using SQL Database

Mirroring to Improve
Citrix XenApp Server Farm
Disaster Recovery
Capabilities

www.citrix.com
Summary ........................................................................................................................... 3
Environment....................................................................................................................... 3
SQL Server Configuration .................................................................................................. 3
XenApp Server Configuration .......................................................................................... 14
Verification ....................................................................................................................... 17
Troubleshooting ............................................................................................................... 18
More Information .............................................................................................................. 21

Page 2
Summary
This document describes how to improve the disaster recovery capabilities of a Citrix XenApp farm
by leveraging the high availability database mirroring feature in Microsoft SQL 2005 / 2008 / 2008
R2. This feature allows transparent failover of the data store in the event of the loss of the principal
SQL Server. The data store never physically resides on the witness server at any time, but SQL is
required on that device so it can monitor the other two SQL servers and allow for automatic failover
without losing any transactions (high safety). For the XenApp server to “pick up” the mirror in the
event of a failure, two things are required on the XenApp servers:
1. The SQL Native Client must be installed on every XenApp server.
2. The MF20.DSN file must be modified on every XenApp server to match the
example in this document. The Driver and Failover_Partner parameters are the
only two lines that need modification.

Environment
Citrix XenApp 5.0 / 6.5

o XenApp 6.5 / Windows 2008 R2 Will require updated SQL Native Client 10.0 reference
to MF20.DSN file

Three Microsoft Standard or Enterprise Edition SQL 2005 / 2008 / SQL 2008 R2 Servers with
latest SQL Service Pack (Roles Principal Mirror Witness)

SQL Server Configuration


1. Create the data store database and have at least one XenApp join the server farm.

2. Verify the data store database by selecting Full in the Recovery model drop-down list in the
Options page of the Database Properties. This is the default behavior:

Page 3
3. Verify the SQL Server is using an Active Directory account. Ideally, use the same account for all
three SQL Servers.

4. Back up the database on the principal SQL Server.

5. Create a database to the mirroring server.

Page 4
6. From the Options page under Restore Database, back up the database to the mirroring server
by selecting the Overwrite the existing database.

7. Under Recovery state, select the RESTORE WITH NORECOVERY as shown below:

The following is a sample script, but you can use the wizard in SQL Server Management Studio (right-
click database tasks > backup):
RESTORE DATABASE [CPS4Farm] FROM DISK = N'C:\CPS4Farm.bak' WITH FILE = 1,
NORECOVERY, NOUNLOAD, REPLACE, STATS = 10

8. Start the mirroring process. Right-click the Database > Properties > Mirroring and click
Configure Security… to start the wizard.

Page 5
9. On the Configure Database Mirroring Security Wizard screen, click Next.

Page 6
a. On the Include Witness Server screen, select Yes and click Next:

Page 7
b. Select the principal server.

Page 8
c. Select the mirroring server (click Connect… ).

Page 9
d. Select the witness (click Connect…).

Page 10
10. Enter the SQL Server service accounts. Note: If all SQL Servers are using the same existing
account, leave everything blank.

Page 11
11. Start the mirroring process by clicking Start Mirroring.

The following screen shot shows the two successfully synchronized databases in the SQL Server
Management Studio:

Page 12
Note: The database on the mirroring server is not available until a failover has occurred. All database
transactions are first committed on the mirror database before the principal database. This might slow
transactions, depending on the network performance.

Page 13
XenApp Server Configuration
1. Citrix recommends that a data store timeout be in place before proceeding. For more information
see Citrix article CTX107708. Adjust this value to accommodate the failure over the transition
period.

2. Stop the IMA Service (use the net stop imaservice command) or in the Services MMC.

3. Install the SQL Native Client from


http://www.microsoft.com/downloads/details.aspx?FamilyId=DF0BA5AA-B4BD-4705-AA0A-
B477BA72A9CB&DisplayLang=en.

4. Edit the Data Source Name (DSN) MF20.DSN located under C:\Program Files
(x86)\Citrix\Independent Management Architecture or C:\Program Files\Citrix\Independent
Management Architecture as follows:
Example DSN:
[ODBC]
DRIVER=SQL Native Client
UID=administrator
Trusted_Connection=Yes
DATABASE=XA DS
WSID=DHARMAEXA02
APP=Citrix IMA
SERVER=DHARMAESQ02
Failover_Partner=DHARMAESQ01

Page 14
Description=ds
XenApp 6.5 Windows 2008 R2 Example DSN
[ODBC]
DRIVER={SQL Server Native Client 10.0}
DATABASE=XA6Database
APP=Citrix IMA
UID=administrator
SERVER=SQLPRINCIPAL
Failover_Partner=SQLMIRRORSERVER
Trusted_Connection=No

5. Start the IMA Service (use the net start imaservice command).

Note: The SQL Client and the DSN modification must be installed on every XenApp server. Only
the Driver and Failover_Partner fields need to be changed. An login account must present on the
SQL mirror server for IMA.

If the SQL Client is not found the Citrix IMA service may fail to connect to the principal database
with the following even log error
Citrix XenApp failed to connect to the Data Store. ODBC error while connecting to the
database: IM002 -> [Microsoft][ODBC Driver Manager] Data source name not found and
no default driver specified

Ensure the Driver = field matches the following registry location

HKLM\Software\ODBC\ODBCINST.INI\SQL Server Client xxxxx

Page 15
Page 16
Verification
Note: During the failover transition there is a short duration of time where the IMA data store is not
available. This is as expected.

1. Initiate a failover on the principal SQL Server either by using the Failover button (go to
Database > Properties > Mirroring > Failover) or stopping SQL itself.

2. Test by issuing the qfarm command at the command prompt at least twice or by using the Citrix
Management Console. Both require the data store to be available.

3. Revert back to the original database by clicking Failover.

Page 17
Troubleshooting

XenApp Server:

1. Verify that the transparent redirection is working using the SQL Profiler. If the DSN is not set up
properly as described above, the failure over feature does not work. The following error message
is received: “SQL Profiler trace running on the previous principal SQL server after failover.” The
following error message shows IMA still trying to connect to the original database: “Error 954 –
The database IMADataStore cannot be opened. It is acting as a mirror database. Login failed for
user 'xxxxxx’.”

2. Verify the SQL connection on the Presentation Server by running netstat –an and verifying the
1433 port connection.

3. Issue the qfarm command at the command prompt of the Presentation Server to verify that it has
a connection to the database. If the connection is dropped you might need to run this twice.
Qfarm needs to connect to the data store to enumerate all the servers in the farm. Make sure no
command line switches are passed for this test.

SQL Server:

1. Verify all SQL Server 2005 servers have Service Pack 1 installed. The build version should be at
least 9.0.2047.

2. You can view use the Database Mirroring monitor to see if there any SQL errors. You can also set
up alerts if a problem does occur.

3. To begin, right-click Database and go to Tasks > Launch Database Mirroring Monitor…

Page 18
4. Highlight the database and click the Warnings tab.

Page 19
5. Click Set Thresholds…

Page 20
More Information

http://msdn.microsoft.com/en-us/library/ms190941.aspx
http://technet.microsoft.com/en-us/library/cc917681.aspx
http://msdn2.microsoft.com/en-us/library/aa337204.aspx
http://msdn2.microsoft.com/en-us/library/ms131373.aspx
https://www.microsoft.com/technet/prodtechnol/sql/2005/mirroringevents.mspx

Page 21

Potrebbero piacerti anche