數據庫容災軟件測試計劃

  • 測試目的
  1. 驗證Beedup對SQL Server2008及以上版本的數據庫實時複製、數據容災功能。
  2. 瞭解Beedup技術實現方式,依賴的運行環境,爲制定容災方案提供參考。
  • 測試目標
  1. Beedup全量初始化複製、實時增量複製功能
  2. DDL複製支持,支持角色、用戶、架構、登錄用戶、表 (列定義 主外鍵 索引)、視圖、存儲過程、函數、觸發器等對象複製
  3. Beedup對主庫的無侵入部署運行,不影響生產庫的正常運行
  4. 直觀簡潔的配置操作,最小化維護成本
  • 測試環境
  1. 系統環境
  1. 主服務器:
  • 操作系統 Win Server 2008
  • 數據庫版本Microsoft SQL Server 2008 R2 Microsoft Corporation  Enterprise Edition (64-bit)
  • 準備測試樣本數據庫,庫中包含測試表及測試數據
  1. 從服務器:
  • 操作系統 Win Server 2008
  • 數據庫版本Microsoft SQL Server 2008 R2 Microsoft Corporation  Enterprise Edition (64-bit)
  • 創建測試數據庫,無需建表及其它對象
  1. Beedup服務器
  • 操作系統 Win Server 2008
  1. 複製條件
  1. 主庫恢復模式必需爲完整,並在設置爲完整模式後做過整庫備份
  2. 主庫登錄用戶具有讀取數據庫字典信息及事務日誌的權限,建議用SA
  3. 從庫登錄用戶具有讀取數據庫字典信息及執行DDL(創建或刪除角色、用戶、架構、表、視圖、存儲過程、函數、觸發器等對象)的權限,建議用SA
  4. Beedup服務器可以通過IP地址、端口、數據庫名、用戶、密碼等連接信息登錄主從數據庫
  5. 主數據庫關閉發佈複製功能
  6. 主數據庫關閉CDC功能
  • 測試步驟
  1. 在主庫準備測試表及數據

create table full_test(id int not null,name varchar(20) not null,birth datetime not null,intro varchar(100))

insert into full_test(id,name,birth) values(1,'john','2017-5-20')

insert into full_test(id,name,birth) values(2,'tom','2017-6-20')

insert into full_test(id,name,birth) values(3,'mike','2017-4-20')

  1. 在Beedup中創建複製任務,配置複製的主從庫連接參數,勾選【全量複製】。
  2. 啓動複製任務,開始初始化全量複製。
  3. 全量複製完畢,隨機抽樣數據表,利用Beedup數據比對功能,效驗全量複製數據一致性。
  4. 打開主庫SQL Server管理器,對某一張表進行 增刪改以及TRUNCATE 數據操作,查看Beedup任務計數器及日誌輸出,確認相應操作複製完成。打開從庫SQL Server管理器,查詢從表對應數據,效驗增量數據複製一致性。

insert into full_test(id,name,birth) values(4,'abc','2010-4-20')

update full_test set intro = 'dsafdsafafadsf' ,birth = '2005-5-20' where id = 1

delete from full_test where id = 2

truncate table full_test

 

  1. 在主庫創建表,並插入、修改、刪除、truncate數據,查看Beedup日誌輸出,確認軟件在從庫複製同樣的操作;更改主庫表字段,確認從庫對應表字段發生同樣更改;刪除主庫表,確認從庫表也被刪除。

create table emploee(id int not null,name varchar(20) not null,birth datetime not null,intro varchar(100))

alter table emploee add primary key (id)

insert into emploee(id,name,birth) values(1,'john','2017-5-20')

insert into emploee(id,name,birth) values(2,'tom','2017-6-20')

insert into emploee(id,name,birth) values(3,'mike','2017-4-20')

update emploee set intro = 'dsafdsafafadsf' ,birth = '2005-5-20' where id = 1

delete from emploee where id = 2

truncate table emploee

alter table emploee add note varchar(20) null

alter table emploee alter column name varchar(40)

alter table emploee drop column intro

drop table emploee

 

  1. 主庫創建主從外鍵依賴表,測試事務複製完整性

創建主表

create table dbo.t_master(id BIGINT IDENTITY NOT NULL,name VARCHAR(50) NULL,address VARCHAR(50) NULL)

alter table dbo.t_master add primary key (id)

 

創建從表

create table dbo.t_slave(id BIGINT IDENTITY NOT NULL,name VARCHAR(50) NOT NULL,address VARCHAR(50) NULL,imp_id BIGINT NULL)

alter table dbo.t_slave add primary key (id)

 

創建外鍵

ALTER TABLE dbo.t_slave  WITH CHECK ADD  CONSTRAINT FK_t_slave_t_master FOREIGN KEY(imp_id)REFERENCES dbo.t_master (id)

 

批量插入數據

declare @count2 int

  set @count2 = 1

  begin

    while @count2<=1000

     begin

         begin transaction

         insert into dbo.t_master(name,address)

             values('m_name_'+cast( @count2 as varchar),'m_address_'+cast( @count2 as varchar))

         insert into dbo.t_slave(name,address,imp_id)

             values('s_name_'+cast( @count2 as varchar),'s_name_'+cast( @count2 as varchar),@count2)

         commit transaction

         set @count2 = @count2 + 1

     end

end

 

批量修改數據

declare @count2 int

  set @count2 = 1

  begin

    while @count2<=100

    begin

         begin transaction

         update dbo.t_master set name = 'm_name_upd_測試2',address = 'm_address_upd_測試' where id = @count2

         update dbo.t_slave set name = 'm_name_upd_測試2',address = 'm_address_upd_測試' where id = @count2

         commit transaction

         set @count2 = @count2 + 1

    end

end

 

批量刪除數據

declare @count2 int

  set @count2 = 1

  begin

    while @count2<=1000

     begin

         begin transaction

         delete from dbo.t_slave where id = @count2

         delete from dbo.t_master where id = @count2

         commit transaction

         set @count2 = @count2 + 1

     end

end

 

  1. 在主庫創建索引、視圖、函數、過程、觸發器等對象,查看對象是否可以正常複製到從庫。

create UNIQUE NONCLUSTERED INDEX IX_full_test_id ON full_test (id)

 

create view v_full_test as select id,name from full_test

 

create function dbo.Csj 

(@m_str varchar(80)) 

returns varchar(80) as begin 

         declare @i varchar(80) 

         if @m_str='0'  set @i='A'

         if @m_str='1'  set @i='B' 

          return (@i) 

end 

 

alter function dbo.Csj 

(@m_str varchar(80)) 

returns varchar(80) as begin 

         declare @i varchar(80) 

         if @m_str='1'  set @i='修改'

         if @m_str='0'  set @i='B' 

         return (@i) 

End

 

create procedure cc as select * from full_test

alter procedure cc as select id from full_test

 

create trigger tr_full_test on full_test for update as

begin

if update (id)

raiserror('操作錯誤',10,1)

rollback

end

EXEC sp_help 'ccff'

update full_test set id=where name = 'aaa'

 

alter trigger tr_full_test on full_test for update as

begin

if update (name)

raiserror('無法操作',10,1)

rollback

end

update full_test set name='abcd'  where id=1

 

  1. 刪除第7步主庫創建的對象,查看從庫對象是否可以自動刪除。

drop index IX_full_test_id on full_test

drop view v_full_test

drop function dbo.Csj

drop procedure cc

drop trigger tr_full_test

發佈了11 篇原創文章 · 獲贊 1 · 訪問量 4054
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章