rac?

Tags: 實例, 服務器,

原庫是一個RAC,目前開發人員誤刪除一張核心表。需要恢復這張表,回收站中沒有。只能rman恢復原庫在刪除之前。恢復的獨立那一臺服務器172.17.214.240。存儲使用原服務器上備份存儲。

操作步驟:

1:存儲選擇

2:創建用戶,需要和原庫的用戶id和名稱一致

3:創建dump目錄

4: 選擇哪個備份呢

5:複製密碼文件和pfile文件

6:啟動

7:還原控制文件

8:catalog 全備

9:還原數據文件

10:catalog歸檔備份並recover數據庫

11:刪除多餘日誌文件

12:trace控制文件

操作步驟:

1:存儲選擇

機房中沒有乾淨的存儲。由於其他存儲已經nfs掛載到其他服務器中。而nfs默認掛載會鎖定存儲。而原庫中的172.17.214.50正好只有db1這臺服務器用來rman備份數據庫用。首先用 fuser –m –v /DBbak 查看哪些進程使用這個目錄。發現沒有後直接卸載 umount /DBbak,然後重新掛載mount –t nfs –o nolock 172.17.214.50:/vol/a/bak /DBbak。172.17.214.240服務器同樣用服務器掛載 mount -t nfs -o nolock 172.17.214.50:/vol/a/bak /oradata/。這樣的好處是節省複製備份時間。

rac 恢復到單實例

2:創建用戶,需要和原庫的用戶id和名稱一致

需要和原庫用戶一致。

[[email protected] backup]# groupadd -g 1010 oinstall

[[email protected] backup]# groupadd -g 1011 dba

[[email protected] backup]# useradd -m -g oinstall -G dba -u 500 oracle

rac 恢復到單實例

3:創建dump目錄

mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump

mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/dpdump

mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/hdump

mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/pfile

mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/scripts

4: 選擇哪個備份呢

選擇刪除表時間之前的備份

rac 恢復到單實例

5:複製密碼文件和pfile文件

[[email protected] dbs]$ cp orapworcl1 /DBbak/240/back/

[[email protected] ~]$ cp 240.pfile /DBbak/240/back/

240服務器上修改密碼文件名稱

[[email protected] ~]$ cd /oradata/240/back/

[[email protected] back]$ ls

240.pfile orapworcl1

[[email protected] back]$ cp orapworcl1 /home/oracle/u01/app/oracle/product/11.2.0/db_1/dbs/

[[email protected] back]$ cd /home/oracle/u01/app/oracle/product/11.2.0/db_1/dbs/

[[email protected] dbs]$ ls

init.ora orapworcl1

[[email protected] dbs]$ mv orapworcl1 orapworcl

[[email protected] dbs]$ ls

init.ora orapworcl

[[email protected] dbs]$

密碼文件必須是特殊名稱,且必須放在特殊目錄

6:啟動

SQL> startup nomount pfile=/oradata/240/back/240.pfile;

ORA-16032: parameter LOG_ARCHIVE_DEST destination string cannot be translated

ORA-07286: sksagdi: cannot obtain device information.

Linux-x86_64 Error: 2: No such file or directory

把LOG_ARCHIVE_DEST去除之後啟動正常

SQL> startup nomount pfile=/oradata/240/back/240.pfile;

ORACLE instance started.

Total System Global Area 4175568896 bytes

Fixed Size 2234960 bytes

Variable Size 1828718000 bytes

Database Buffers 2332033024 bytes

Redo Buffers 12582912 bytes

參數文件/oradata/240/back/240.pfile:

orcl.__java_pool_size=16777216

orcl.__large_pool_size=16777216

orcl.__oracle_base='/home/oracle/u01/app/oracle'#ORACLE_BASE set from environment

orcl.__pga_aggregate_target=1073741824

orcl.__sga_target=4194304000

orcl.__shared_io_pool_size=0

orcl.__shared_pool_size=1778384896

orcl.__streams_pool_size=16777216

*.audit_file_dest='/home/oracle/u01/app/oracle/admin/orcl/adump'

*.audit_trail='NONE'

*.compatible='11.2.0.0.0'

*.control_files='/oradata/240/oradata/control01.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='orcl'

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

*.open_cursors=300

*.pga_aggregate_target=1073741824

*.processes=1500

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=1655

*.sga_target=4194304000

*.undo_tablespace='UNDOTBS1'

內存設置大小根據服務器設置

7:還原控制文件

RMAN> restore controlfile from '/oradata/backup/oracle/orcl/ctlbackup/CTLBAK_ORCL_20150830_6552_1';

Starting restore at 09-SEP-15

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=2186 device type=DISK

channel ORA_DISK_1: restoring control file

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

output file name=/oradata/240/oradata/control01.ctl

Finished restore at 09-SEP-15

啟動到mount之後,這時可以看到歸檔已經開了

rac 恢復到單實例

rac 恢復到單實例

8:catalog 全備

crosscheck backupset; 掃描

由於在原庫服務器上掛載目錄是/DBbak,必須在240上設置掛載目錄不一致。否則在還原的時候會找最新的備份。因為我們不知道表刪除的具體時間,最好排除最新的備份。240服務器上掛載目錄不一致,這樣備份就都無效,我們來手動制定備份集。

delete expired backupset;刪除失效備份

重新掃描之後沒有了。

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6537_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6538_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6539_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6540_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6541_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6542_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6543_1';

catalog backuppiece '/oradata/backup/oracle/orcl/fullbackup/FULLBAK_ORCL_20150830_6544_1';

rac 恢復到單實例

rac 恢復到單實例

rac 恢復到單實例

9:還原數據文件

select file_name,file_id,'set newname for datafile ' file_id ' to '''

replace(file_name,'+DATA/orclrestore/datafile/','/oradata/240/oradata/') ''' ;'

from dba_data_files order by file_id;

連接到原庫

run{

allocate channel d1 type disk;

allocate channel d2 type disk;

allocate channel d3 type disk;

allocate channel d4 type disk;

allocate channel d5 type disk;

allocate channel d6 type disk;

allocate channel d7 type disk;

allocate channel d8 type disk;

set newname for datafile 1 to '/oradata/240/oradata/system01.dbf' ;

set newname for datafile 2 to '/oradata/240/oradata/sysaux01.dbf' ;

。。。。。。。。

set newname for datafile 73 to '/oradata/240/oradata/datafile68.dbf' ;

restore database;

switch datafile all;

release channel d1;

release channel d2;

release channel d3;

release channel d4;

release channel d5;

release channel d6;

release channel d7;

release channel d8;

}

有多少個備份就開多少個進程,加快速度

rac 恢復到單實例

rac 恢復到單實例

10:catalog歸檔備份並recover數據庫

catalog backuppiece '/oradata/backup/oracle/orcl/archbackup/ARCHBAK_ORCL_20150830_6546_1';

catalog backuppiece '/oradata/backup/oracle/orcl/archbackup/ARCHBAK_ORCL_20150830_6547_1';

catalog backuppiece '/oradata/backup/oracle/orcl/archbackup/ARCHBAK_ORCL_20150830_6548_1';

catalog backuppiece '/oradata/backup/oracle/orcl/archbackup/ARCHBAK_ORCL_20150830_6549_1';

catalog backuppiece '/oradata/backup/oracle/orcl/archbackup/ARCHBAK_ORCL_20150830_6550_1';

catalog backuppiece '/oradata/backup/oracle/orcl/archbackup/ARCHBAK_ORCL_20150830_6551_1';

只需要到30號的就行。

然後recover database

rac 恢復到單實例

11:刪除多餘日誌文件

select 'alter database drop logfile group ' group# ' ;' from v$logfile;最後會自動留下兩組

ORA-01567: dropping log 36 would leave less than 2 log files for instance orcl

Member名稱無法確定,只能先增加然後再刪除。

rac 恢復到單實例

rac 恢復到單實例

rac 恢復到單實例

12:trace控制文件

編輯文件 controlbk1.sql

CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS NOARCHIVELOG

MAXLOGFILES 40

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 19451

LOGFILE

GROUP 1 '/oradata/240/oradata/redo01.log' SIZE 20M BLOCKSIZE 512,

GROUP 2 '/oradata/240/oradata/redo02.log' SIZE 20M BLOCKSIZE 512

DATAFILE

'/oradata/240/oradata/system01.dbf',

'/oradata/240/oradata/sysaux01.dbf',

。。。。。。。。。。。。。。。。

'/oradata/240/oradata/datafile68.dbf'

CHARACTER SET ZHS16CGB231280;

控制文件創建成功之後,數據庫自動會被mount。

啟動數據庫還是報錯:

ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled

Details: ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled. Oracle bug, 4355382 ORA-38856: FAILED TO OPEN DATABASE WITH RESETLOGS WHEN USING RAC BACKUP, exists in the Oracle 10g release 2.0 that affects backups taken from a RAC database. The problem is related to the number of threads used by the source database and an expectation that the cloned database must have an identical number of threads.

解決辦法:

給thread 2添加日誌組,然後刪除。

ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 3 '/oradata/240/oradata/redo03.log' SIZE 10M REUSE;

ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 4 '/oradata/240/oradata/redo04.log' SIZE 10M REUSE;

SQL> alter database open resetlogs;

SQL> alter database disable thread 2;

SQL> alter database drop logfile group 3;

SQL> alter database drop logfile group 4;

rac 恢復到單實例

rac 恢復到單實例

rac 恢復到單實例

rac 恢復到單實例

相關問題答案