SQL Server 2008 Database Mirroring
Here are some notes on “SQL Server 2008 Database Mirroring” I took while attending an advanced class on SQL Server taught by Greg Low (fromhttp://sqlblog.com/blogs/greg_low/ andhttp://www.sqldownunder.com/).
Please note that, although these notes were taken during the class, I might have added some of my own (mis)interpretation :-). Always check your facts on Books Online (I try to provide links when applicable). As with anything else you get from a blog, never use any of this in production before you thoroughly validate it a test environment. Please keep in mind that some of those will be hard to follow without some pre-requisite knowledge and the right context. Reading the post from top to bottom will help.
Database Mirroring
- Software solution for high availability.
- Per database and not per server.
- Increase data protection, availability, upgrade availability.
- Careful – A lot of things live outside the database
- SQL HA options for the masses, without the high-end hardware requirement.
- Very popular option.
- See http://msdn.microsoft.com/en-us/library/ms189852.aspx
Requirements and Limitations
- Full recovery model
- Express (witness only), Standard (can’t do async) or Enterprise
- Logins (logins are not in the database, you need to make sure they are on the other side)
- Cannot have multiple mirrors – use log shipping if you need this
- Not intended for a large number of databases – Depends on traffic
- Careful – In multi-database applications, failover behavior
- Cannot mirror master, msdb, tempdb, model
Endpoints
- Options for name, port, encryption
- Careful – Names, FQDN, IP addresses
- Endpoint encryption
- See http://msdn.microsoft.com/en-us/library/ms181591.aspx
- Authentication (domain accounts, certificates)
- See http://msdn.microsoft.com/en-us/library/ms190456.aspx
- DNS/WINS – name resolution is important, use FQDN
- See http://msdn.microsoft.com/en-us/library/ms189921.aspx
- Careful – domain suffix issues
- Consider the LISTENER_IP option in endpoint configuration – private network for mirroring
- Example: Setting Up Database Mirroring Using Certificates (Transact-SQL)
- See http://msdn.microsoft.com/en-us/library/ms191140.aspx
Modes
- Roles: Principal, Mirror, Witness
- Modes: high performance (async), high safety (sync), high safety with HA (sync with witness)
- Async: DR scenarios, long distrances, no need for witness – Consider log shipping instead
- See http://msdn.microsoft.com/en-us/library/ms187110.aspx
- Sync: Avoid data loss, performance impact (wait for both logs to write before ack to client)
- See http://msdn.microsoft.com/en-us/library/ms179344.aspx
- Witness: third system to be able to do failover (any edition, including Express)
- See http://msdn.microsoft.com/en-us/library/ms189902.aspx
- Careful – Keep the witness as a third site. One witness can work with multiple mirrors.
- Encryption: Can be used, encrypted data is usually not larger than original data
Clients
- Clients: ADO.NET v2 required for automatic failover: Failover partner in connection string.
- Careful – Client will ask the primary upon connect. Can try the partner if primary not there.
- In SQL Server 2008: Failover partner cached in registry upon first connect to primary (no change to connection string required if primary available on first connect)
- See http://msdn.microsoft.com/en-us/library/ms366348.aspx
Reporting on Mirror
- Mirror can be access as read-only.
- Database snapshots can be created on mirror, you can use snapshot for reports.
- See http://msdn.microsoft.com/en-us/library/ms175511.aspx
- Snapshot cannot be restored to mirror. Snapshot performance implications.
- Careful – refreshing snapshot, finding the correct snapshot, failover situations
- Consider using snapshot as source for a separate reporting database.
- Consider having a process that keeps track of which is the latest snapshot.
Clustering and Mirroring
- Using database mirroring combine with failover clustering.
- Commonly used as a DR solution.
- Do not use auto failover.
- See http://msdn.microsoft.com/en-us/library/ms191309.aspx
SQL Server 2008
- Logstream compression
- See http://technet.microsoft.com/en-us/library/cc645581.aspx
- Automated page repair
- See http://msdn.microsoft.com/en-us/library/bb677167.aspx
- Incoming log stream processing improvements
- Transparent client redirection
Failover
- Manual failover – Must be in sync, use SSMS or ALTER DATABASE...
- See http://msdn.microsoft.com/en-us/library/bb522476.aspx
- Automated failover – Need witness, must avoid “split brain” scenario
- Careful – Lack of synchronization
- Careful – Option to “Force Service” when not in sync, allows data loss
- See http://msdn.microsoft.com/en-us/library/ms189977.aspx
- After failover, if mirroring isn’t disabled, original principal becomes mirror
Upgrade Steps
- Switch to high safety (sync). Make sure it’s in sync.
- Disable the witness.
- Perform a rolling upgrade (upgrade mirror, manual failover to mirror, upgrade original principal, manual failover to original principal).
- Switch back to high performance (async)
- Re-enable the witness.
- See http://msdn.microsoft.com/en-us/library/bb677181.aspx
- Careful – Some data loss may occur
Technet Best practices
- Looking at Database Mirroring Best Practices and Performance Considerations
- http://download.microsoft.com/download/4/7/a/47a548b9-249e-484c-abd7-29f31282b04d/DBM_Best_Pract.doc
- Comparing Workload1 and Workload2 – OLTP vs. batch-type workload
- Looking at performance with no mirroring vs. Safety OFF vs. Safety FULL
- Looking at time to index creation, index rebuild – impact with ONLINE=ON due to waiting on mirror
Performance counters
- Log send queue rate
- Log bytes redone from cache/sec
- Log bytes sent from chace/sec
- Log compressed bytes rcvd/sec (2008)
- Log compressed bytes sent/sec (2008)
- Log harden times (ms)
- Log remaining for undo KB
- Log scanned for undo KB
- Mirror write transactions/sec
- See http://technet.microsoft.com/en-us/library/ms189931.aspx
- See http://msdn.microsoft.com/en-us/library/ms408393.aspx
Failover process
- Failover occurs
- Some time to detect the failure (hard failures (network outage) are quicker than soft failures)
- Some time to coordinate with the witness
- Decision to failover
- Some time (order of a second) to actually fail over
- Database available on new principal
- Database Undo continues
- Time to failover typically just a few seconds (varies depending on case – pull network cable, power off principal, stop sql server service, shutdown principal, manual failover)
Network
- Log send flow control time (ms)
- Looking at typical network latency (LAN, MAN, WAN)
- Looking at whitepaper numbers on network latency effects on sync mirroring
- SQL Server 2008 – Log stream compression, trade off: data volume vs. CPU, affects both sides
- Looking at long stream compression effect on transactions/sec (SQL CAT team test)
- See http://sqlcat.com/technicalnotes/archive/2007/09/17/database-mirroring-log-compression-in-sql-server-2008-improves-throughput.aspx
Automatic page repair
- Pages on both principal and mirror can be repaired using each other’s copy
- Detection and repair of 823 and 824 errors
- Standard or Enterprise edition
- See http://msdn.microsoft.com/en-us/library/bb677167.aspx
- Looking at suspect_pages
- See http://msdn.microsoft.com/en-us/library/ms191301.aspx
Demo
- Database in full recovery mode
- Backup original database
- Restore both backups with NO RECOVERY
- Careful – Consider options to migrate and keep other objects in sync (Logins, SQL Server Agent jobs (disabled), SSIS packages, linked servers, backup devices, maintenance plans, database mail profiles, etc.)
- In SSMS, Database “Recovering…”, click on Tasks, Mirror…
- Witness – can be enabled from principal or partner, but keep in separate server
- Principal – Listener port, encryption, endpoint
- Partner – Listener port, encryption, endpoint
- Security – Service accounts for principal, partner
- Review screen – Principal and Mirror endpoints – format is TCP://computer:port
- Option to start mirroring right away…
- SELECT * FROM sys.endpoints
- SELECT * FROM sys.dm_db_mirroring_connections
- Notice that the wizard made a few calls on your behald, like encryption protocol
- Careful – If status is “Synchronizing…” all the time, you’re running behind (not keeping up)
- Adding a witness
- Launching “Database Mirroring Monitor”
Demo with TDE
- Redoing from start – using a database with TDE
- Backup database, backup certificate and private key
- Restore certificate and private key, Restore database with no recovery
- Configuring mirroring via TSQL.
- If not already there, would need to do CREATE ENDPOINT … on each side.
- Then run on each side of the partnership
- ALTER DATABASE … SET PARTNER=’ TCP://computer1:port’
- Then to fail over
- ALTER DATABASE… SET PARTNER FAILOVER
- See http://blogs.msdn.com/sqlserverfaq/archive/2009/03/31/setting-up-database-mirroring-in-sql-server-2008-using-t-sql-when-the-database-is-encrypted-using-transparent-data-encryption.aspx
Mirroring Details
- Backup: Can’t backup mirror, can’t backup snapshot, Consider log shipping for those
- Monitoring: Check if partner is keeping up
- Monitoring GUI: GUI tool, dm_monitor monitor role
- Monitoring SP: sp_dbmonitorupdate, once per minute by default, updates internal msdb table
- See http://msdn.microsoft.com/en-us/library/ms403827.aspx
- States: Synchronized, Synchronizing, Suspended (pause), Disconnected
- See http://msdn.microsoft.com/en-us/library/ms189284.aspx
- Cross domain security: Use certificate security
- See http://msdn.microsoft.com/en-us/library/ms191140.aspx
- Client design: Consider the added latency when working with high safety
- Network issues: No set limits for async, compression helps, consider the consequences
- Currently no support for combining filestream and mirroring (consider Clustering)
- Careful - Mirroring and multi-dabase apps. Mirror is per database.
Mirror and other technologies
- Mirroring and Replication – Supported
- Mirroring and Database Snapshots – Supported
- Mirroring and Clustering – Supported. Typical: Cluster local, async mirroring to remote
- Mirroring and Log Shipping – Supported. Consider carefully
- See http://msdn.microsoft.com/en-us/library/bb500117.aspx
Related blog posts
- http://blogs.technet.com/josebda/archive/2009/04/02/sql-server-2008-log-shipping.aspx
- http://blogs.technet.com/josebda/archive/2009/04/02/sql-server-2008-database-snapshots.aspx
- http://blogs.technet.com/josebda/archive/2009/04/02/sql-server-2008-failover-clustering.aspx
- http://www.sqlservercentral.com/blogs/robert_davis/archive/2008/11/18/How-many-mirrored-databases-can-I-have-on-a-server_3F00_.aspx
- http://blogs.msdn.com/john_daskalakis/archive/2009/01/15/9320483.aspx
- http://www.sqlskills.com/BLOGS/PAUL/category/Conference-Questions-Pot-Pourri.aspx
Link:http://blogs.technet.com/b/josebda/archive/2009/04/02/sql-server-2008-database-mirroring.aspx
转载于:https://www.cnblogs.com/yefengmeander/archive/2011/10/08/2887670.html
SQL Server 2008 Database Mirroring相关推荐
- 70-433 Microsoft SQL Server 2008, Database Development 考试感言
今天通过了70-433 SQL SERVER 2008 数据库开发这门考试.考了2.5小时,65道题,700分通过.考试时间一共3小时20分. 准备这门考试,大概花了我两周的业余时间.没看MOC的教材 ...
- SQL Server 2008 认证之路
考试流程: 先到考试机构(例如:普尔文Prometric )的授权考试中心交费.填写报名资料,就可以预约2天后(或者更晚)的考试,考试机构受理之后会发一封确认邮件到你的邮箱. 考试形式通常为机考,以单 ...
- Pro SQL Server 2008 Mirroring
Pro SQL Server 2008 Mirroring 转载于:https://www.cnblogs.com/gavinhughhu/archive/2009/11/13/1602246.htm ...
- 今天在webcasts上看sql server 2008的新功能介绍,无意中发现在连接sql server 数据库时,还有一个...
今天在webcasts上看sql server 2008的新功能介绍,无意中发现在连接sql server 数据库时,还有一个 Failover Partner的选项.以前都没注意过,它的主要功能就是 ...
- 一. SQL Server 2008 新特性概述
前几天一直再学习ASP.NET MVC框架.这几天在研究EMC存储和F5交换机都是奢侈品啊,虽然在工作中大多是ORCLE,看到SQL SERVER 2K8有许多新特性决定学习学习,增加自己的市场竞争力 ...
- PowerShell 2.0 实践(十二)管理 SQL Server 2008 R2(1)
DBA可以使用的工具很多,对于SQL Server来说,有查询分析器.事件探查器.命令行工具等,其中SQL语句是重中之重,但是PowerShell的出现使得DBA又多了一种选择. 测试脚本下载 本系列 ...
- [转]实战 SQL Server 2008 数据库误删除数据的恢复
实战 SQL Server 2008 数据库误删除数据的恢复 关键字:SQL Server 2008, recover deleted records 今天有个朋友很着急地打电话给我,他用delete ...
- 在SQL Server 2008中配置文件流(FILESTREAM)
SQL Server 2008推出了一个新的特性叫做文件流(FILESTREAM),它使得基于SQL Server的应用程序可以在文件系统中存储非结构化的数据,例如文档.图片.音频.视频等等.文件流主 ...
- SQL Server 2008高可用性系列:数据库快照
SQL Server 2008高可用性系列:数据库快照 http://database.51cto.com 2010-09-13 14:45 我爱菊花 博客园 我要评论(0) 摘要:我们今天要 ...
最新文章
- ubuntu上玩3D,把状态栏面板栏给玩没了
- (仿头条APP项目)2.主界面按钮切换Fragment页面
- mysql频繁查询出错_Mysql数据库频繁查询错误解决方案
- mysql 宽字符注入_sql注入 宽字节注入
- How to use QueryPerformanceCounter? (c++,不使用 .Net)
- Nginx 基础(一)
- 简单的Twitter:Heroku上的Play框架,AJAX,CRUD
- layui爱准挂更新密码静态WEB页(临时)
- linux 背光驱动程序,Linux驱动工程师成长之路 LCD背光控制RT9379B
- docker容器构建_我如何容器化构建系统
- 2013-09-16 构建C1000K的服务器(1) – 基础
- FFmpeg实现音视频同步的精准片段拼接
- 美国佛罗里达州立大学计算机系王广老师招收人工智能全奖博士生
- Shiro在线刷新权限
- Python就业指导
- 中英双语版Arnold for Cinema 4D 2023(c4d阿诺德渲染器插件)
- 阿里云腾讯云服务器安装oracle11g
- 天津社保EMC存储容灾项目---2629万
- cad用键盘放大缩小_cad放大的命令多少(CAD的放大缩小快捷键是什么?)
- 顶部Snackbar实现
热门文章
- MATLAB操作学习---起式
- ipc4 - A 转换AV号(avtobv)
- linux桌面支持hdpi,用于HiDPI显示器的最佳Linux桌面环境 | MOS86
- TI 927 928 947 948 940串行器解串器系列
- c语言if语句后的一对圆括号,在C语言中,紧跟在关键字if后一对圆括号里的表达式()...
- 2019年终总结---在前端的成长
- 郑大计算机研究生学硕好还是专硕好,2021郑州大学考研:学硕专硕的区别
- python已知两条直角边求斜边,Python实现“已知三角形两个直角边,求斜边”
- 【数字信号去噪】基于matlab小波阙值数字信号去噪和求信噪比【含Matlab源码 2191期】
- 解决CSDN上传MD文件不能显示照片