RAC asm恢復到單例項

n-lauren發表於2012-10-09

rac源伺服器:

rac1:192.168.100.201

rac2:192.168.100.202

目標伺服器:

192.168.8.201

恢復的主要步驟如下:

恢復初始化引數檔案->修改引數檔案->恢復控制檔案->resotre資料檔案->recover資料檔案

1、正確安裝單例項資料庫

1)檢視rac檔案環境變數

[oracle@rac2 log]$ cat/etc/profile.d/oraenv.sh

# oracle 10g

export ORACLE_BASE=/oracle/ora10g

export ORACLE_HOME=$ORACLE_BASE/product/db

export CRS_HOME=$ORACLE_BASE/product/crs

exportPATH=$CRS_HOME/bin:$ORACLE_HOME/bin:$PATH

export ORACLE_OWNER=oracle

export ORACLE_SID=jscn2

exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export NLS_LANG='american_america.ZHS16GBK'

#exportNLS_LANG='american_america.AL32UTF8'

umask 022

目標伺服器ORACLE_SID不要設定

2)安裝備份伺服器

根據這個環境變數建立目標伺服器資料庫(包括,資料庫的安裝,升級包安裝,資料庫不要建立)

2、恢復階段

1)啟動目標資料庫到nomount

[oracle@IM-8-201 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 -Production on Tue Nov 22 21:45:18 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

startup failed: ORA-01078: failure inprocessing system parameters

LRM-00109: could not open parameter file'/oracle/ora10g/product/db/dbs/initjscnora'

starting Oracle instance without parameterfile 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

2)從備份集中恢復spfile,並儲存成pfile,操作如下

把最近的0級備份和後面的備份檔案拷貝到

我們看到備份集有如下

-rw-r----- 1 oracle oinstall 622592 Dec 2 16:11 arch_JSCN_20111202_286

-rw-r----- 1 oracle oinstall 266752 Dec 2 16:11 arch_JSCN_20111202_287

-rw-r----- 1 oracle oinstall 140288 Dec 2 16:13 arch_JSCN_20111202_296

-rw-r----- 1 oracle oinstall 36352 Dec 2 16:13 arch_JSCN_20111202_297

-rw-r----- 1 oracle oinstall 16908288 Dec 2 16:13 control_c-2437751542-20111202-00

-rw-r----- 1 oracle oinstall 196608 Dec 2 16:11 lev0_JSCN_20111202_288

-rw-r----- 1 oracle oinstall 32784384 Dec 2 16:11 lev0_JSCN_20111202_289

-rw-r----- 1 oracle oinstall 172032 Dec 2 16:11 lev0_JSCN_20111202_290

-rw-r----- 1 oracle oinstall 388726784Dec 2 16:12 lev0_JSCN_20111202_291

-rw-r----- 1 oracle oinstall 256327680Dec 2 16:13 lev0_JSCN_20111202_292

-rw-r----- 1 oracle oinstall 9658368 Dec 2 16:13 lev0_JSCN_20111202_293

-rw-r----- 1 oracle oinstall 15204352 Dec 2 16:13 lev0_JSCN_20111202_294

-rw-r----- 1 oracle oinstall 1818624 Dec 2 16:13 lev0_JSCN_20111202_295

這幾個都是最近的備份,control_c-2437751542-20111202-00一個包含初始化引數檔案

讓我們恢復引數檔案

[oracle@IM-8-201 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 -Production on Tue Nov 22 22:07:18 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: DUMMY (notmounted)

RMAN> restore spfile to pfile'/home/oracle/initjscn.ora' from '/orabak/lev2_JSCN_20111201_182';

Starting restore at 22-NOV-11

using target database control file insteadof recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=39 devtype=DISK

channel ORA_DISK_1: autobackup found:/orabak/lev2_JSCN_20111201_182

channel ORA_DISK_1: SPFILE restore fromautobackup complete

Finished restore at 22-NOV-11

--檢視/home/oracle/initjscn.ora

接下來要做的是個體力活,修改 pfile.ora中的初始化引數,主要有兩方面的修改

a 修改含檔案路徑的引數,達到符合當前伺服器環境的實際情況

b 修改多例項相關的引數

c 記憶體引數(如果源伺服器和目錄伺服器記憶體一樣大,不用調)

原檔案內容如下:

---------------------------------------------------------------------------------------------------

jscn2.__db_cache_size=1207959552

jscn1.__db_cache_size=1207959552

jscn2.__java_pool_size=16777216

jscn1.__java_pool_size=16777216

jscn2.__large_pool_size=16777216

jscn1.__large_pool_size=16777216

jscn2.__shared_pool_size=352321536

jscn1.__shared_pool_size=352321536

jscn2.__streams_pool_size=0

jscn1.__streams_pool_size=0

*.audit_file_dest='/oracle/ora10g/admin/jscn/adump'

*.background_dump_dest='/oracle/ora10g/admin/jscn/bdump'

*.cluster_database_instances=2

*.cluster_database=true

*.compatible='10.2.0.3.0'

*.control_files='+DATA/jscn/controlfile/current.263.768517111'

*.core_dump_dest='/oracle/ora10g/admin/jscn/cdump'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_file_multiblock_read_count=8

*.db_name='jscn'

*.dispatchers='(PROTOCOL=TCP)(SERVICE=jscnXDB)'

jscn1.instance_number=1

jscn2.instance_number=2

*.job_queue_processes=10

jscn1.log_archive_dest_1='location=/oraarch1/'

jscn2.log_archive_dest_1='location=/oraarch2/'

jscn1.log_archive_dest_2='service=jscn2'

jscn2.log_archive_dest_2='service=jscn1'

*.open_cursors=300

*.pga_aggregate_target=2512388096

*.processes=1500

*.remote_listener='LISTENERS_JSCN'

*.remote_login_passwordfile='exclusive'

*.sessions=1655

*.sga_target=1610612736

jscn1.standby_archive_dest='/oraarch2/'

jscn2.standby_archive_dest='/oraarch1'

jscn2.thread=2

jscn1.thread=1

*.undo_management='AUTO'

jscn1.undo_tablespace='UNDOTBS1'

jscn2.undo_tablespace='UNDOTBS2'

*.user_dump_dest='/oracle/ora10g/admin/jscn/udump'

---------------------------------------------------------------------------------------------------

最終修改完之後,這裡的初始化引數如下,比如原來的檔案精簡不少:

---------------------------------------------------------------------------------------------------

*.audit_file_dest='/oracle/ora10/admin/jscn/adump'

*.background_dump_dest='/oracle/ora10/admin/jscn/bdump'

*.compatible='10.2.0.3.0'

*.control_files='/oracle/ora10/oradata/jscn/control01.ctl','/oracle/ora10/oradata/jscn/control02.ctl','/oracle/ora10/oradata/jscn/control03.ctl'

*.core_dump_dest='/oracle/ora10/admin/jscn/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=8

*.db_name='jscn'

*.job_queue_processes=10

*.log_archive_dest_1='location=/oraarch'

*.open_cursors=300

*.pga_aggregate_target=251238809

*.processes=150

*.remote_login_passwordfile='exclusive'

*.sessions=165

*.sga_target=261061273

*.undo_management='AUTO'

undo_tablespace='UNDOTBS1'

*.user_dump_dest='/oracle/ora10/admin/jscn/udump'

---------------------------------------------------------------------------------------------------

建立相應的目錄

[oracle@ora-bak-100-119 ~]$ mkdir -p/oracle/ora10/admin/jscn/adump

[oracle@ora-bak-100-119 ~]$ mkdir -p/oracle/ora10/admin/jscn/bdump

[oracle@ora-bak-100-119 ~]$ mkdir -p/oracle/ora10/admin/jscn/cdump

[oracle@ora-bak-100-119 ~]$ mkdir -p/oracle/ora10/admin/jscn/udump

[oracle@ora-bak-100-119 ~]$ mkdir -p /oracle/ora10/oradata/jscn/

現在我們開始恢復了

SQL> create spfile from pfile='/home/oracle/initjscn.ora';

File created.

SQL> shutdown immediate

SQL> startup nomount

ORACLE instance shut down.

SQL> startup nomount

ORA-07446: sdnfy: bad value'/oracle/ora10g/admin/jscn/udump' for parameter user_dump_dest.

SQL> startup nomount

ORACLE instance started.

ORA-04030: out of process memory whentrying to allocate 32 bytes (sqlarea,tmp)

如果碰到以上錯誤

--1、建立相應的目錄

--2、修改pga_aggregate_target為合適的值

SQL> startup nomount

ORACLE instance started.

Total System Global Area 264241152 bytes

Fixed Size 2083200 bytes

Variable Size 83887744 bytes

Database Buffers 171966464 bytes

Redo Buffers 6303744 bytes

3)恢復控制檔案

控制檔案我們預設是自動備份的,所以我們要選取最新的控制檔案來恢復資料

-rw-r----- 1 oracle oinstall 16908288 Dec 2 16:13 control_c-2437751542-20111202-00

1 設定dbid

[oracle@IM-8-201 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 -Production on Tue Nov 22 23:55:44 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: jscn (notmounted)

RMAN> set dbid= 2437751542

executing command: SET DBID

RMAN> restore controlfile from'/orabak/201112/01_L0/cro_c-2437751542-20111201-00';

Starting restore at 23-NOV-11

using target database control file insteadof recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=157 devtype=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete,elapsed time: 00:00:03

outputfilename=/oracle/ora10g/oradata/jscn/control01.ctl

outputfilename=/oracle/ora10g/oradata/jscn/control02.ctl

Finished restore at 23-NOV-11

RMAN> alter database mount;

database mounted

4)恢復資料檔案

先檢視原始檔配置,這些內容存在在控制檔案中

資料檔案:

[oracle@rac2 orabak]$ sqlplus / as sysdba

SQL> select file#,name from v$datafile;

FILE# NAME

------------------------------------------------------------------------------------------

1 +DATA/jscn/datafile/system.276.768517007

2 +DATA/jscn/datafile/undotbs1.280.768517007

3 +DATA/jscn/datafile/sysaux.277.768517007

4 +DATA/jscn/datafile/users.281.768517009

5 +DATA/jscn/datafile/undotbs2.265.768517163

6 +DATA/jscn/datafile/jscn.279.768561585

7 +DATA/jscn/datafile/jscndata.274.768561677

8 +DATA/jscn/datafile/jscnindex.273.768561769

臨時檔案

SQL> select file#,name from v$tempfile;

FILE# NAME

------------------------------------------------------------------------------------------

1 +DATA/jscn/tempfile/temp.266.768517129

日誌檔案:

SQL> select member from gv$logfile;

MEMBER

--------------------------------------------------------------------------------

+DATA/jscn/onlinelog/group_1.278.768517115

+DATA/jscn/onlinelog/group_2.267.768517119

+DATA/jscn/onlinelog/group_3.262.768517183

+DATA/jscn/onlinelog/group_4.261.768517187

RMAN 中的 SET 命令可以用來為資料檔案和臨時檔案重新命名,這裡就使用 set 命令對資料檔案和臨時檔案的路徑進行重定義,然後再執行恢復操作,如下:

RMAN>

RUN {

SET NEWNAME FOR DATAFILE 1 to '/oracle/ora10/oradata/jscn/system01.dbf';

SET NEWNAME FOR DATAFILE 2 to '/oracle/ora10/oradata/jscn/UNDOTBS1.dbf';

SET NEWNAME FOR DATAFILE 3 to '/oracle/ora10/oradata/jscn/sysaux01.dbf';

SET NEWNAME FOR DATAFILE 4 to '/oracle/ora10/oradata/jscn/users01.dbf';

SET NEWNAME FOR DATAFILE 5 to '/oracle/ora10/oradata/jscn/UNDOTBS2.dbf';

SET NEWNAME FOR DATAFILE 6 to '/oracle/ora10/oradata/jscn/jscn.dbf';

SET NEWNAME FOR DATAFILE 7 to '/oracle/ora10/oradata/jscn/jscndata.dbf';

SET NEWNAME FOR DATAFILE 8 to '/oracle/ora10/oradata/jscn/jscnindex.dbf';

SET NEWNAME FOR TEMPFILE 1 to '/oracle/ora10/oradata/jscn/temp01.dbf';

restore database;

switch datafile all;

}

2> 3> 4> 5> 6> 7> 8>9> 10> 11> 12> 13>

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

executing command: SET NEWNAME

Starting restore at 23-NOV-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: starting datafilebackupset restore

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

restoring datafile 00001 to/oracle/ora10g/oradata/jscn/system01.dbf

restoring datafile 00004 to/oracle/ora10g/oradata/jscn/users01.dbf

restoring datafile 00008 to/oracle/ora10g/oradata/jscn/jscnindex.dbf

channel ORA_DISK_1: reading from backuppiece /orabak/lev0_JSCN_20111201_203

channel ORA_DISK_1: restored backup piece 1

piece handle=/orabak/lev0_JSCN_20111201_203tag=LEV0

channel ORA_DISK_1: restore complete,elapsed time: 00:00:45

channel ORA_DISK_1: starting datafilebackupset restore

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

restoring datafile 00005 to/oracle/ora10g/oradata/jscn/UNDOTBS2.dbf

restoring datafile 00006 to/oracle/ora10g/oradata/jscn/jscn.dbf

channel ORA_DISK_1: reading from backuppiece /orabak/lev0_JSCN_20111201_205

channel ORA_DISK_1: restored backup piece 1

piece handle=/orabak/lev0_JSCN_20111201_205tag=LEV0

channel ORA_DISK_1: restore complete,elapsed time: 00:00:25

channel ORA_DISK_1: starting datafilebackupset restore

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

restoring datafile 00002 to/oracle/ora10g/oradata/jscn/UNDOTBS1.dbf

restoring datafile 00003 to/oracle/ora10g/oradata/jscn/sysaux01.dbf

restoring datafile 00007 to/oracle/ora10g/oradata/jscn/jscndata.dbf

channel ORA_DISK_1: reading from backuppiece /orabak/lev0_JSCN_20111201_204

channel ORA_DISK_1: restored backup piece 1

piece handle=/orabak/lev0_JSCN_20111201_204tag=LEV0

channel ORA_DISK_1: restore complete,elapsed time: 00:00:35

Finished restore at 23-NOV-11

datafile 1 switched to datafile copy

input datafile copy recid=9 stamp=767941800filename=/oracle/ora10g/oradata/jscn/system01.dbf

datafile 2 switched to datafile copy

input datafile copy recid=10stamp=767941800 filename=/oracle/ora10g/oradata/jscn/UNDOTBS1.dbf

datafile 3 switched to datafile copy

input datafile copy recid=11stamp=767941800 filename=/oracle/ora10g/oradata/jscn/sysaux01.dbf

datafile 4 switched to datafile copy

input datafile copy recid=12stamp=767941800 filename=/oracle/ora10g/oradata/jscn/users01.dbf

datafile 5 switched to datafile copy

input datafile copy recid=13stamp=767941800 filename=/oracle/ora10g/oradata/jscn/UNDOTBS2.dbf

datafile 6 switched to datafile copy

input datafile copy recid=14stamp=767941800 filename=/oracle/ora10g/oradata/jscn/jscn.dbf

datafile 7 switched to datafile copy

input datafile copy recid=15stamp=767941800 filename=/oracle/ora10g/oradata/jscn/jscndata.dbf

datafile 8 switched to datafile copy

input datafile copy recid=16stamp=767941800 filename=/oracle/ora10g/oradata/jscn/jscnindex.dbf

RMAN> recover database;

Starting recover at 16-DEC-11

using channel ORA_DISK_1

starting media recovery

media recovery failed

RMAN-00571:===========================================================

RMAN-00569: =============== ERROR MESSAGESTACK FOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002: failure of recover command at12/16/2011 01:08:08

ORA-00283: recovery session canceled due toerrors

RMAN-11003: failure during parse/executionof SQL statement: alter database recover if needed

start until cancel using backup controlfile

ORA-00283: recovery session canceled due toerrors

ORA-38760: This database instance failed toturn on flashback database

SQL> alter database backup controlfileto trace;

Database altered.

5)重建控制檔案

SQL> shutdown immediate;

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 264241152 bytes

Fixed Size 2083200 bytes

Variable Size 83887744 bytes

Database Buffers 171966464 bytes

Redo Buffers 6303744 bytes

CREATE CONTROLFILE REUSEDATABASE "JSCN" RESETLOGS ARCHIVELOG

MAXLOGFILES 192

MAXLOGMEMBERS 3

MAXDATAFILES 1024

MAXINSTANCES 32

MAXLOGHISTORY 292

LOGFILE

GROUP 1'/oracle/ora10/oradata/jscn/redo01.dbf' SIZE 50M,

GROUP 2'/oracle/ora10/oradata/jscn/redo02.dbf' SIZE 50M

-- STANDBY LOGFILE

DATAFILE

'/oracle/ora10/oradata/jscn/system01.dbf',

'/oracle/ora10/oradata/jscn/UNDOTBS1.dbf',

'/oracle/ora10/oradata/jscn/sysaux01.dbf',

'/oracle/ora10/oradata/jscn/users01.dbf',

'/oracle/ora10/oradata/jscn/UNDOTBS2.dbf',

'/oracle/ora10/oradata/jscn/jscn.dbf',

'/oracle/ora10/oradata/jscn/jscndata.dbf',

'/oracle/ora10/oradata/jscn/jscnindex.dbf'

CHARACTER SET ZHS16GBK

;

ALTER DATABASE ADD LOGFILE THREAD 2

GROUP 3'/oracle/ora10/oradata/jscn/redo03.dbf' SIZE 50M,

GROUP 4'/oracle/ora10/oradata/jscn/redo04.dbf' SIZE 50M;

SQL> alter database open resetlogs

2 ;

Database altered.

SQL> exit

Disconnected from Oracle Database 10gEnterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Miningand Real Application Testing options

[oracle@IM-8-201 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Productionon Wed Nov 23 09:43:49 2011

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:

Oracle Database 10g Enterprise EditionRelease 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Miningand Real Application Testing options

SQL> conn jscn/jscn

Connected.

SQL> desc nihao;

Name Null? Type

------------------------------------------------- ----------------------------

ID NUMBER

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22990797/viewspace-745954/,如需轉載,請註明出處,否則將追究法律責任。

相關文章