ORACLE RAC資料庫的備份與恢復(4)
4、RAC備份集恢復到單例項資料庫
從RAC資料庫恢復到單例項的資料庫,需要DBA做的工作還是有一些的---我是指除了常規恢復操作之外。
設定環境如下:
源端:192.168.10.11:12
目標端:192.168.10.101 ,機器名jssnode1
目標端已安裝好資料庫軟體,並升級至與源端相同的版本,引數配置合理並且磁碟空間充足,源端建立的備份集也已複製至目標端。
別的就不廢話了,接下來小跑進入實戰演練部分吧,首先檢查目標端設定環境變數:
[oracle@jssnode1 ~]$ env | grep ORA
ORACLE_SID=jssdb
ORACLE_BASE=/data/ora10g
ORACLE_TERM=xterm
ORACLE_HOME=/data/ora10g/product/10.2.0/db_1進入RMAN命令列模式,並啟動到NOMOUNT狀態:
[oracle@jssnode1 ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Feb 4 15:49:12 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ¨/data/ora10g/product/10.2.0/db_1/dbs/initjssdb.ora¨
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 2082400 bytes
Variable Size 67111328 bytes
Database Buffers 83886080 bytes
Redo Buffers 6303744 bytes腦袋裡蹦出了個大問號:怎麼沒見建立初始化引數檔案,也能啟動到NOMOUNT呢?當然可以啦,具體參考"塗抹ORACLE--三思筆記"中9.2.4.2小節中的相關內容。
啟動過程中報錯了,不管它,這裡startup的目的只是為了給ORACLE分配相應的記憶體區,以便讓他能夠執行下面的restore操作。
從備份集中恢復spfile並儲存成pfile,操作如下:
RMAN> restore spfile to pfile ¨/data1/pfile.ora¨ from ¨/data/backup/07l53d5s_1_1¨;
Starting restore at 04-FEB-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /data/backup/07l53d5s_1_1
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 04-FEB-10接下來要做的是個體力活,修改pfile.ora中的初始化引數,主要有兩方面的修改:
- 修改含檔案路徑的引數,達到符合當前伺服器環境的實際情況
- 修改多例項相關的引數
原檔案內容如下:
jssdbn1.__db_cache_size=104857600
jssdbn2.__db_cache_size=100663296
jssdbn1.__java_pool_size=4194304
jssdbn2.__java_pool_size=4194304
jssdbn1.__large_pool_size=4194304
jssdbn2.__large_pool_size=4194304
jssdbn1.__shared_pool_size=163577856
jssdbn2.__shared_pool_size=167772160
jssdbn1.__streams_pool_size=0
jssdbn2.__streams_pool_size=0
*.audit_file_dest=¨/data/ora10g/admin/jssdb/adump¨
*.background_dump_dest=¨/data/ora10g/admin/jssdb/bdump¨
*.cluster_database_instances=2
*.cluster_database=true
*.compatible=¨10.2.0.1.0¨
*.control_files=¨+ASMDISK1/jssdb/control01.ctl¨,¨+ASMDISK1/jssdb/control02.ctl¨,¨+ASMDISK1/jssdb/control03.ctl¨
*.core_dump_dest=¨/data/ora10g/admin/jssdb/cdump¨
*.db_block_size=8192
*.db_create_file_dest=¨+ASMDISK1¨
*.db_domain=¨¨
*.db_file_multiblock_read_count=16
*.db_name=¨jssdb¨
jssdbn1.instance_number=1
jssdbn2.instance_number=2
*.job_queue_processes=10
jssdbn1.log_archive_dest_1=¨location=/data/oradata/jssdbn1/archivelog¨
jssdbn2.log_archive_dest_1=¨location=/data/oradata/jssdbn2/archivelog¨
*.log_archive_dest_2=¨¨
jssdbn1.log_archive_dest_2=¨service=jssdbn2¨
jssdbn1.log_archive_local_first=FALSE
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_listener=¨LISTENERS_JSSDB¨
*.remote_login_passwordfile=¨exclusive¨
*.sga_target=283115520
jssdbn2.thread=2
jssdbn1.thread=1
*.undo_management=¨AUTO¨
jssdbn1.undo_tablespace=¨UNDOTBS1¨
jssdbn2.undo_tablespace=¨UNDOTBS2¨
*.user_dump_dest=¨/data/ora10g/admin/jssdb/udump¨最終修改完之後,三思這裡的初始化引數如下,比如原來的檔案精簡不少:
*.audit_file_dest=¨/data/ora10g/admin/jssdb/adump¨
*.background_dump_dest=¨/data/ora10g/admin/jssdb/bdump¨
*.compatible=¨10.2.0.1.0¨
*.control_files=¨/data1/jssdb/control01.ctl¨,¨/data1/jssdb/control02.ctl¨,¨/data1/jssdb/control03.ctl¨
*.core_dump_dest=¨/data/ora10g/admin/jssdb/cdump¨
*.db_block_size=8192
*.db_domain=¨¨
*.db_file_multiblock_read_count=16
*.db_name=¨jssdb¨
*.job_queue_processes=10
*.log_archive_dest_1=¨location=/data1/jssdb/archivelog¨
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile=¨exclusive¨
*.sga_target=283115520
*.undo_management=¨AUTO¨
*.undo_tablespace=¨UNDOTBS1¨
*.user_dump_dest=¨/data/ora10g/admin/jssdb/udump¨然後進入sqlplus命令列環境,通過編輯好的pfile建立spfile,並重啟oracle到nomount狀態:
SQL> create spfile from pfile =¨/data1/pfile.ora¨;
File created.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 88081880 bytes
Database Buffers 188743680 bytes
Redo Buffers 6303744 bytes接下來要恢復控制檔案了,再次進入RMAN命令列,注意操作前別忘了設定dbid(如何獲取dbid就不說了吧),執行操作如下:
RMAN> set dbid=953576437
executing command: SET DBID
RMAN> restore controlfile from ¨/data/backup/07l53d5s_1_1¨;
Starting restore at 04-FEB-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/data1/jssdb/control01.ctl
output filename=/data1/jssdb/control02.ctl
output filename=/data1/jssdb/control03.ctl
Finished restore at 04-FEB-10控制檔案成功恢復到指定路徑下。
下面就可以進入到mount狀態了:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1登錄檔庫備份後生成的歸檔檔案備份集:
RMAN> catalog backuppiece ¨/data/backup/08l53d64_1_1¨;
cataloged backuppiece
backup piece handle=/data/backup/08l53d64_1_1 recid=7 stamp=710179350由於之前在RMAN中配置了預設通道,這裡也要將這些配置清除,操作如下:
RMAN> configure channel 1 device type disk clear;
old RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT ¨*¨;
old RMAN configuration parameters are successfully deleted
RMAN> configure channel 2 device type disk clear;
old RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT ¨*¨;
old RMAN configuration parameters are successfully deleted
RMAN> configure device type disk clear;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
RMAN configuration parameters are successfully reset to default value接下來先別忙著做restore,有下列檔案是需要我們預先進行處理的:
SQL> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------------------------------------
1 +ASMDISK1/jssdb/datafile/system.260.703671683
2 +ASMDISK1/jssdb/datafile/undotbs1.259.703671695
3 +ASMDISK1/jssdb/datafile/sysaux.266.703671697
4 +ASMDISK1/jssdb/datafile/undotbs2.258.703671705
5 +ASMDISK1/jssdb/datafile/users.257.703671709
6 +ASMDISK1/jssdb/datafile/jsstbs.269.703779631
6 rows selected.
SQL> select file#,name from v$tempfile;
FILE# NAME
---------- ------------------------------------------------------------
1 +ASMDISK1/jssdb/tempfile/temp.265.703671701
SQL> select member from v$logfile;
MEMBER
------------------------------------------------------------
+ASMDISK1/jssdb/onlinelog/group_1.263.703671679
+ASMDISK1/jssdb/onlinelog/group_2.261.703671681
+ASMDISK1/jssdb/onlinelog/group_3.256.703672257
+ASMDISK1/jssdb/onlinelog/group_4.268.703672257RMAN 中的SET命令可以用來為資料檔案和臨時檔案重新命名,這裡三思就使用set命令對資料檔案和臨時檔案的路徑進行重定義,然後再執行恢復操作,如下:
RMAN> RUN {
2> SET NEWNAME FOR DATAFILE 1 to ¨/data1/jssdb/system01.dbf¨;
3> SET NEWNAME FOR DATAFILE 2 to ¨/data1/jssdb/undoa01.dbf¨;
4> SET NEWNAME FOR DATAFILE 3 to ¨/data1/jssdb/sysaux01.dbf¨;
5> SET NEWNAME FOR DATAFILE 4 to ¨/data1/jssdb/undob01.dbf¨;
6> SET NEWNAME FOR DATAFILE 5 to ¨/data1/jssdb/users01.dbf¨;
7> SET NEWNAME FOR DATAFILE 6 to ¨/data1/jssdb/jsstbs01.dbf¨;
8> SET NEWNAME FOR TEMPFILE 1 to ¨/data1/jssdb/temp01.dbf¨;
9> RESTORE DATABASE;
10> SWITCH DATAFILE ALL;
11> SWITCH TEMPFILE ALL;
12> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 04-FEB-10
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 /data1/jssdb/system01.dbf
restoring datafile 00002 to /data1/jssdb/undoa01.dbf
restoring datafile 00003 to /data1/jssdb/sysaux01.dbf
restoring datafile 00004 to /data1/jssdb/undob01.dbf
restoring datafile 00005 to /data1/jssdb/users01.dbf
restoring datafile 00006 to /data1/jssdb/jsstbs01.dbf
channel ORA_DISK_1: reading from backup piece /data/backup/06l53d53_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/data/backup/06l53d53_1_1 tag=TAG20100203T133531
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 04-FEB-10
datafile 1 switched to datafile copy
input datafile copy recid=7 stamp=710096833 filename=/data1/jssdb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=8 stamp=710096833 filename=/data1/jssdb/undoa01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=9 stamp=710096833 filename=/data1/jssdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=10 stamp=710096833 filename=/data1/jssdb/undob01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=11 stamp=710096833 filename=/data1/jssdb/users01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=12 stamp=710096833 filename=/data1/jssdb/jsstbs01.dbf
renamed temporary file 1 to /data1/jssdb/temp01.dbf in control file對資料庫執行recover,由於我們只複製了備份集,而沒有複製源庫中新歸檔以及online redo檔案,這裡只能進行不完全的恢復(建立的備份並非一致性冷備份),也就是說,報錯是必然的,不過沒關係,只要能修復到一致性狀態就好:
RMAN> recover database;
Starting recover at 04-FEB-10
using channel ORA_DISK_1
starting media recovery
unable to find archive log
archive log thread=2 sequence=98
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/04/2010 17:24:11
RMAN-06054: media recovery requesting unknown log: thread 2 seq 98 lowscn 15874447接下來,我們不得不重建控制檔案,以修復重做日誌檔案的路徑:
SQL> alter database backup controlfile to trace;
Database altered.你也許在想,可以通過"alter database rename file"方式修改重做日誌檔案路徑的啊,事實上"alter database rename file"方式極有可能觸發" ORA-00600: internal error code, arguments: [kgeade_is_0], [], [], [], [], [], [], [] " 錯誤,經查這是ORACLE的一個BUG,對應BUG為7207932,通常是RAC環境從asm向檔案系統遷移時被觸發,在10204版本中依然存在,Doc ID: 742289.1對此有詳細說明,號稱11g版本中對該問題進行了修復。
獲取控制檔案建立指令碼之後,稍加修改(主要是改redolog的路徑),然後在sqlplus命令列環境下執行:
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 92276184 bytes
Database Buffers 184549376 bytes
Redo Buffers 6303744 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "JSSDB" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 192
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 1024
5 MAXINSTANCES 32
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 ¨/data1/jssdb/redo01.dbf¨ SIZE 50M,
9 GROUP 2 ¨/data1/jssdb/redo02.dbf¨ SIZE 50M
10 -- STANDBY LOGFILE
11 DATAFILE
12 ¨/data1/jssdb/system01.dbf¨,
13 ¨/data1/jssdb/undoa01.dbf¨,
14 ¨/data1/jssdb/sysaux01.dbf¨,
15 ¨/data1/jssdb/undob01.dbf¨,
16 ¨/data1/jssdb/users01.dbf¨,
17 ¨/data1/jssdb/jsstbs01.dbf¨
18 CHARACTER SET ZHS16GBK
19 ;
Control file created.
SQL> ALTER DATABASE ADD LOGFILE THREAD 2
2 GROUP 3 ¨/data1/jssdb/redo03.dbf¨ SIZE 50M,
3 GROUP 4 ¨/data1/jssdb/redo04.dbf¨ SIZE 50M;
Database altered.搞定,下面就可以開啟資料庫了:
SQL> alter database open resetlogs;
Database altered.接下來別忘了重建臨時表空間的資料檔案:
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE ¨/data1/jssdb/temp01.dbf¨ size 50m;
Tablespace altered.哎,做到這步,都還沒有完啊,只是說目的基本達成,最後還需要收尾的工作。
清除未使用執行緒的redo日誌組,操作如下:
SQL> select thread#,status,enabled from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PRIVATE
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES INACTIVE
2 1 NO CURRENT
3 2 YES INACTIVE
4 2 NO CURRENT
SQL> alter database disable thread 2;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database clear unarchived logfile group 4;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.清除多餘的undo檔案。
SQL> select name from v$tablespace where name like ¨UNDO%¨;
NAME
------------------------------
UNDOTBS1
UNDOTBS2
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string UNDOTBS1
SQL> drop tablespace undotbs2 including contents and datafiles;
Tablespace dropped.竣工!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7607759/viewspace-631456/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:polardb資料庫備份與恢復資料庫
- RAC備份恢復之Voting備份與恢復
- postgresql備份與恢復資料庫SQL資料庫
- 資料庫備份恢復資料庫
- 資料庫備份與恢復技術資料庫
- 將RAC備份集恢復為單例項資料庫單例資料庫
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- Oracle 備份 與 恢復 概述Oracle
- MySQL-19.資料庫備份與恢復MySql資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- 萬里GreatDB資料庫的學習之路--GreatDB備份與恢復(4)資料庫
- Mysql資料備份與恢復MySql
- Dedecms資料庫恢復與備份的兩種方法資料庫
- 淺談達夢資料庫的備份與恢復資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- 備份與恢復oracle_homeOracle
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- Oracle資料庫冷備和恢復Oracle資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- ORACLE DG從庫 Rman備份恢復Oracle
- mysqldump使用方法(MySQL資料庫的備份與恢復)MySql資料庫
- RabbitMQ如何備份與恢復資料MQ
- Oracle 12c 備份與恢復Oracle
- Mongo 資料庫備份和恢復命令Go資料庫
- pg_dump 備份,恢復資料庫資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- 【ASK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(二)備份恢復之前你需要知道的Oracle
- Oracle 9i統計資訊備份與恢復Oracle
- Oracle 備份恢復之 FlashbackOracle
- ORACLE備份&恢復案例(轉)Oracle
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- 如何在HarmonyOS對資料庫進行備份,恢復與加密資料庫加密
- 分散式文件儲存資料庫之MongoDB備份與恢復分散式資料庫MongoDB
- gitlab的資料備份和恢復Gitlab