תאריך<br />סימוכין<br />1<br />Database Mirror for the exceptional DBA<br />דוד יצחק <br />רפא"ל – מערכות לחימה מתקדמות בע...
Rafael Advanced Defense Systems<br />Designs, develops, manufactures and supplies a wide range of high tech defense system...
Speaker Qualifications<br />SQL Server , Oracle , Sybase ,Sybase Anywhere - application & infrastructure DBA .<br />14 yea...
Agenda<br />Database Mirroring Architecture Short Overview<br />Automating Setup using T SQL & SQLCMD or Power shell<br />...
Key Terms-1<br />Principal: <br />Source of the mirroring. <br />Can  mirror one or more databases on a single SQL Server ...
Key Terms- 2<br />Witness <br />Optional  Server that monitor the principal and mirror servers to provide a quorum <br />P...
Key Terms - 3<br />Session <br />Active relationship between the servers involved in DB  mirroring <br />Allows them to ma...
Key Terms - 4<br />Role Switching <br />Active relationship between the servers involved in DB  mirroring <br />Allows the...
Copy-on-Write Technology<br />2. Log record <br />Copied to mirror server  over Network <br />I<br />1. Client <br />trans...
Principle<br />1. Write the data to transaction log and commit the data<br />DB Mirror High Performance<br />2. Send the t...
Principle<br />1. Write the data to transaction log<br />DB Mirror High Safety with Witness<br />2. Send the transaction t...
Database Mirroring Operating Modes: Sync/ Async<br />Synchronous operations<br />Committed transaction is committed on bot...
Database Mirroring Operating Modes: Sync/ Async<br />Asynchronous  operations<br />Transactions commit without waiting for...
Flow to determine the operating Mode for DB<br />
Operating Modes <br />
Database Mirroring Operating Modesin SSMS<br />
Database Mirroring Operating Modes: Sync/ Async<br />Asyns / Sync depends on the transaction safety setting. <br />Control...
Failover variations 1 Automatic failover: high-availability mode<br />Enabled with  a three-server configuration:  princip...
Failover variations 2 Manual failover:  high-protection mode<br />No witness server &  you are using synchronous operation...
Failover variations 3Forced service<br />Mirror server being available but possibly not synchronized. <br />Mirror server ...
Failover variations 3Forced service<br />---Run the ALTER DATABASE databaseName SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS ...
Rafael  Choice <br /> Asynchronous mirroring without automatic failover .<br />Mirroring asynchronously (high-performance ...
Steps to Set Up DB mirroringIn General<br />Create endpoints on all of the instances.<br /> Create a login for the service...
Steps to Set Up DB mirroring In General<br /> Set the mirror partner for the principal database on the principal partner.<...
Automating Setup – 3 options<br />T-SQL with SPs and linked servers<br />Alternatives - script creates a connection to eac...
T-SQL with SPs & linked servers disadvantage<br />Create linked servers to allow MSSQL run commands against both partners ...
Automating Setup – PowerShell 1<br />PowerShell has the ability to load and use .Net objects.<br />Load the SMO objects in...
Automating Setup – PowerShell 2<br />
Automating Setup – PowerShell 3<br />
Automating Setup – PowerShell 4<br />
Automating Setup - SQLCMD<br />Command-line utility <br />Next generation of the isql and osql utilities<br />Can use  var...
Sqlcmd- Example 1 with variables <br />-- Set here Principal Server name <br />:setvarPrincipalServer  "userWXP.domain.loc...
Sqlcmd - Example 2 with variables file <br />/*	Script variables */<br />:r "d:jobsmssqldb_env.sql"<br />/* End Of Script ...
Prepare the Database for MirroringSQLCMD Version<br />Make  sure the compatibility level is 90 - the min  level required f...
Prepare the Database for MirroringSQLCMD Version<br />SELECT @Compatibility =D.compatibility_level,<br />               @R...
11.1&11.2<br />Procedure to failover   from/to Principal/mirror Server<br />SQLCMD Version<br />/*	Script variables */<br ...
 Database mirroring status table :  dbm_monitor_data table<br />Undocumented table  in  msdb .<br />sp_dbmmonitorupdate  c...
 Database mirroring status table :    select * from msdb.dbo.dbm_monitor_data order by local_timedesc<br />Query the db  m...
  Database Mirroring Monitor Job 1<br />Update the DB mirroring monitor table (sp_dbmmonitorupdate system sp)<br />Default...
  Database Mirroring Monitor Job 2<br />sp_dbmmonitoraddmonitoring<br />Creates the Job with a default schedule to run eve...
  Database Mirroring Monitor Job 3<br />sp_dbmmonitorchangemonitoring: <br />update the interval in which an existing Data...
  Understanding Warning Thresholds 1<br />Events that are written to the Windows Event Log whenever  the threshold exceede...
  Understanding Warning Thresholds 2<br /> <br />Unrestored log (error number 32043): <br />Configure the number of kiloby...
  Understanding Warning Thresholds 3<br />Oldest Unsent transaction (error number 32040): <br />Number of minutes worth of...
  Understanding Warning Thresholds 4<br />Mirror commit overhead (error number 32044): <br />Configure the number of milli...
   Using the Database Mirroring Monitor 1<br />Refreshes status every 30 sec  (async connections to principal &mirror serv...
   Using the Database Mirroring Monitor 2<br />
   Using the Database Mirroring Monitor 3<br />Principal log : status of principal server as of the time displayed<br />Un...
   Using the Database Mirroring Monitor 4<br />Current send rate<br />Rate in kilobytes  transactions are being sent to th...
   Using the Database Mirroring Monitor 5<br /><ul><li>Mirror log: status on the mirror server as of the time displayed in...
   Using the Database Mirroring Monitor 6<br />Mirror commit overhead<br />Only for high-safety mode. <br />Num of millise...
    Monitoring using system SP sp_dbmmonitorresults<br />Directly  returning rows from DB mirroring status table. <br />Pa...
    Monitoring using system SP sp_dbmmonitorresults<br />EXECsp_dbmmonitorresults<br />@database_name=N'adventureWorks',<b...
    Managing Warning Thresholds using system SP 1<br />Instead of the Database Mirroring Monitor<br />3  SPs  configure, v...
= @average_delay, @enabled = 1;<br />    Managing Warning Thresholds using system SP 2<br />--Warn if the unset log exceed...
= @average_delay, @enabled = 1;<br />Top wait Events Checks Network Waits DB mirror <br />
= @average_delay, @enabled = 1;<br />Top wait Events Checks Network Waits DB mirror 2 <br />
Read-writeWorkload<br />Real-time Reporting<br />Real-time Reporting<br />Fast Incremental Backups<br />Fast Backups<br />...
Use fast backups on mirror DB
More than 1 mirror DB destination to improve DRP  </li></ul>What Next I Expect in DenaliOffload Processing– Improve Primar...
Disasters happen every day...its a fact ! <br />Disasters cost money so why suffer by being unprepared? <br />Organization...
Disaster Recovery Process<br /><ul><li>שחזור מטייפ גיבוי יכול לקחת ימים
Data Centric Environments
צמצום “Mean Time To Recovery”   אחרי אירועDRP</li></ul>(redirect)<br />X<br />LAN/WAN<br />Disaster Recovery Site	<br />Pr...
Sample mirroring deployment Plan<br />
Sample mirroring deployment Plan<br />
ד"ר עמי הרי <br />קורס T&E<br />הנדסת מערכת טכניון <br />
מדדים <br />(RTO) Recovery Time Objective <br />הזמן המרבי עד לחזרתה של המערכת לתפקוד מלא עבור תהליכים עסקיים שונים <br />...
מדדים : ניתוח סיכונים(Risk Analysis) <br />תהליך לאיתור סיכונים צפויים ביישום תהליך או מוצר חדש. <br />כולל  הערכת ההסתברו...
תעדוף <br />כשבונים אתר DRP באתר חלופי – קובעים את סדר השחזור לפי רמת החשיבות של המערכות <br />אילו מערכות לא ישוחזרו<br /...
מדדי ביצועים<br />
מדדי ביצועים<br />
שגרה <br />האם אנו מוכנים לאירוע DRP ? <br />
אירוע DRP הוכרז<br />מה עושים ?<br />
Upcoming SlideShare
Loading in...5
×

Database Mirror for the exceptional DBA – David Izahk

4,076

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,076
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
112
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Database Mirror for the exceptional DBA – David Izahk

  1. 1. תאריך<br />סימוכין<br />1<br />Database Mirror for the exceptional DBA<br />דוד יצחק <br />רפא"ל – מערכות לחימה מתקדמות בע"מ<br />cimid@rafael.co.il<br />4.4.2011<br />
  2. 2. Rafael Advanced Defense Systems<br />Designs, develops, manufactures and supplies a wide range of high tech defense systems for air, land, sea and space applications.<br />Sales in 2010 exceeding $1851M<br />About 7000 Employees<br />
  3. 3. Speaker Qualifications<br />SQL Server , Oracle , Sybase ,Sybase Anywhere - application & infrastructure DBA .<br />14 years of SQL experience, starting with version 6.5<br />Education : <br />BSC (Information System Engineer) <br />MBA<br />Currently ME (System Engineering) <br />
  4. 4. Agenda<br />Database Mirroring Architecture Short Overview<br />Automating Setup using T SQL & SQLCMD or Power shell<br />Monitoring and Alerting<br />What Next I Expect in Denali<br />Planning (T&E) and Best Practices.<br />Resources<br />Next Session (?) : <br />Reporting Considerations<br />Merge Replication and Database Mirror as a combined solution<br />Database Mirroring and failover Cluster combination<br />.Net coding with Database Mirror<br />
  5. 5. Key Terms-1<br />Principal: <br />Source of the mirroring. <br />Can mirror one or more databases on a single SQL Server instance to another SQL Server instance.<br />You mirror a database, not a subset of the database<br />Mirror: <br />The recipient of the mirroring from the principal DB server. <br />Kept in hot standby mode cannot be used directly in any way. <br />In continuous “restore” mode.<br />Physical transaction records are continuously applied to this mirror database.<br />Not available for direct DB usage - exception is creating DB snapshots<br />
  6. 6. Key Terms- 2<br />Witness <br />Optional Server that monitor the principal and mirror servers to provide a quorum <br />Partner <br />Opposite server when referring to the principal and mirror servers<br />Endpoint <br />Bound to a network protocol<br /> Allows SQL servers to communicate across the network.<br />
  7. 7. Key Terms - 3<br />Session <br />Active relationship between the servers involved in DB mirroring <br />Allows them to maintain server state information about one another<br />Roles <br />Possible roles:<br />Witness role—Can be any edition of a SQL Server (even SQL Server Express).<br />Principal role<br />Mirror role<br />After a failure, the mirror server takes over the principal role, and the roles reverse.<br /> <br />
  8. 8. Key Terms - 4<br />Role Switching <br />Active relationship between the servers involved in DB mirroring <br />Allows them to maintain server state information about one another<br />The act of transferring the principal role to the mirror server.<br />When a failure occurs :<br />Principal role is switched to the mirror server<br />DB is broughtonline as the principal DB<br />
  9. 9. Copy-on-Write Technology<br />2. Log record <br />Copied to mirror server over Network <br />I<br />1. Client <br />transaction<br />Principle Server<br />Mirror Server<br />Mirror DB<br />3.physical log record is written to the mirror DB<br />Principle DB<br />2.transaction is written<br />to principal server’s transaction log<br />4. acknowledgment to principal server of its write success<br />Mirror DB is exactly the same as the Principal DB <br />*<br />
  10. 10. Principle<br />1. Write the data to transaction log and commit the data<br />DB Mirror High Performance<br />2. Send the transaction to mirror <br />Mirror<br />3. Write the data to transaction log and commit the data <br />4. Send Acknowledgement to principle <br />
  11. 11. Principle<br />1. Write the data to transaction log<br />DB Mirror High Safety with Witness<br />2. Send the transaction to mirror <br />Mirror<br />3. Write the data to transaction log and commit the data <br />4. Send Acknowledgement to principle <br />5. Commit the data<br />
  12. 12. Database Mirroring Operating Modes: Sync/ Async<br />Synchronous operations<br />Committed transaction is committed on both partners of the database mirroring pair. <br />Ensure Zero Data loss.<br />Add some latency cost - it is across two servers.<br />Possible performance issues on slower networks. <br />Recovery is Faster – no uncommitted trans to be applied/undone <br />Failover can be automatic. <br />High-safety modes use synchronous operations.<br />Enterprise/Standard Edition. <br />
  13. 13. Database Mirroring Operating Modes: Sync/ Async<br />Asynchronous operations<br />Transactions commit without waiting for the mirror server to write the log to disk. <br />Can increase performance but chance of some data loss.<br />Enterprise Edition Only . <br />Manual failover only. <br />High-performance mode uses asynchronous operations.<br />
  14. 14. Flow to determine the operating Mode for DB<br />
  15. 15. Operating Modes <br />
  16. 16. Database Mirroring Operating Modesin SSMS<br />
  17. 17. Database Mirroring Operating Modes: Sync/ Async<br />Asyns / Sync depends on the transaction safety setting. <br />Control this setting through SAFETY option when configuring with T-SQL.<br />The default for SAFETY is FULL (synchronous operations).<br />Set it to OFF for asynchronous operations. <br />With mirroring wizard, this option is set for you automatically.<br />ALTER DATABASE $(MirrorDatabaseName) SET SAFETY OFF /ON <br />
  18. 18. Failover variations 1 Automatic failover: high-availability mode<br />Enabled with a three-server configuration: principal, mirror, witness server. <br /> Mirror DB must already be synchronized (Sync with the transactions as they are being written to the principal). <br /> Role switching is done automatically. <br />
  19. 19. Failover variations 2 Manual failover: high-protection mode<br />No witness server & you are using synchronous operations. <br />The principal and mirror are connected to each other<br />Mirror DB is synchronized. <br />Role switching is done manually.<br />High safety without automatic failover mode.<br />You are making the decision to start using the mirror server as the principal (no data loss).<br /> <br />ALTERDATABASE $(MirrorDatabaseName)SETSAFETYFULL<br />ALTERDATABASE $(MirrorDatabaseName)SETPARTNERFAILOVER<br />
  20. 20. Failover variations 3Forced service<br />Mirror server being available but possibly not synchronized. <br />Mirror server can be forced to take over when the principal server has failed. <br />Possibly means data loss because the transactions were not synchronized.<br />For high safety without automatic failover mode (high-protection mode) or high-performance mode.<br />
  21. 21. Failover variations 3Forced service<br />---Run the ALTER DATABASE databaseName SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS <br />SET @strSQL='ALTER DATABASE '+ @strDatabaseName+' SET PARTNER OFF'<br />EXECsp_executesql@strSQL<br />SET @strSQL='RESTORE DATABASE '+ @strDatabaseName+' WITH RECOVERY'<br />EXECsp_executesql@strSQL<br />PRINT'Bringing '+ @strDatabaseName+' ONLINE'<br />OR <br />ALTER DATABASE <DatabaseName> SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS<br />
  22. 22. Rafael Choice <br /> Asynchronous mirroring without automatic failover .<br />Mirroring asynchronously (high-performance mode)<br />Failover is performed manually. <br />when you respond to a failure, you can make a decision as to whether to fail over all databases to the mirroring partners or simply try to resolve the failing database.<br />
  23. 23. Steps to Set Up DB mirroringIn General<br />Create endpoints on all of the instances.<br /> Create a login for the service accounts of the other instances if they do not exist.<br /> Grant connect permissions to the service accounts of the other instances on the endpoint.<br /> Set the principal partner for the mirror database on the mirror partner.<br />
  24. 24. Steps to Set Up DB mirroring In General<br /> Set the mirror partner for the principal database on the principal partner.<br /> If using a witness server, set the witness partner on the principal partner to enable automatic failover.<br /> If not using a witness server, you may want to change the operating mode from “High safety (synchronous)” to “High performance (asynchronous).<br /> <br />
  25. 25. Automating Setup – 3 options<br />T-SQL with SPs and linked servers<br />Alternatives - script creates a connection to each server<br />T SQL with sqlcmd & CONNECT command . <br />PowerShell . <br />I will show option T SQL with sqlcmd<br />
  26. 26. T-SQL with SPs & linked servers disadvantage<br />Create linked servers to allow MSSQL run commands against both partners and witness.<br />SET @PrincipalServer=@@ServerName<br />SET @CurrDBName=DB_NAME()<br />SET @EPName='MirroringEndPoint'<br />-- Make sure linked server to mirror exists <br />EXEC @Results =dbo.dba_ManageLinkedServer<br />@ServerName= @ MirrorServer,<br /> @Action ='create'<br />IF @Results <> 0 <br />BEGIN<br />RETURN @Results;<br />END<br />
  27. 27. Automating Setup – PowerShell 1<br />PowerShell has the ability to load and use .Net objects.<br />Load the SMO objects into PowerShell and use them directly in the script. <br />The SQL Team separated some of the SMO functions into separate DLLs in SQL Server 2008. <br />The script checks the internal version of SMO and loads the SMOExtended object if you are using the SQL Server 2008 version of SMO.<br />Disadvantage: SSMS support partially debugging Power Shell. Need editor. <br /> <br />
  28. 28. Automating Setup – PowerShell 2<br />
  29. 29. Automating Setup – PowerShell 3<br />
  30. 30. Automating Setup – PowerShell 4<br />
  31. 31. Automating Setup - SQLCMD<br />Command-line utility <br />Next generation of the isql and osql utilities<br />Can use variables within sqlcmd input files or scripts.<br />Admins have a lot of scripts each performs its own functions on a specific server. <br />Consolidate into a single script using the :CONNECT command. <br />
  32. 32. Sqlcmd- Example 1 with variables <br />-- Set here Principal Server name <br />:setvarPrincipalServer "userWXP.domain.local"<br />--Set DBs names to DB mirroring <br />(Principal databases) .<br />:setvarMirrorDatabaseName "AdventureWorks"<br />--Set backup directory on principal server .<br />:setvarBackupDirectory "D:Database_Mirroring“<br />--Make a connection to Principal Server using <br />Windows Authentication<br />:CONNECT $(PrincipalServer)<br />GO<br />BACKUPDATABASE [$(MirrorDatabaseName)] TO<br />DISK='$(BackupDirectory)$(MirrorDatabaseName).bak'<br />WITHINIT;<br />Go<br />
  33. 33. Sqlcmd - Example 2 with variables file <br />/* Script variables */<br />:r "d:jobsmssqldb_env.sql"<br />/* End Of Script variables */<br />:CONNECT $(PrincipalServer)<br />GO<br />BACKUPDATABASE [$(MirrorDatabaseName)] <br />TODISK='$(BackupDirectory)$(MirrorDatabaseName).bak‘<br />WITHINIT;<br />Go<br />
  34. 34. Prepare the Database for MirroringSQLCMD Version<br />Make sure the compatibility level is 90 - the min level required for database mirroring. <br />If < 90, sets the compatibility level to the highest setting supported by the version of SQL Server. <br />Make sure the database is using the Full Recovery model. <br />If not changes the recovery model to Full . <br />
  35. 35. Prepare the Database for MirroringSQLCMD Version<br />SELECT @Compatibility =D.compatibility_level,<br /> @RecoveryModel=D.recovery_model,<br /> @MirrState=DM.mirroring_state<br />FROMsys.databases D <br />INNERJOINsys.database_mirroring DM ONDM.database_id=D.database_id<br />WHERED.database_id= @DBID <br />IF @MirrStateISNOTNULL<br />BEGIN<br />RAISERROR('Database [%s] is already configured for mirroring on server [%s].',<br /> 16, 1, @DBName, @Server);<br />RETURN;<br />END<br />IF @Compatibility < 90 <br />…<br />ELSEIF @MaxCompat>= 100 -- SQL Server 2008+ <br />…<br />IF @RecoveryModel<> 1 -- Full Recovery Model <br />
  36. 36. 11.1&11.2<br />Procedure to failover from/to Principal/mirror Server<br />SQLCMD Version<br />/* Script variables */<br />:r "D:jobsmssqldb_env.sql“<br />--Detects any DB that fit the criteria . <br />--Issues the failback command one at a time for each DB .<br />USE[master]<br />GO<br />SELECTDB_ID(N'$(MirrorDatabaseName)')AS [Database ID];<br />GO<br />IFEXISTS(SELECT 1 FROMsys.database_mirroringWHEREdatabase_id=DB_ID(N'$(MirrorDatabaseName)')ANDmirroring_role_desc='PRINCIPAL')<br />ALTERDATABASE $(MirrorDatabaseName)SETSAFETYFULL<br />GO<br />SELECTDB_ID(N'$(MirrorDatabaseName)')AS [Database ID];<br />GO<br />IFEXISTS(SELECT 1 FROMsys.database_mirroringWHEREdatabase_id=DB_ID(N'$(MirrorDatabaseName)')ANDmirroring_role_desc='PRINCIPAL')<br />ALTERDATABASE $(MirrorDatabaseName)SETPARTNERFAILOVER<br />GO<br />
  37. 37.  Database mirroring status table : dbm_monitor_data table<br />Undocumented table in msdb .<br />sp_dbmmonitorupdate creates, updates, truncates the database mirroring status table. <br />DB Mirroring Monitor Job creates this table - Automatically the first time a database mirroring status update occurs. <br />DB Mirroring Monitor & DB Mirroring Monitor Job call sp_dbmmonitorupdate system sp<br />Frequently of updates ? <br />Depends on the method used and the configuration settings. <br />
  38. 38.  Database mirroring status table :  select * from msdb.dbo.dbm_monitor_data order by local_timedesc<br />Query the db mirroring status table on both the principal server and the mirror server.<br />redo_rate is always 0 on the principal server - does not redo transactions. <br />
  39. 39.   Database Mirroring Monitor Job 1<br />Update the DB mirroring monitor table (sp_dbmmonitorupdate system sp)<br />Default schedule is to run once a minute<br />Can change from 1 to 120 minutes. <br />If SQL Server Agent is disabled, Job cannot run.<br />Created automatically when you start a database mirroring session using SSMS or T SQL <br />
  40. 40.   Database Mirroring Monitor Job 2<br />sp_dbmmonitoraddmonitoring<br />Creates the Job with a default schedule to run every minute.<br />Example: Create a new Database Mirroring Monitor Job that runs every 10 minutes.<br />EXEC sp_dbmmonitoraddmonitoring 10<br />sp_dbmmonitordropmonitoring<br />Drop the job. <br />No parameters <br />Example: <br />EXEC sp_dbmmonitordropmonitoring<br />
  41. 41.   Database Mirroring Monitor Job 3<br />sp_dbmmonitorchangemonitoring: <br />update the interval in which an existing Database Mirroring Monitor Job will run. <br />2 parameters<br />Parameter argument is 1, which means update<br />period, followed by the new update interval for the value argument. <br />Example: run every 15 minutes.<br />EXEC sp_dbmmonitorchangemonitoring 1, 15<br /> <br />
  42. 42.   Understanding Warning Thresholds 1<br />Events that are written to the Windows Event Log whenever the threshold exceeded. <br />Can configure alerts to fire based on the error numbers for these events:<br />Unsent log (error number 32042): <br />Number of kilobytes in unsent logs that can accumulate on the principal server before this event is raised. <br />Important<br />Communication issue between partners ( high-performance mode )<br />In high-safety mode if DB mirroring has been paused. <br /> <br /> <br />
  43. 43.   Understanding Warning Thresholds 2<br /> <br />Unrestored log (error number 32043): <br />Configure the number of kilobytes in unrestored logs accumulated on the mirror server before this event is raised. <br />Determine the amount of time it will take to roll forward the log on the mirror server in failover. <br />Generally because the I/O subsystem on the mirror server cannot keep up with the logs coming from the principal server.<br />
  44. 44.   Understanding Warning Thresholds 3<br />Oldest Unsent transaction (error number 32040): <br />Number of minutes worth of transactions that can accumulate in the send queue on the principal server before this event is raised. <br />Communication issue between partners - high-performance mode <br />In high-safety mode if DB mirroring has been paused. <br />
  45. 45.   Understanding Warning Thresholds 4<br />Mirror commit overhead (error number 32044): <br />Configure the number of milliseconds in the average transaction delay that can be tolerated on the principal server before this event is raised. <br />The time the principal server waits for the mirror server to write a transaction to the redo queue - only relevant in high-safety mode <br /> <br />
  46. 46.    Using the Database Mirroring Monitor 1<br />Refreshes status every 30 sec (async connections to principal &mirror servers).<br />Member of the dbm_monitor db role in MSDB (not sysadmin server role) have to wait for the data to be updated by the DB Mirroring Monitor Job <br />Step 1: Registering Mirrored Databases<br />Step 2: Performing Health Checks<br /> <br />
  47. 47.    Using the Database Mirroring Monitor 2<br />
  48. 48.    Using the Database Mirroring Monitor 3<br />Principal log : status of principal server as of the time displayed<br />Unsent log<br />Num of kilobytes waiting in the send queue.<br />Oldest unsent transaction<br />Oldest transaction in the send queue waiting to be sent to the mirror server <br />Amount of potential data loss (in time) in the event of a failure.<br />Time to send log (estimated):<br />Estimate for the amount of time for the principal server to transmit transactions in the send queue to the mirror server.<br />
  49. 49.    Using the Database Mirroring Monitor 4<br />Current send rate<br />Rate in kilobytes transactions are being sent to the mirror server. <br />Current rate of new transactions<br /><ul><li>Current rate of new transaction</li></ul>Rate in kilobytes of new transactions being written to the log on the principal<br />
  50. 50.    Using the Database Mirroring Monitor 5<br /><ul><li>Mirror log: status on the mirror server as of the time displayed in</li></ul> <br />Unrestored log<br />Num of kilobytes waiting in the redo queue.<br /> <br />Time to restore log (estimated):<br />Estimate time for mirror server to apply the transactions waiting in the redo queue to the mirror DB.<br /> <br />Current restore rate<br />Rate in kilobytes that transactions are being restored to mirror DB.<br /> <br />
  51. 51.    Using the Database Mirroring Monitor 6<br />Mirror commit overhead<br />Only for high-safety mode. <br />Num of milliseconds of average delay per transaction you can accept while the principal server waits for a transaction to write to the redo queue on the mirror server before a warning is generated on the principal server.<br /> <br />Time to send and restore all current log (estimated): <br />Estimated time to send and restore all of the transactions that have currently been committed on the principal server to the mirror server. <br />Can be less than “Time to send log (estimated)” + “Time to restore log (estimated)” <br />Because these are parallel operations.<br />
  52. 52.     Monitoring using system SP sp_dbmmonitorresults<br />Directly returning rows from DB mirroring status table. <br />Parameters: <br />@database name: limits the result set to a single database.<br />@mode: Optional parameter that specifies the number of rows returned by the result set.<br />The required input is an integer value between 0 and 9. <br />• 0: Last row<br />• 1: Last 2 hours<br />......<br />• 8: Last 1,000 rows<br />• 9: Last 1,000,000 rows or essentially all rows<br /> <br />@update_table : Optional parameter <br />1 or 0 that determines whether the DB mirroring status table is updated before returning the result set.<br />
  53. 53.     Monitoring using system SP sp_dbmmonitorresults<br />EXECsp_dbmmonitorresults<br />@database_name=N'adventureWorks',<br />@mode = 6,<br />@update_table=<br />
  54. 54.     Managing Warning Thresholds using system SP 1<br />Instead of the Database Mirroring Monitor<br />3 SPs configure, view, and remove warning thresholds: <br />sp_dbmmonitorchangealert, <br />sp_dbmmonitorhelpalert<br />sp_dbmmonitordropalert.<br />
  55. 55. = @average_delay, @enabled = 1;<br />    Managing Warning Thresholds using system SP 2<br />--Warn if the unset log exceeds the the threshold in KB<br />execsys.sp_dbmmonitorchangealert@database_name=N'$(MirrorDatabaseName)',@alert_id=2,@threshold = @enable_send_queue, @enabled = 1;<br />--Warn if the unrestored log exceeds the the threshold in KB<br />execsys.sp_dbmmonitorchangealert@database_name=N'$(MirrorDatabaseName)',@alert_id=3,@threshold = @redo_queue, @enabled = 1;<br />--Warn if the age of the oldest unset transaction exceeds the threshold in minutes<br />execsys.sp_dbmmonitorchangealert@database_name=N'$(MirrorDatabaseName)',@alert_id=1,@threshold = @time_behind, @enabled = 1;<br />--Warn if the mirror commit overhead exceeds the threshold in milliseconds<br />execsys.sp_dbmmonitorchangealert@database_name=N'$(MirrorDatabaseName)',@alert_id=4,@threshold<br />
  56. 56. = @average_delay, @enabled = 1;<br />Top wait Events Checks Network Waits DB mirror <br />
  57. 57. = @average_delay, @enabled = 1;<br />Top wait Events Checks Network Waits DB mirror 2 <br />
  58. 58. Read-writeWorkload<br />Real-time Reporting<br />Real-time Reporting<br />Fast Incremental Backups<br />Fast Backups<br /><ul><li>Offload read-only queries to an up-to-date Mirror DB
  59. 59. Use fast backups on mirror DB
  60. 60. More than 1 mirror DB destination to improve DRP </li></ul>What Next I Expect in DenaliOffload Processing– Improve Primary Performance!<br />Real-time <br />Queries<br />Continuous redo <br />shipping, validation & apply<br /> Mirror DB<br />Principle DB<br />
  61. 61. Disasters happen every day...its a fact ! <br />Disasters cost money so why suffer by being unprepared? <br />Organizations that survive typically have:<br />management foresight<br />tested Processes & procedures<br />back-up facilities<br />A PLAN!!<br />
  62. 62. Disaster Recovery Process<br /><ul><li>שחזור מטייפ גיבוי יכול לקחת ימים
  63. 63. Data Centric Environments
  64. 64. צמצום “Mean Time To Recovery” אחרי אירועDRP</li></ul>(redirect)<br />X<br />LAN/WAN<br />Disaster Recovery Site <br />Production Site<br />(resync backwards after source restoration)<br />
  65. 65. Sample mirroring deployment Plan<br />
  66. 66. Sample mirroring deployment Plan<br />
  67. 67. ד"ר עמי הרי <br />קורס T&E<br />הנדסת מערכת טכניון <br />
  68. 68. מדדים <br />(RTO) Recovery Time Objective <br />הזמן המרבי עד לחזרתה של המערכת לתפקוד מלא עבור תהליכים עסקיים שונים <br />(RPO) Recovery Point Objective<br />הזמן המרבי שלגבי ניתן לאבד מידע . כמות המידע שהארגון מוכן לאבד ? יום שלם , מספר שעות /דקות <br />משתנה באותה סקלה כמו RTO אבל לא תלוי בו (מערכות מסחר RPO אפס אבל RTO גדול יותר) .<br />Service Level Agreement<br />בהקשר לזה מדברים על זמינות , MTTF(Mean Time Between Failure) , MTTR (Mean time To recover) <br />זמינות גבוהה (High availability) <br />יכולת של המשתמש לגשת למערכת לצורך אחזור נתונים בכל עת <br />חוסר זמינות= downtime<br />
  69. 69. מדדים : ניתוח סיכונים(Risk Analysis) <br />תהליך לאיתור סיכונים צפויים ביישום תהליך או מוצר חדש. <br />כולל הערכת ההסתברות וההשפעה הצפויה, ודרכי התגובה, של כל סיכון על מנת לגדר אותו ככל האפשר.<br />רמת הסיכון נקבעת על בסיס המכפלה של "הסיכוי לתקלה "ו"עוצמת התקלה":<br />Risk Level = Probability*Impact<br />
  70. 70. תעדוף <br />כשבונים אתר DRP באתר חלופי – קובעים את סדר השחזור לפי רמת החשיבות של המערכות <br />אילו מערכות לא ישוחזרו<br />רמת השירות שתינתן במסגרת אילוצי מצב חירום <br />
  71. 71. מדדי ביצועים<br />
  72. 72. מדדי ביצועים<br />
  73. 73. שגרה <br />האם אנו מוכנים לאירוע DRP ? <br />
  74. 74. אירוע DRP הוכרז<br />מה עושים ?<br />
  75. 75. אירוע DRP<br />אתר ראשי מסונכרן לאתר משני<br /><ul><li>קרה אסון באתר ראשי
  76. 76. אירוע DRP מוכרז
  77. 77. סנכרון מופסק וה- storage באתר הופך להיות פעיל . בסיסי הנתונים לR/W- </li></ul>סנכרון<br /><ul><li>השרתים הופכים להיות פעילים</li></ul>אתר ראשי<br />(Primary Site)<br />אתר משני<br />(DR Site)<br />71<br />
  78. 78. Resources<br />Microsoft SQL Server 2008 R2 Unleashed (2010), Sams <br />Pro SQL Server Disaster Recovery (2008) , Apress <br />Accelerated SQL Server (2008) , Apress<br />Professional Sql Server 2008 Internals And Troubleshooting (2010) ,Wiley <br />Pro SQL Server 2008 Administration (2009), Apress. <br />Microsoft SQL Server 2008 High Availability with Clustering & Database Mirroring , (2010) ,Wiley <br />SQL Server 2008 Transact SQL Recipes 2008 , Apress.<br />
  79. 79. Resources<br />Professional Association for SQL Server (www.sqlpass.org)<br />SQL Server Central (www.sqlservercentral.com)<br />Simple-Talk (www.simple-talk.com/sql)<br />MSSQLTips.com (www.mssqltips.com)<br />SQLTeam.com (www.sqlteam.com)<br />SQL Server Community (www.sqlcommunity.com)<br />
  80. 80. Discussion, questions & answers<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×