服务器芯片镜像测试,模拟镜像服务器磁盘问题的两个测试【转】
我們知道在高安全模式下,在主服務(wù)器上提交的事務(wù)必須同時(shí)在鏡像服務(wù)器上提交成功,否則該事務(wù)無(wú)法在主數(shù)據(jù)庫(kù)上提交。
在上面的圖中,一個(gè)事務(wù)在主數(shù)據(jù)庫(kù)上提交的步驟包含:
客戶端程序?qū)⑹聞?wù)發(fā)送給主數(shù)據(jù)庫(kù)服務(wù)器SQLServer
主數(shù)據(jù)庫(kù)服務(wù)器?SQL Server為這個(gè)事務(wù)寫日志文件
2.1?????????主數(shù)據(jù)庫(kù)服務(wù)器將這個(gè)事務(wù)的日志內(nèi)容傳遞給鏡像服務(wù)器的SQL Server
鏡像數(shù)據(jù)庫(kù)服務(wù)器SQL Server將收到的日志內(nèi)容寫入到日志文件。
鏡像服務(wù)器回復(fù)主服務(wù)器寫日志的動(dòng)作完成。
主服務(wù)器SQL Server回復(fù)客戶端程序該事務(wù)提交成功。
>2.主數(shù)據(jù)庫(kù)服務(wù)器SQL Server在檢查點(diǎn)時(shí)將該事務(wù)修改的數(shù)據(jù)頁(yè)從內(nèi)存中寫入數(shù)據(jù)文件。
>3.鏡像數(shù)據(jù)庫(kù)服務(wù)器SQL Server將日志對(duì)于的數(shù)據(jù)頁(yè)在文件上做變更。
從這樣的順序中,我們提出一個(gè)問(wèn)題,如果鏡像服務(wù)器的SQL Server在那個(gè)時(shí)候不能完成步驟3,是否這時(shí)主數(shù)據(jù)庫(kù)服務(wù)器對(duì)于的數(shù)據(jù)庫(kù)就不能正常的提交事務(wù)了呢?本文介紹的兩個(gè)測(cè)試就是模擬日志文件和數(shù)據(jù)庫(kù)不可用時(shí)候的測(cè)試結(jié)果
測(cè)試一:數(shù)據(jù)庫(kù)有多個(gè)數(shù)據(jù)文件和日志文件,分布在不同的磁盤上,在鏡像數(shù)據(jù)庫(kù)聯(lián)機(jī)的情況下刪除一個(gè)磁盤,即一個(gè)數(shù)據(jù)文件和日志文件不可能的測(cè)試:
1.創(chuàng)建數(shù)據(jù)庫(kù)test,添加四個(gè)文件。注意為第一個(gè)日志文件設(shè)置較小的大小并禁止自動(dòng)增長(zhǎng):
test?????????????? C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\test.mdf
test_log?????????? C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\test_log.ldf
test1????????????? E:\test1.ndf
testlog1?????????? E:\testlog1.ldf
2.配置數(shù)據(jù)庫(kù)鏡像高安全模式,主服務(wù)器為SQL1,鏡像數(shù)據(jù)庫(kù)為SQL2.
3.創(chuàng)建兩張測(cè)試表test和test1,插入超過(guò)1,000,000行數(shù)據(jù)到test表中.由于第一個(gè)日志文件較小且不能自動(dòng)增長(zhǎng),因此SQL Server開始使用第二個(gè)日志文件testlog1.檢查數(shù)據(jù)庫(kù)鏡像的狀態(tài):
結(jié)果:主數(shù)據(jù)庫(kù)顯示已principal/sychronized
4.執(zhí)行下面的腳本,開始事務(wù),這個(gè)事務(wù)會(huì)執(zhí)行超過(guò)10分鐘:
begin tran
insert into test ?select * from test
insert into test ?select * from test
commit
當(dāng)事務(wù)開始執(zhí)行1分鐘以后,暫停數(shù)據(jù)庫(kù)鏡像1分鐘,然后在手工恢復(fù)數(shù)據(jù)庫(kù)鏡像的同步:
結(jié)果:?主數(shù)據(jù)庫(kù)狀態(tài)顯示principal/synchronizing.
訪問(wèn)test1表,可以返回?cái)?shù)據(jù)。
6.手工將E盤從鏡像數(shù)據(jù)庫(kù)服務(wù)上拔出:.
結(jié)果:?主數(shù)據(jù)庫(kù)狀態(tài)立即變更為?(principal/suspend)。
測(cè)試訪問(wèn)主數(shù)據(jù)庫(kù)并查詢test1表
鏡像數(shù)據(jù)庫(kù)狀態(tài)變更為:?(mirrored, suspend/restoring)
7.檢查事務(wù)的執(zhí)行:
幾分鐘以后,這個(gè)事務(wù)顯示在主數(shù)據(jù)庫(kù)上提交成功。
.
8.檢查主數(shù)據(jù)庫(kù)和鏡像數(shù)據(jù)庫(kù)的SQL Server錯(cuò)誤日志:
主數(shù)據(jù)庫(kù):
Error: 1453, Severity: 16, State: 1.
‘TCP://LDUA2481460-2.DOM248146.COM:5023‘, the remote mirroring partner for database ‘test‘, encountered error 5159, status 1, severity 24. Database mirroring has been suspended.? Resolve the error on the remote server and resume mirroring, or remove mirroring and re-establish the mirror server instance.
鏡像數(shù)據(jù)庫(kù):
‘TCP://LDUA2481460-2.DOM248146.COM:5023‘, the remote mirroring partner for database ‘test‘, encountered error 5159, status 1, severity 24. Database mirroring has been suspended.? Resolve the error on the remote server and resume mirroring, or remove mirroring and re-establish the mirror server instance.
Operating system error 2(The system cannot find the file specified.) on file "E:\test_3.ldf" during RestoreFileHdr.
Test 2:在執(zhí)行并同步一個(gè)大事務(wù)的時(shí)候?qū)㈢R像數(shù)據(jù)庫(kù)刪除:
1.????創(chuàng)建數(shù)據(jù)庫(kù)test,包含一個(gè)數(shù)據(jù)文件一個(gè)日志文件。
test1??????????? E:\test1.mdf
test1_log??????? E:\test1_log.ldf
2.配置數(shù)據(jù)庫(kù)鏡像高安全模式,主服務(wù)器為SQL1,鏡像數(shù)據(jù)庫(kù)為SQL2.
3.創(chuàng)建兩張測(cè)試表test和test1,插入超過(guò)1,000,000行數(shù)據(jù)到test表中.由于第一個(gè)日志文件較小且不能自動(dòng)增長(zhǎng),因此SQL Server開始使用第二個(gè)日志文件testlog1.檢查數(shù)據(jù)庫(kù)鏡像的狀態(tài):
結(jié)果:主數(shù)據(jù)庫(kù)顯示已principal/sychronized
4.執(zhí)行下面的腳本,開始事務(wù),這個(gè)事務(wù)會(huì)執(zhí)行超過(guò)10分鐘:
begin tran
insert into test select * from test
insert into test select * from test
commit
5.當(dāng)事務(wù)開始執(zhí)行1分鐘以后,暫停數(shù)據(jù)庫(kù)鏡像1分鐘,然后在手工恢復(fù)數(shù)據(jù)庫(kù)鏡像的同步:
結(jié)果:?主數(shù)據(jù)庫(kù)狀態(tài)顯示principal/synchronizing.
訪問(wèn)test1表,可以返回?cái)?shù)據(jù)。
6.手工將E盤從鏡像數(shù)據(jù)庫(kù)服務(wù)上拔出:
結(jié)果:?主數(shù)據(jù)庫(kù)狀態(tài)立即變更為?(principal/ disconnected)。
測(cè)試訪問(wèn)主數(shù)據(jù)庫(kù)并查詢test1表
鏡像數(shù)據(jù)庫(kù)不存在。
7.檢查事務(wù)的執(zhí)行:
幾分鐘以后,這個(gè)事務(wù)顯示在主數(shù)據(jù)庫(kù)上提交成功。
8.檢查主數(shù)據(jù)庫(kù)和鏡像數(shù)據(jù)庫(kù)的SQL Server錯(cuò)誤日志:
主數(shù)據(jù)庫(kù):
1453, Severity: 16, State: 1
‘TCP://LDUA2481460-2.DOM248146.COM:5023‘, the remote mirroring partner for database ‘test1‘, encountered error 5149, status 1, severity 16. Database mirroring has been suspended.? Resolve the error on the remote server and resume mirroring, or remove mirroring and re-establish the mirror server instance..
鏡像數(shù)據(jù)庫(kù):
Error: 17053 Severity: 16 State: 1
RestoreFileHdr: Operating system error 2(The system cannot find the file specified.) encountered.
Error: 5159 Severity: 24 State: 1
Operating system error 2(The system cannot find the file specified.) on file "E:\test1_1.ldf" during RestoreFileHdr.
Error: 823 Severity: 24 State: 3.
The operating system returned error 21(The device is not ready.) to SQL Server during a write at offset 0x00000000012000 in file ‘E:\test1.mdf‘. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information see SQL Server Books Online.
Error: 1454 Severity: 16 State: 1.
While acting as a mirroring partner for database ‘test1‘ server instance ‘LDUA2481460-1\MSSQLSERVER1‘ encountered error 823 status 3 severity 24. Database mirroring will be suspended.? Try to resolve the error and resume mirroring.
測(cè)試結(jié)果:
主數(shù)據(jù)庫(kù)在這兩種情況下依然可以訪問(wèn)并且成功提交事務(wù)
轉(zhuǎn)自:http://blogs.msdn.com/b/apgcdsd/archive/2012/03/09/10280123.aspx
總結(jié)
以上是生活随笔為你收集整理的服务器芯片镜像测试,模拟镜像服务器磁盘问题的两个测试【转】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 牡丹油多少钱一斤啊?
- 下一篇: 地下城与勇士驱魔什么时候出二觉?