【12c 庫異機恢復】實驗
前面我做了 11g 異機恢復實驗(就是同一臺機器不同目錄的方式來模擬),本次實驗在 12c 的環境下完成異機的恢復工作。
1 、系統環境
作業系統: CentOS Linux release 7.7.1908
資料庫: Version 12.1.0.2.0
目錄變換
資料目錄: /oradata /oradata/orclnew
歸檔目錄: /archivelog /archivelognew
閃回目錄: /falsh_recovery /flash_recoverynew
2 、備份原庫( /home/oracle/backup )
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup as compressed backupset tag='full_backup' format '/home/oracle/backup/full_db_%U_%T' database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/backup/archivelog_%U_%T' delete all input;
backup current controlfile tag='ctl_file' format='/home/oracle/backup/ctl_file_%U_%T';
backup spfile tag='spfile' format='/home/oracle/backup/spfile_%U_%T';
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
[oracle@db1 backup]$ ll
total 649888
-rw-r----- 1 oracle oinstall 10382336 Jan 25 09:36 archivelog_0j0k5ho8_1_1_20220125
-rw-r----- 1 oracle oinstall 2560 Jan 25 09:36 archivelog_0k0k5ho8_1_1_20220125
-rw-r----- 1 oracle oinstall 17891328 Jan 25 09:36 ctl_file_0l0k5ho9_1_1_20220125
-rw-r----- 1 oracle oinstall 1073152 Jan 25 09:35 full_db_020k5hn2_1_1_20220125
-rw-r----- 1 oracle oinstall 159014912 Jan 25 09:35 full_db_030k5hn2_1_1_20220125
-rw-r----- 1 oracle oinstall 105201664 Jan 25 09:35 full_db_040k5hn2_1_1_20220125
-rw-r----- 1 oracle oinstall 1081344 Jan 25 09:35 full_db_050k5hn3_1_1_20220125
-rw-r----- 1 oracle oinstall 1105920 Jan 25 09:35 full_db_060k5hn3_1_1_20220125
-rw-r----- 1 oracle oinstall 1105920 Jan 25 09:35 full_db_070k5hn3_1_1_20220125
-rw-r----- 1 oracle oinstall 1105920 Jan 25 09:35 full_db_080k5hn4_1_1_20220125
-rw-r----- 1 oracle oinstall 64159744 Jan 25 09:35 full_db_090k5hn4_1_1_20220125
-rw-r----- 1 oracle oinstall 64159744 Jan 25 09:35 full_db_0a0k5hn4_1_1_20220125
-rw-r----- 1 oracle oinstall 64167936 Jan 25 09:35 full_db_0b0k5hnk_1_1_20220125
-rw-r----- 1 oracle oinstall 40525824 Jan 25 09:35 full_db_0c0k5hnk_1_1_20220125
-rw-r----- 1 oracle oinstall 40542208 Jan 25 09:35 full_db_0d0k5hnk_1_1_20220125
-rw-r----- 1 oracle oinstall 40525824 Jan 25 09:35 full_db_0e0k5hnn_1_1_20220125
-rw-r----- 1 oracle oinstall 53338112 Jan 25 09:36 full_db_0f0k5hnu_1_1_20220125
-rw-r----- 1 oracle oinstall 98304 Jan 25 09:36 spfile_0m0k5hoc_1_1_20220125
現狀:
SYS@orcl>select file_id,file_name,tablespace_name from cdb_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ------------------------------------------------------------ ------------------------------
1 /oradata/orcl/system01.dbf SYSTEM
3 /oradata/orcl/sysaux01.dbf SYSAUX
5 /oradata/orcl/undotbs1.dbf UNDOTBS1
6 /oradata/orcl/user01.dbf USERS
8 /oradata/orcl/pdb1/system01.dbf SYSTEM
9 /oradata/orcl/pdb1/sysaux01.dbf SYSAUX
10 /oradata/orcl/pdb1/user01.dbf USERS
11 /oradata/orcl/pdb1/data.dbf DATA
12 /oradata/orcl/pdb2/system01.dbf SYSTEM
13 /oradata/orcl/pdb2/sysaux01.dbf SYSAUX
14 /oradata/orcl/pdb2/user01.dbf USERS
11 rows selected.
SYS@orcl>select file_id,file_name,tablespace_name from cdb_temp_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ------------------------------------------------------------ ------------------------------
1 /oradata/orcl/temp01.dbf TEMP
4 /oradata/orcl/pdb2/temp01.dbf TEMP
3 /oradata/orcl/pdb1/temp01.dbf TEMP
3 、恢復到測試機
目標主機引數檔案
[oracle@db1 ~]$ cat 4.sql
orcl.__data_transfer_cache_size=0
orcl.__db_cache_size=956301312
orcl.__java_pool_size=16777216
orcl.__large_pool_size=33554432
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=738197504
orcl.__sga_target=1409286144
orcl.__shared_io_pool_size=67108864
orcl.__shared_pool_size=318767104
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='12.1.0'
*.control_files='/oradata/orclnew/control01.ctl','/oradata/orclnew/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/flash_recoverynew'
*.db_recovery_file_dest_size=10G
*.db_securefile='PREFERRED'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
*.enable_pluggable_database=true
*.log_archive_dest_1='location=/archivelognew'
*.memory_target=2G
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
建立檔案目錄
[root@db1 ~]# mkdir -p /oradata/orclnew /flash_recoverynew /archivelognew
[root@db1 ~]# chmod 775 /oradata/orclnew /flash_recoverynew /archivelognew -R
[root@db1 ~]# chown oracle:oinstall /oradata/orclnew /flash_recoverynew /archivelognew -R
[root@db1 ~]#cd /oradata/orclnew
[root@db1 orclnew]# mkdir -p pdbseed pdb1 pdb2
[root@db1 orclnew]# chmod 775 pdbseed pdb1 pdb2 -R
[root@db1 orclnew]# chown oracle:oinstall pdbseed pdb1 pdb2 -R
SYS@orcl>create spfile from pfile='/home/oracle/4.sql';
File created.
SYS@orcl>startup nomount;
ORACLE instance started.
Total System Global Area 2147483648 bytes
Fixed Size 2926472 bytes
Variable Size 1174407288 bytes
Database Buffers 956301312 bytes
Redo Buffers 13848576 bytes
恢復控制:
[oracle@db1 ~]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Jan 25 09:51:05 2022
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (not mounted)
RMAN> restore controlfile from '/home/oracle/backup/ctl_file_0l0k5ho9_1_1_20220125';
Starting restore at 25-JAN-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/orclnew/control01.ctl
output file name=/oradata/orclnew/control02.ctl
Finished restore at 25-JAN-22
[oracle@db1 oradata]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 25 09:52:40 2022
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@orcl>alter database mount;
Database altered.
恢復資料檔案:
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
set newname for datafile 1 to '/oradata/orclnew/pdb2/system01.dbf';
set newname for datafile 3 to '/oradata/orclnew/pdb2/sysaux01.dbf';
set newname for datafile 5 to '/oradata/orclnew/pdb2/user01.dbf ';
set newname for datafile 6 to '/oradata/orclnew/pdb1/system01.dbf';
set newname for datafile 8 to '/oradata/orclnew/pdb1/sysaux01.dbf';
set newname for datafile 9 to '/oradata/orclnew/pdb1/user01.dbf';
set newname for datafile 10 to '/oradata/orclnew/pdb1/data.dbf';
set newname for datafile 11 to '/oradata/orclnew/system01.dbf';
set newname for datafile 12 to '/oradata/orclnew/sysaux01.dbf';
set newname for datafile 13 to '/oradata/orclnew/undotbs1.dbf';
set newname for datafile 14 to '/oradata/orclnew/user01.dbf';
restore database;
switch datafile all;
recover database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
SYS@orcl>alter database open resetlogs;
SYS@orcl>show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTED
4 PDB2 MOUNTED
4 、檢查各項引數,確認是否正確
cdb pdb 臨時檔案 (新建 temp 檔案)
[oracle@db1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 25 10:42:58 2022
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@orcl>create temporary tablespace temp101 tempfile '/oradata/orclnew/temp101.dbf' size 200m autoextend on maxsize 2g;
SYS@orcl>alter database default temporary tablespace temp101;
SYS@orcl>conn sys/oracle@pdb1 as sysdba
SYS@pdb1>create temporary tablespace temp201 tempfile '/oradata/orclnew/temp201.dbf' size 200m autoextend on maxsize 2g;
SYS@pdb1>alter database default temporary tablespace temp201;
SYS@orcl>show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTED
4 PDB2 MOUNTED
SYS@orcl>select file_id,file_name,tablespace_name from cdb_temp_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ------------------------------------------------------------ ------------------------------
5 /oradata/orclnew/temp101.dbf TEMP101
redolog 檔案(新建 redolog )
alter database add logfile '/oradata/orclnew/redo10.log' size 50m;
alter database add logfile '/oradata/orclnew/redo11.log' size 50m;
alter database add logfile '/oradata/orclnew/redo12.log' size 50m;
pdbseed (發現恢復後 pdbseed 檔案為空,怎麼辦?)
cdb 啟動到 mount 狀態
alter database rename file '/oradata/orcl/pdbseed/sysaux01.dbf' to '/oradata/orclnew/pdbseed/sysaux01.dbf' ;
alter database rename file '/oradata/orcl/pdbseed/system01.dbf' to '/oradata/orclnew/pdbseed/system01.dbf' ;
alter database rename file '/oradata/orcl/pdbseed/temp01.dbf' to '/oradata/orclnew/pdbseed/temp01.dbf' ;
alter database rename file '/oradata/orcl/pdbseed/user01.dbf' to '/oradata/orclnew/pdbseed/user01.dbf' ;
刪除原有 redolog (透過切換 redolog )
alter system switch logfile;
alter system checkpoint;
alter database drop logfile to group 1;
alter database drop logfile to group 2;
alter database drop logfile to group 3;
SYS@orcl>select *from v$logfile;
GROUP# STATUS TYPE MEMBER IS_ CON_ID
---------- ------- ------- ------------------------------------------------------------ --- ----------
4 ONLINE /oradata/orclnew/redo10.log NO 0
5 ONLINE /oradata/orclnew/redo11.log NO 0
6 ONLINE /oradata/orclnew/redo12.log NO 0
測試建立 pdb 庫,檢查 pdbseed 是否可用:
SYS@orcl>show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 PDB2 READ WRITE NO
SYS@orcl>create pluggable database pdb3 admin user pdb3 identified by pdb3 file_name_convert=('/oradata/orclnew/pdbseed','/oradata/orclnew/pdb3/');
Pluggable database created.
SYS@orcl>show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 MOUNTED
SYS@orcl>alter pluggable database pdb3 open;
Pluggable database altered.
SYS@orcl>show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
SYS@orcl>select file_name from cdb_temp_files;
FILE_NAME
------------------------------------------------------------
/oradata/orclnew/temp301.dbf
/oradata/orclnew/temp101.dbf
/oradata/orclnew/temp201.dbf
/oradata/orclnew/pdb3/temp01.dbf
SYS@orcl>select file_name,tablespace_name from cdb_temp_files;
FILE_NAME TABLESPACE_NAME
------------------------------------------------------------ ------------------------------
/oradata/orclnew/temp101.dbf TEMP101
/oradata/orclnew/pdb3/temp01.dbf TEMP
/oradata/orclnew/temp301.dbf TEMP301
/oradata/orclnew/temp201.dbf TEMP201
總結:比起 11g 異機恢復, 12c 的異機恢復多了 pdbseed 種子庫的遷移,其他過程沒有區別。(注意:檢視整個庫中的檔案使用 cdb_data_files cdb_temp_files 檢視)
Yicheng16
22.01.25
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69963467/viewspace-2853869/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【11g 庫異地恢復】實驗
- 12C grid CDB異機恢復+歸檔(DDL操作)
- oracle 異機恢復Oracle
- Oracle Database 12c RAC損壞ocr和votedisk恢復實驗OracleDatabase
- RMAN備份異機恢復
- RMAN備份恢復典型案例——異機恢復未知DBID
- 兩篇oracle異機恢復文章Oracle
- rman備份異機恢復(原創)
- 【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(1)Oracle 10g
- 【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(2)Oracle 10g
- Oracle 12c 備份與恢復Oracle
- 表空間TSPITR恢復-實驗
- 【Oracle 恢復表空間】 實驗Oracle
- 透過搭建恢復目錄實現RMAN異地備份和恢復
- Oracle 12C新特性-RMAN恢復表Oracle
- oracle 12c 針對cdb的差異0備與對pdb進行恢復Oracle
- 【Oracle 12c資料庫支援閃回庫功能】實驗Oracle資料庫
- RMAN資料庫恢復異常報錯ORA-01180資料庫
- 異機使用完全備份恢復指定的PDB
- ORACLE 11.2.0.4 RAC RMAN異機恢復之ORA-15001Oracle
- 寶塔資料庫恢復 mysql資料庫丟失恢復 mysql資料庫刪除庫恢復 寶塔mysql資料庫恢復資料庫MySql
- DG同步異常恢復文件
- SQLServer異常故障恢復(二)SQLServer
- [20190718]12c rman新特性 表恢復.txt
- 【12c】12c RMAN新特性之recover table(表級別恢復)
- [20200309]資料庫異常關閉恢復的終點.txt資料庫
- 【12c】12c RMAN新特性之通過網路遠端恢復資料庫(RESTORE/Recover from Service)資料庫REST
- 實驗:centos6刪除核心並恢復CentOS
- 【北亞資料恢復】異常斷電導致Oracle資料庫報錯的oracle資料恢復資料恢復Oracle資料庫
- 【12c cdb pdb】實驗
- 【硬碟資料恢復】加電有異響的硬碟資料恢復硬碟資料恢復
- 【資料庫資料恢復】SAP資料庫資料恢復案例資料庫資料恢復
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 7_Oracle truncate異常恢復之plsql修復OracleSQL
- 6_Oracle truncate異常恢復之bbed修復Oracle
- sybase資料庫恢復資料庫
- OracleDG備庫恢復–gapOracle
- Oracle asm磁碟損壞異常恢復OracleASM