Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 4.73 KB

management-of-logins-and-jobs-after-role-switching-sql-server.md

File metadata and controls

43 lines (32 loc) · 4.73 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Manage logins & jobs after mirror failover
Learn how to manage logins & jobs after failing over your mirrored database from the primary to the secondary database.
MashaMSFT
mathoma
03/14/2017
sql
high-availability
how-to
role switching [SQL Server]

Management of Logins and Jobs After Role Switching (SQL Server)

[!INCLUDE SQL Server] When deploying a high-availability or disaster-recovery solution for a [!INCLUDEssNoVersion] database, it is important to reproduce relevant information that is stored for the database in the master or msdb databases. Typically, the relevant information includes the jobs of the primary/principal database and the logins of users or processes that need to connect to the database. You should duplicate this information on any instance of [!INCLUDEssNoVersion] that hosts a secondary/mirror database. If possible after roles are switched, it is best to programmatically reproduce the information on the new primary/principal database.

Logins

On every server instances that hosts a copy of the database, you should reproduce the logins that have permission to access the principal database. When the primary/principal role switches, only users whose logins exist on the new primary/principal server instance can access the new primary/principal database. Users whose logins are not defined on the new primary/principal server instance are orphaned and cannot access the database.

If a user is orphaned, create the login on the new primary/principal server instance and run sp_change_users_login. For more information, see Troubleshoot Orphaned Users (SQL Server).

Logins Of Applications That Use SQL Server Authentication or a Local Windows Login

If an application uses SQL Server Authentication or a local Windows login, mismatched SIDs can prevent the application's login from resolving on a remote instance of [!INCLUDEssNoVersion]. The mismatched SIDs cause the login to become an orphaned user on the remote server instance. This issue can occur when an application connects to a mirrored or log shipping database after a failover or to a replication subscriber database that was initialized from a backup.

To prevent this issue, we recommend that you take preventative measures when you set up such an application to use a database that is hosted by a remote instance of [!INCLUDEssNoVersion]. Prevention involves transferring the logins and the passwords from the local instance of [!INCLUDEssNoVersion] to the remote instance of [!INCLUDEssNoVersion]. For more information about how to prevent this issue, see KB article 918992 -How to transfer logins and passwords between instances of SQL Server).

Note

This problem affects Windows local accounts on different computers. However, this problem does not occur for domain accounts because the SID is the same on each of the computers.

For more information, see Orphaned Users with Database Mirroring and Log Shipping (a Database Engine blog).

Jobs

Jobs, such as backup jobs, require special consideration. Typically, after a role switch, the database owner or system administrator must re-create the jobs for the new primary/principal database.

When the former primary/principal server instance is available, you should delete the original jobs on that instanceof [!INCLUDEssNoVersion]. Note that jobs on the current mirror database fail because it is in the RESTORING state, making it unavailable.

Note

Different instances of [!INCLUDEssNoVersion] might be configured differently, with different drive letters or such. The jobs for each partner must allow for any such differences.

See Also

Manage Metadata When Making a Database Available on Another Server Instance (SQL Server)
Troubleshoot Orphaned Users (SQL Server)