oracle整個庫遷移

我們常常需要對數據進行遷移,遷移到更加高級的主機上、遷移到遠程的機房上、遷移到不同的平臺下……

  一、exp/imp:

  這也算是最常用最簡單的方法了,一般是基於應用的owner級做導出導入。

  操作方法爲:在新庫建立好owner和表空間,停老庫的應用,在老庫做exp user/pwd owner=XXX file=exp_xxx.dmp log=exp_xxx.log buffer=6000000,傳dmp文件到新庫,在新庫做imp user/pwd fromuser=XXX touser=XXX file=exp_xxx.dmp log=imp_xxx.log ignore=y.

  優缺點:優點是可以跨平臺使用;缺點是停機時間長,停機時間爲從exp到網絡傳輸到新庫,再加上imp的時間。

  二、存儲遷移:

  這種情況下,數據文件、控制文件、日誌文件、spfile都在存儲上(一般情況下是裸設備),我們可以直接把存儲掛到新機器上,然後在新機器上啓動數據庫。

  操作方法:將老庫的pfile(因爲裏面有指向裸設備的spfile鏈接),tnsnames.ora,listener.ora,密碼文件傳到新庫的對應位置。將存儲切至新機,或者用文件拷貝或dd的方式複製數據文件,啓動數據庫。

  優缺點:優點是該遷移方式非常簡單,主要的工作是主機工程師的工作,dba只需配合即可,停機時間爲當庫、切存儲、起庫的時間。缺點是要求新老庫都是同一平臺,是相同的數據庫版本。

  三、利用data guard遷移:

  用dg我們不僅可以用來做容災,物理的dg我們還可以作爲遷移的方式。

  操作方法:可見http://www.oracleblog.cn/study-note/dg-created-by-rman/或者http://www.oracleblog.cn/study-note/create-dg-by-rman-one-datafile-by-one-datafile/或者其他相關網文。注意switch over之後,可以將dg拆掉,去掉log_archive_dest_2、FAL_SERVER、FAL_CLIENT、standby_file_management參數。另外還要注意如果用rman做dg,注意手工添加tempfile。

  優缺點:優點是停機時間短,停機時間爲switch over的時間。缺點:主機必須雙份、存儲必須雙份。

  四、用rman做遷移

  rman比較適合於跨文件系統的遷移,如同平臺下的不同文件系統。

  操作方法:

  1.停第三方的歸檔備份,如legato或dp

  2.backup數據庫:

  在一次週末的課程試驗中,頻繁的看到 Data file init write 等待事件。

  在這裏做一點記錄說明,以下是來自跟蹤文件的記錄信息:

以下是引用片段:

  WAIT #2: nam='Data file init write' ela= 13031 count=1 intr=256 timeout=-1 obj#=51706 tim=6068271611

  WAIT #2: nam='Data file init write' ela= 118163 count=1 intr=256 timeout=-1 obj#=51706 tim=6068392491

  WAIT #2: nam='Data file init write' ela= 94036 count=1 intr=256 timeout=-1 obj#=51706 tim=6068490286

  WAIT #2: nam='Data file init write' ela= 52412 count=1 intr=256 timeout=-1 obj#=51706 tim=6068545333

  WAIT #2: nam='Data file init write' ela= 4 count=0 intr=32 timeout=2147483647 obj#=51706 tim=6068545596

  WAIT #2: nam='Data file init write' ela= 26 count=1 intr=32 timeout=2147483647 obj#=51706 tim=6068545641

  WAIT #2: nam='Data file init write' ela= 101743 count=1 intr=256 timeout=-1 obj#=51706 tim=6068648487

  WAIT #2: nam='Data file init write' ela= 44854 count=1 intr=256 timeout=-1 obj#=51706 tim=6068694281

  WAIT #2: nam='Data file init write' ela= 52841 count=1 intr=256 timeout=-1 obj#=51706 tim=6068748054

  WAIT #2: nam='Data file init write' ela= 48984 count=1 intr=256 timeout=-1 obj#=51706 tim=6068798310

  WAIT #2: nam='Data file init write' ela= 3 count=0 intr=32 timeout=2147483647 obj#=51706 tim=6068798365

  WAIT #2: nam='Data file init write' ela= 26 count=1 intr=32 timeout=2147483647 obj#=51706 tim=6068798409

  WAIT #2: nam='Data file init write' ela= 101899 count=1 intr=256 timeout=-1 obj#=51706 tim=6068900931

  WAIT #2: nam='Data file init write' ela= 21 count=-1 intr=32 timeout=2147483647 obj#=51706 tim=6068901053

  測試數據庫是Oracle10g 10.2.0.3,實際上這個等待事件也是從Oracle 10g開始引入的,用來標識表空間或數據文件擴展時的等待。

  Oracle 需要將系統塊格式化爲Oracle數據塊,然後才能提供數據庫使用。

  在這個流程處理中,Oracle經過如下三個步驟:

  1.擴展數據文件

  select file# from file$ where ts#=:1

  2.更新用戶空間限額

  update tsq$ set blocks=:3,maxblocks=:4,grantor#=:5,priv1=:6,priv2=:7,priv3=:8 where ts#=:1 and user#=:2

  3.擴展數據段

  update seg$ set type#=:4,blocks=:5,extents=:6,minexts=:7,maxexts=:8,extsize=:9,extpct=:10,user#=:11,iniexts=:12,lists=decode(:13, 65535, NULL, :13),groups=decode(:14, 65535, NULL, :14), cachehint=:15, hwmincr=:16, spare1=DECODE(:17,0,NULL,:17),scanhint=:18 where ts#=:1 and file#=:2 and block#=:3

  這就是Oracle10g中空間擴展時內部流程。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章