手把手教你學會SQL Server鏡像操作
MSSQL 從 2005 開始推出鏡像功能.
SQL Server鏡像是不可讀的.整個庫在個 norecovery模式.
SQL Server鏡像只能是1對1 但可以用鏡像+logshipping 混合實現(xiàn)一對多和鏡像鏈.
SQL Server鏡像認證分為 證書 和windows驗證.windows驗證必須在一個域里面實現(xiàn).
并不是每個公司的生產環(huán)境都是一個域.域的好處是可以做故障轉移群集+鏡像混合實現(xiàn)保障.
下面就說下認證方式的鏡像
環(huán)境:win2008 +mssql2008
1 在主庫上面創(chuàng)建數(shù)據庫主密鑰
- create master key encryption by password ='123!@#abc';
2 創(chuàng)建證書
- create certificate host_105with subject='host_105_c'
3創(chuàng)建端點
- create endpoint endport_mirrorstate=started
- as tcp(listener_port=1522, listener_ip=all)
- for database_mirroring(authentication=certificate host_105,
- encryption=required algorithm AES, role=all );
4 備份證書并把證書復制到鏡像服務器上
- backup certificate host_105 to file='c:\host_105.cer';
5 在備份機上面重復1-4步驟 (證書名不一樣 把 所有帶 host_105替換成host_106)
6 在主機上創(chuàng)建sql驗證賬戶并和證書綁定
- create login mirror_b with password='xwj1234!@#$'
- create user mirror_b
- for login mirror_bcreate certificate host_106
- authorization mirror_bfrom file='c:\host_106.cer'grant
- connect on endpoint:: endport_mirror to mirror_b
7 在鏡像機上創(chuàng)建sql驗證賬戶并和證書綁定
- create login mirror_a with password;='xwj1234!@#$'
- create user mirror_a for login mirror_a;
- grant connect on endpoint::
- endport_mirror to mirror_a;
- create certificate host_105authorization mirror_afrom file='c:\host_105.cer';
8 在主庫新建mirror_test數(shù)據庫 日志模式設置為完全模式 并在鏡像庫上面還原,還原模式為 norecovery
9 同步鏡像
- --- 在鏡像服務器上運行alter database mirror_test
- set partner='TCP://192.168.1.105:1522'
- ---在主機上面運行alter database mirror_test
- set partner='TCP://192.168.1.106:1522'
- ---設置為高性能模式alter database mirror_testset safety off
10 測試
- --在主機執(zhí)行
- create table test(id int);
- insert into test select 1;
- --在鏡像庫上執(zhí)行
- create database mirror_test_snp
- on primary
- (name='mirror_test',filename='c:\mirror_test.mdf')
- as snapshot of mirror_test;
- use mirror_testselect * from test
11 打開鏡像監(jiān)控器
11 mirror+logshipping
原文標題:MSSQLMiRROR
鏈接:http://www.cnblogs.com/xwj1985/archive/2010/08/08/1795225.html
【編輯推薦】
- SQL Server 2000 數(shù)據倉庫中使用分區(qū)之分區(qū)設計
- SQL Server 2000 數(shù)據倉庫中使用分區(qū)之分區(qū)的缺點
- SQL Server 2000 安裝時的一些癥狀歸納
- 啟動自動執(zhí)行SQL Server存儲過程的實際操作流程
- SQL Server數(shù)據庫與EXCEL數(shù)據導入與導出