1. 環境配置
伺服器1:sqlmirror01
ip:192.168.10.176
伺服器2:sqlmirror02
ip:192.168.10.177
作業系統:windows 2012 r2
安裝 .net framework 3.5/4.0
關閉伺服器防火牆或設定白名單
資料庫版本:sql server 2014
2. 建立主金鑰(非必需)
use master
gocreate master key encryption by password='zaq12wsx'
go3. 建立證書
sqlmirror01執行
use master
gocreate certificate sqlmirror01_cert with subject='sqlmirror01 certificate',expiry_date='2099-1-1'
gosqlmirror02執行
use master
gocreate certificate sqlmirror02_cert with subject='sqlmirror02 certificate',expiry_date='2099-1-1'
go4. 建立映象端點
sqlmirror01執行
use master
gocreate endpoint endpoint_mirroring
state=started
as tcp ( listener_port = 5022,listener_ip = all )
for database_mirroring ( authentication = certificate sqlmirror01_cert, encryption = required algorithm aes, role = all )
gosqlmirror02執行
use master
gocreate endpoint endpoint_mirroring
state=started
as tcp ( listener_port = 5022,listener_ip = all )
for database_mirroring ( authentication = certificate sqlmirror02_cert, encryption = required algorithm aes, role = all )
go5. 備份證書
sqlmirror01執行
use master
gobackup certificate sqlmirror01_cert to file = 'c:\certificate_files\sqlmirror01_cert.cer'
gosqlmirror02執行
use master
gobackup certificate sqlmirror02_cert to file = 'c:\certificate_files\sqlmirror02_cert.cer'
go6. 拷貝證書
將sqlmirror01_cert.cer拷貝至sqlmirror02的c:\certificate_files\
將sqlmirror02_cert.cer拷貝至sqlmirror01的c:\certificate_files\
7. 建立登入名
sqlmirror01執行
use master
gocreate login sqlmirror02_login with password='abc@123456'
gosqlmirror02執行
use master
gocreate login sqlmirror01_login with password='abc@123456'
go8. 建立使用該登入名的使用者
sqlmirror01執行
use master
gocreate user sqlmirror02_user for login sqlmirror02_login
gosqlmirror02執行
use master
gocreate user sqlmirror01_user for login sqlmirror01_login
go9. 證書與使用者關聯
sqlmirror01執行
use master
gocreate certificate sqlmirror02_cert
authorization sqlmirror02_user
from file='c:\certificate_files\sqlmirror02_cert.cer'
gosqlmirror02執行
use master
gocreate certificate sqlmirror01_cert
authorization sqlmirror01_user
from file='c:\certificate_files\sqlmirror01_cert.cer'
go10. 授予對遠端映象端點的登入名的 connect 許可權
sqlmirror01執行
use master
gogrant connect on endpoint::endpoint_mirroring to [sqlmirror02_login];
go sqlmirror02執行
use master
gogrant connect on endpoint::endpoint_mirroring to [sqlmirror01_login];
go11. 配置映象夥伴
sqlmirror01執行
建立資料庫
create database [mirror_test_1]
on primary
( name = n'mirror_test_1', filename = n'c:\dbdata\mirror_test_1.mdf' , size = 3072kb , maxsize = unlimited, filegrowth = 1024kb )
log on
( name = n'mirror_test_1_log', filename = n'c:\dbdata\mirror_test_1_log.ldf' , size = 1024kb , maxsize = 2048gb , filegrowth = 10%)
go備份資料庫
backup database mirror_test_1 to disk='c:\backup\mirror_test_1.bak' with compression,checksum
將備份拷貝至sqlmirror02
sqlmirror02執行
restore database mirror_test_1 from disk='c:\backup\mirror_test_1.bak' with norecovery
連線映象
sqlmirror02執行
use master
goalter database mirror_test_1 set partner = 'tcp://sqlmirror01:5022';
gosqlmirror01執行
更改為高效能模式
映象主體sqlmirror01執行
SQL Server 2005資料庫映象簡介
sql server 2005資料庫映象簡介 自從sql server 2000以來,你已經能夠通過使用複製來建立乙個備用的伺服器 傳輸日誌,以及備份和重新儲存了 但是現在微軟又引入了乙個內建的工具,它可以實現自動的錯誤恢復。資料庫映象是sql server 2005的乙個新特性,它允許你將乙個sq...
SQLSERVER2005刪除資料庫映象
sqlserver2005刪除資料庫映象,其實這之前有個很詭異的問題.在資料庫映象斷開後,如何從新建立映象的連線呢?alter database hrmis set partner off?然後再行操作?嘗試後再來結貼。不過這裡要說的是當sqlserver2005映象斷開連線後如何刪除映象的問題,如...
SQL Server資料庫映象關鍵效能計數器
sql server資料庫映象關鍵效能計數器 監視資料庫映象基本有以下5種方法 1.配置資料庫映象監視器 設定告警閾值。2.配置wmi event alert,配置映象狀態修改後的動作或告警。3.使用系統監視器檢視關鍵效能計數器。4.部署作業監控異常映象狀態,傳送告警。5.使用sp dbmmonit...