程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> 記錄一次現場“數據庫遷移”的筆記

記錄一次現場“數據庫遷移”的筆記

編輯:關於JAVA

剛開始出現了些問題,搞得我既郁悶又著急。都不知道我在記什麼了,大家將就著看吧!

一個10G數據庫的真實遷移過程(也可以說是一個數據庫系統崩潰下的恢復過程),要求停機的時間最短

前提:擁有完整的數據庫備份和歸檔日志,遷移的主機所有的目錄結構和原主機一樣。

Oracle版本: 10.1.0.3.0

操作系統: Linux2.6.11

備份程序:rman,沒用恢復目錄

把所有rman的備份(包括控制文件的自動備份)拷貝到新的服務器上,路徑要和原來的一模一樣。

遷移過程如下:

1、把參數文件,tns等文件拷貝到新服務器上,原數據庫停機,開始把數據庫遷移到新的服務器上。

$set Oracle_sid=service

SQL> conn / as sysdba

Connected.

SQL>startup nomount;

2、--恢復控制文件

SQL> declare

devtype varchar2(256);

done boolean;

begin

devtype :=dbms_backup_restore.deviceallocate(NULL);

dbms_backup_restore.restoresetdatafile;

dbms_backup_restore.restorecontrolfileto("/opt/data/SERVICE/control01.ctl"); dbms_backup_restore.restorebackuppIEce("/opt/backup/control_c-4194659530-20050805-01",DONE => done);

end;

/

PL/SQL procedure successfully completed.

--這個過程我到現在還解,應該是只要控制文件自動備份,通過restore controlfile from autobackup就能恢復過來,但我在現場怎麼實現不了。沒辦法,只要用dbms_backup_restore包了。

3、--把控制文件復制成三個文件

$ cp control01.ctl control02.ctl

$ cp control01.ctl control03.ctl

SQL>alter database mount --數據庫啟動到mount狀態准備進行數據文件的恢復

4、--啟動rman

Recovery Manager: Release 10.1.0.3.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target /

connected to target database: SERVICE (DBID=667643333)

RMAN> restore database ;

Starting restore at 05-AUG-05

using target database controlfile instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /opt/data/SERVICE/system01.dbf

restoring datafile 00002 to /opt/data/SERVICE/undotbs01.dbf

restoring datafile 00003 to /opt/data/SERVICE/sysaux01.dbf

restoring datafile 00004 to /opt/data/SERVICE/users01.dbf

restoring datafile 00005 to /opt/data/SERVICE/business01.dbf

restoring datafile 00006 to /opt/data/SERVICE/advertise.dbf

restoring datafile 00007 to /opt/data/SERVICE/backup.dbf

channel ORA_DISK_1: restored backup pIEce 1

pIEce handle=/opt/backup/service_mpgr881f_1_1_565452847 tag=TAG20050804T141407

channel ORA_DISK_1: restore complete

Finished restore at 05-AUG-05

5、--查看歸檔日志

RMAN> list backup archivelog all;

6、進行數據庫的恢復

RMAN> recover database;

Starting recover at 05-AUG-05

using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15553

channel ORA_DISK_1: restored backup pIEce 1

pIEce handle=/opt/backup/service_mqgr88jj_1_1_565453427 tag=TAG20050804T142347

channel ORA_DISK_1: restore complete

archive log filename=/opt/archive/SERVICE1_15553_552391870.dbf thread=1 sequence=15553

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15554

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15555

channel ORA_DISK_1: restored backup pIEce 1

pIEce handle=/opt/backup/service_msgr88om_1_1_565453590 tag=TAG20050804T142629

channel ORA_DISK_1: restore complete

archive log filename=/opt/archive/SERVICE1_15554_552391870.dbf thread=1 sequence=15554

archive log filename=/opt/archive/SERVICE1_15555_552391870.dbf thread=1 sequence=15555

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15556

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15557

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15558

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15559

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15560

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15561

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15562

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15563

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15564

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15565

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15566

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15567

channel ORA_DISK_1: restored backup pIEce 1

pIEce handle=/opt/backup/service_mvgraf8g_1_1_565525776 tag=TAG20050805T102935

channel ORA_DISK_1: restore complete

archive log filename=/opt/archive/SERVICE1_15556_552391870.dbf thread=1 sequence=15556

archive log filename=/opt/archive/SERVICE1_15557_552391870.dbf thread=1 sequence=15557

archive log filename=/opt/archive/SERVICE1_15558_552391870.dbf thread=1 sequence=15558

archive log filename=/opt/archive/SERVICE1_15559_552391870.dbf thread=1 sequence=15559

archive log filename=/opt/archive/SERVICE1_15560_552391870.dbf thread=1 sequence=15560

archive log filename=/opt/archive/SERVICE1_15561_552391870.dbf thread=1 sequence=15561

archive log filename=/opt/archive/SERVICE1_15562_552391870.dbf thread=1 sequence=15562

archive log filename=/opt/archive/SERVICE1_15563_552391870.dbf thread=1 sequence=15563

archive log filename=/opt/archive/SERVICE1_15564_552391870.dbf thread=1 sequence=15564

archive log filename=/opt/archive/SERVICE1_15565_552391870.dbf thread=1 sequence=15565

archive log filename=/opt/archive/SERVICE1_15566_552391870.dbf thread=1 sequence=15566

archive log filename=/opt/archive/SERVICE1_15567_552391870.dbf thread=1 sequence=15567

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15568

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15569

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=15570

channel ORA_DISK_1: restoring archive log

archive log

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved