12c RAC 用Rman 恢复到异机单实例

准备工作

原服务器软件部署:Redhat 6.6 + Oracle 12.2.0.1 rac

Oracle12c单实例安装

1、创建恢复服务器,设置大于原库数据大小的磁盘容量。设置相同的服务器主机名参照原服务器系统及软件版本和位数配置恢复的服务器,避免恢复过程中版本差异导致的问题;

2、将rman数据文件备份、归档日志备份复制到恢复服务器中( rman备份最好制定备份位置为NFS等共享存储上,还原时可以省去传递备份的时间);

3、创建相关的目录

例如,目标服务器安装ORACLE实例时,选择了“只安装实例”选项,那么在RMAN还原之前,我们必须创建下面一些目录(这些不是必须的,有些环境甚至完全不必要。具体根据实际情况判断):

  •  创建$ORACLE_BASE/admin/$ORACLE_SID/下的六个目录;
  • $ORACLE_BASE/oradata下创建$ORACLE_SID目录;
  •  RMAN备份路径目录(这个地方最好与源数据库一致,创建好后,把源数据库备份的数据文件复制到这个目录里);--非必须。
  •  归档日志目录(同样,创建好后,把需要的归档日志文件复制到此目录) --非必须。

 

#mkdir -p /u01/app/oracle/admin/gnnt2/{adump,bdump,cdump,dpdump,pfile,udump}
#mkdir -p /u01/app/oracle/oradata/$ORACLE_SID

注意:这些工作是前期准备工作,不能到RMAN还原恢复的时候才做。

服务器A备份数据库

 rman备份脚本

 原库数据较大,为了节约备份空间,采用增量备份。有关增量备份的概念转至我的博文https://www.cnblogs.com/-abm/p/9963917.html

 计划任务

[oracle@swnode2 /]$ crontab -l
10 0 * * 0 /bin/sh /home/oracle/rmanbackup0.sh
10 0 * * 1 /bin/sh /home/oracle/rmanbackup1.sh
10 0 * * 2 /bin/sh /home/oracle/rmanbackup1.sh
10 0 * * 3 /bin/sh /home/oracle/rmanbackup2.sh
10 0 * * 4 /bin/sh /home/oracle/rmanbackup1.sh
10 0 * * 5 /bin/sh /home/oracle/rmanbackup1.sh
10 0 * * 6 /bin/sh /home/oracle/rmanbackup1.sh
说明: 每周日凌晨执行0级全量备份,
      每周三凌晨执行一次累计增量备份,其他时间都为差异增量备份

0级备份

[oracle@swnode2 ~]$ cat rmanbackup0.sh
#!/bin/bash
#Creation: 2018-11-27
#Version: 1.0.0
export ORACLE_SID=gnnt2
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH

DATE=`date +%Y-%m-%d`
LOG=/home/oracle/logs/log_rman_0_$DATA

echo "=================================================================================" 
>>$LOG
echo "Begin backup at : `date`" >> $LOG
rman target / <> $LOG

run
{
allocate channel c1 device type disk;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/DBback/%d.%F.conf';
backup as compressed backupset incremental level 0 database format '/DBback/0_%d_pdb_shwjs_%T_%s_%p.DBFILE';
crosscheck backup;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up format '/DBback/arch_bak/arch_%d_%T_%s_%p.ACR';
crosscheck archivelog all;
report obsolete;
delete noprompt expired backup;
delete noprompt obsolete;
DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-8';
delete noprompt backup of archivelog all completed before 'sysdate-8';
release channel c1;
}
exit
EOF
echo "End backup at : `date`" >>$LOG

#echo "Begin scp at : `date`" >>$LOG
#scp ${
      1}/*`date +%Y%m%d`* [email protected]:/tmp/
#echo "End scp at : `date`" >>$LOG
echo "=================================================================================" >>$LOG

exit 0

1级备份(差异增量)

[oracle@swnode2 ~]$ cat rmanbackup1.sh
#!/bin/bash
#Creation: 2018-11-27
#Version: 1.0.0
export ORACLE_SID=gnnt2
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH

DATE=`date +%Y-%m-%d`
LOG=/home/oracle/logs/log_rman_1_$DATA

echo "=================================================================================" 
>>$LOG
echo "Begin backup at : `date`" >> $LOG
rman target / <> $LOG

run
{
allocate channel c1 device type disk;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/DBback/%d.%F.conf';
backup as compressed backupset incremental level 1 database format '/DBback/1_%d_pdb_shwjs_%T_%s_%p.DBFILE';
crosscheck backup;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up format '/DBback/arch_bak/arch_%d_%T_%s_%p.ACR';
crosscheck archivelog all;
report obsolete;
delete noprompt expired backup;
delete noprompt obsolete;
DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-8';
delete noprompt backup of archivelog all completed before 'sysdate-8';
release channel c1;
}
exit
EOF
echo "End backup at : `date`" >>$LOG

#echo "Begin scp at : `date`" >>$LOG
#scp ${
      1}/*`date +%Y%m%d`* [email protected]:/tmp/
#echo "End scp at : `date`" >>$LOG
echo "=================================================================================" >>$LOG

exit 0

 

2级备份(累计增量)

[oracle@swnode2 ~]$ cat rmanbackup2.sh
#!/bin/bash
#Creation: 2018-11-27
#Version: 1.0.0
export ORACLE_SID=gnnt2
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH

DATE=`date +%Y-%m-%d`
LOG=/home/oracle/logs/log_rman_0_$DATA

echo "=================================================================================" 
>>$LOG
echo "Begin backup at : `date`" >> $LOG
rman target / <> $LOG

run
{
allocate channel c1 device type disk;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/DBback/%d.%F.conf';
backup as compressed backupset incremental level 1 cumulative database format '/DBback/2_%d_pdb_shwjs_%T_%s_%p.DBFILE';
crosscheck backup;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up format '/DBback/arch_bak/arch_%d_%T_%s_%p.ACR';
crosscheck archivelog all;
report obsolete;
delete noprompt expired backup;
delete noprompt obsolete;
DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-8';
delete noprompt backup of archivelog all completed before 'sysdate-8';
release channel c1;
}
exit
EOF
echo "End backup at : `date`" >>$LOG

#echo "Begin scp at : `date`" >>$LOG
#scp ${
      1}/*`date +%Y%m%d`* [email protected]:/tmp/
#echo "End scp at : `date`" >>$LOG
echo "=================================================================================" >>$LOG

exit 0

 

RMAN恢复过程

A数据库为要被还原的数据库,B数据库为Rman还原库

拷贝A数据库服务器上的pfile至B并修改

建议备份恢复前提前准备好恢复数据库上pfile,具体方法如下

1、获取原库的pfile,并修改


SQL> create pfile='/RmanBackup/init.ora' from spfile;
文件已创建。

将pfile文件复制到恢复主机上,
修改其中的部分配置为备库的具体值。主要修改数据存储路径(红色标识),创建修改后的路径,与配置文件对应

#cd /u01/app/oracle/product/12.2.0/db_1/dbs/

 
    
[oracle@swnode2 dbs]$ cat initgnnt2.ora
gnnt1.__data_transfer_cache_size=0
gnnt2.__data_transfer_cache_size=0
gnnt2.__db_cache_size=39594229760
gnnt1.__db_cache_size=39325794304
gnnt1.__inmemory_ext_roarea=0 gnnt2.__inmemory_ext_roarea=0 gnnt1.__inmemory_ext_rwarea=0 gnnt2.__inmemory_ext_rwarea=0 gnnt1.__java_pool_size=805306368 gnnt2.__java_pool_size=671088640 gnnt1.__large_pool_size=939524096 gnnt2.__large_pool_size=805306368 gnnt1.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment gnnt2.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment gnnt1.__pga_aggregate_target=13824425984 gnnt2.__pga_aggregate_target=13824425984 gnnt1.__sga_target=55029268480 gnnt2.__sga_target=55029268480 gnnt1.__shared_io_pool_size=536870912 gnnt2.__shared_io_pool_size=0 gnnt2.__shared_pool_size=13824425984 gnnt1.__shared_pool_size=13287555072 gnnt1.__streams_pool_size=0 gnnt2.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/gnnt/adump' *.audit_trail='NONE' *.cluster_database=false #单实例故使用false *.compatible='12.2.0' *.control_file_record_keep_time=15 *.control_files='/data/conf_dir/current.261.972470897' *.db_block_size=8192 *.db_create_file_dest='/u01/app/oracle/oradata' *.db_name='gnnt' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=gnntXDB)' *.enable_pluggable_database=true family:dw_helper.instance_mode='read-only' gnnt2.instance_number=2 gnnt1.instance_number=1 *.local_listener='-oraagent-dummy-' *.log_archive_dest_1='LOCATION=/u01/app/oracle/acfs_arch' *.log_archive_format='%t_%s_%r.dbf' *.nls_language='SIMPLIFIED CHINESE' *.nls_territory='CHINA' *.open_cursors=300 *.pga_aggregate_target=13107m *.processes=15000 *.remote_login_passwordfile='exclusive' *.sga_target=52428m gnnt2.thread=2 gnnt1.thread=1 gnnt1.undo_tablespace='UNDOTBS1' gnnt2.undo_tablespace='UNDOTBS2'

2、rman下用修改后的pfile启动至nomount状态,恢复控制文件

RMAN> startup nomount pfile='/u01/app/oracle/product/12.2.0/db_1/dbs/initgnnt2.ora';
Oracle instance started
Total System Global Area 2483027968 bytes
Fixed Size 8795808 bytes
Variable Size 671091040 bytes
Database Buffers 1795162112 bytes
Redo Buffers 7979008 bytes

恢复控制文件(这一步必须nomount状态)

RMAN> restore controlfile from '/data/conf_ORCL_c-1508459345-20181125-00';

Starting restore at 25-NOV-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=8 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/racdb11/current.256.980678617
output file name=/u01/app/oracle/oradata/racdb11/current.257.980678613
Finished restore at 25-NOV-18

3、启动到mount状态,恢复数据库

RMAN> alter database mount;

Statement processed
released channel: ORA_DISK_1


5、注册备份目录到控制文件,-----------把拷贝过来的备份文件目录注册到控制文件,告诉控制文件我的备份在这个目录

RMAN> CATALOG START WITH '/DBback/';

 

restore还原数据库文件

1、修改数据文件位置

由于RAC用的是ASM存储管理的,现在是本地文件,需要修改数据文件名所以要newname一下
使用以下语句查出来所有的数据文件,改为本地文件名字

SQL>select 'SET NEWNAME FOR DATAFILE '|| file# ||' to ' ||''''|| name ||''''|| ';' from v$datafile;

查询到的结果修改,去掉SQL格式,修改正确的路径。

rman下 run{}中执行还原

 

run{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
SET NEWNAME FOR DATAFILE 1 to '/u01/app/oracle/oradata/DATAFILE/system.257.972470727';
SET NEWNAME FOR DATAFILE 3 to '/u01/app/oracle/oradata/DATAFILE/sysaux.258.972470787';
SET NEWNAME FOR DATAFILE 4 to '/u01/app/oracle/oradata/DATAFILE/undotbs1.259.972470823';
SET NEWNAME FOR DATAFILE 5 to '/u01/app/oracle/oradata/4700A987085B3DFAE05387E5E50A8C7B/DATAFILE/system.270.972471005';
SET NEWNAME FOR DATAFILE 6 to '/u01/app/oracle/oradata/4700A987085B3DFAE05387E5E50A8C7B/DATAFILE/sysaux.269.972471005';
SET NEWNAME FOR DATAFILE 7 to '/u01/app/oracle/oradata/DATAFILE/users.260.972470825';
SET NEWNAME FOR DATAFILE 8 to '/u01/app/oracle/oradata/4700A987085B3DFAE05387E5E50A8C7B/DATAFILE/undotbs1.271.972471005';
SET NEWNAME FOR DATAFILE 9 to '/u01/app/oracle/oradata/DATAFILE/undotbs2.273.972471285';
SET NEWNAME FOR DATAFILE 10 to '/u01/app/oracle/oradata/68E9F82A20250D37E053650DA8C0828F/DATAFILE/system.282.972471893';
SET NEWNAME FOR DATAFILE 11 to '/u01/app/oracle/oradata/68E9F82A20250D37E053650DA8C0828F/DATAFILE/sysaux.283.972471893';
SET NEWNAME FOR DATAFILE 12 to '/u01/app/oracle/oradata/68E9F82A20250D37E053650DA8C0828F/DATAFILE/undotbs1.281.972471893';
SET NEWNAME FOR DATAFILE 13 to '/u01/app/oracle/oradata/68E9F82A20250D37E053650DA8C0828F/DATAFILE/undo_2.285.972471941';
SET NEWNAME FOR DATAFILE 14 to '/u01/app/oracle/oradata/68E9F82A20250D37E053650DA8C0828F/DATAFILE/users.286.972471947';
SET NEWNAME FOR DATAFILE 21 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/system.292.972569467';
SET NEWNAME FOR DATAFILE 22 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/sysaux.293.972569467';
SET NEWNAME FOR DATAFILE 23 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/undotbs1.291.972569465';
SET NEWNAME FOR DATAFILE 24 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.289.973098773';
SET NEWNAME FOR DATAFILE 25 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.287.973099325';
SET NEWNAME FOR DATAFILE 26 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.288.973099375';
SET NEWNAME FOR DATAFILE 27 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.290.973099407';
SET NEWNAME FOR DATAFILE 28 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/undo_2.295.974139333';
SET NEWNAME FOR DATAFILE 29 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users05.dbf';
SET NEWNAME FOR DATAFILE 30 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users06.dbf';
SET NEWNAME FOR DATAFILE 31 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users07.dbf';
SET NEWNAME FOR DATAFILE 32 to '/u01/app/oracle/oradata/DATAFILE/system01.dbf';
SET NEWNAME FOR DATAFILE 33 to '/u01/app/oracle/oradata/DATAFILE/sysaux.dbf';
SET NEWNAME FOR DATAFILE 34 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 35 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users08.dbf';
SET NEWNAME FOR DATAFILE 36 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users09.dbf';
SET NEWNAME FOR DATAFILE 37 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users10.dbf';
SET NEWNAME FOR DATAFILE 38 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users11.dbf';
SET NEWNAME FOR DATAFILE 39 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.306.997209999';
SET NEWNAME FOR DATAFILE 40 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.307.1000716387';
SET NEWNAME FOR DATAFILE 41 to '/u01/app/oracle/oradata/6900B0297CC66549E053650DA8C0B038/DATAFILE/users.308.1000717873';
restore database;
switch datafile all;
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
内容较多,点击展开

 

recover database

这里有以下几种不完全恢复方式

1、恢复到问题时间点

[oracle@swnode2 oradata]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
[oracle@swnode2 oradata]$ rman target /


Recovery Manager: Release 12.2.0.1.0 - Production on Sun Nov 25 17:22:19 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=1508459345, not open)



RMAN> recover database until time '2018-11-27 19:00:00';
----------------------------------------------------------------------------------------------------------------------
也可以
RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> recover database until time '2018-11-27 19:00:00';
 
   

 2、恢复到指定scn

 也可以基于scn恢复,如何获取归档日志最后的scn号呢?

这个scn根据在rman下通过查看备份集详情获得

RMAN>list backupset;
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
1774    4.42G      DISK        00:21:42     27-NOV-18
        BP Key: 1774   Status: AVAILABLE  Compressed: YES  Tag: TAG20181127T033133
        Piece Name: /DBback/arch_bak/arch_GNNT_20181127_1834_1.ACR

  List of Archived Logs in backup set 1774
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    3570    623133533  26-NOV-18 623144627  26-NOV-18
  1    3571    623144627  26-NOV-18 623144743  26-NOV-18
  1    3572    623144743  26-NOV-18 623144838  26-NOV-18
  1    3573    623144838  26-NOV-18 623144954  26-NOV-18
  1    3574    623144954  26-NOV-18 624000290  26-NOV-18
  1    3575    624000290  26-NOV-18 624137326  26-NOV-18
  1    3576    624137326  26-NOV-18 624182658  26-NOV-18
  1    3577    624182658  26-NOV-18 624466466  26-NOV-18
  1    3578    624466466  26-NOV-18 624648532  26-NOV-18
  1    3579    624648532  26-NOV-18 624811743  26-NOV-18
  1    3580    624811743  26-NOV-18 624898678  26-NOV-18
  1    3581    624898678  26-NOV-18 626225424  26-NOV-18
  1    3582    626225424  26-NOV-18 626528280  26-NOV-18
  1    3583    626528280  26-NOV-18 626552079  26-NOV-18
  1    3584    626552079  26-NOV-18 626796446  27-NOV-18
  1    3585    626796446  27-NOV-18 626801478  27-NOV-18
  1    3586    626801478  27-NOV-18 626947222  27-NOV-18
  2    2919    623133510  26-NOV-18 623144658  26-NOV-18
  2    2920    623144658  26-NOV-18 623144693  26-NOV-18
  2    2921    623144693  26-NOV-18 623144786  26-NOV-18
  2    2922    623144786  26-NOV-18 623144889  26-NOV-18
  2    2923    623144889  26-NOV-18 623627321  26-NOV-18
  2    2924    623627321  26-NOV-18 624141400  26-NOV-18
  2    2925    624141400  26-NOV-18 624652859  26-NOV-18
  2    2926    624652859  26-NOV-18 626211462  26-NOV-18
  2    2927    626211462  26-NOV-18 626223272  26-NOV-18
  2    2928    626223272  26-NOV-18 626225370  26-NOV-18
  2    2929    626225370  26-NOV-18 626234325  26-NOV-18
  2    2930    626234325  26-NOV-18 626290700  26-NOV-18
  2    2931    626290700  26-NOV-18 626528251  26-NOV-18
  2    2932    626528251  26-NOV-18 626535138  26-NOV-18
  2    2933    626535138  26-NOV-18 626542328  26-NOV-18
  2    2934    626542328  26-NOV-18 626550432  26-NOV-18
  2    2935    626550432  26-NOV-18 626560723  26-NOV-18
  2    2936    626560723  26-NOV-18 626586366  26-NOV-18
  2    2937    626586366  26-NOV-18 626844113  27-NOV-18
  2    2938    626844113  27-NOV-18 626947203  27-NOV-18

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1775    Full    20.53M     DISK        00:00:01     27-NOV-18
        BP Key: 1775   Status: AVAILABLE  Compressed: NO  Tag: TAG20181127T035320
        Piece Name: /DBback/GNNT.c-1283969136-20181127-00.conf
  SPFILE Included: Modification time: 26-NOV-18
  SPFILE db_unique_name: GNNT
  Control File Included: Ckp SCN: 626964005    Ckp time: 27-NOV-18

 基于scn的恢复命令

RMAN>recover database until scn=626964005;
RMAN> recover database until scn=626844113;

Starting recover at 2018-11-28 08:37:15
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00021: /data/oradata/system.292.972569467
destination for restore of datafile 00022: /data/oradata/sysaux.293.972569467
destination for restore of datafile 00023: /data/oradata/undotbs1.291.972569465
destination for restore of datafile 00024: /data/oradata/users.289.973098773
destination for restore of datafile 00025: /data/oradata/users.287.973099325
destination for restore of datafile 00026: /data/oradata/users.288.973099375
destination for restore of datafile 00027: /data/oradata/users.290.973099407
destination for restore of datafile 00028: /data/oradata/undo_2.295.974139333
destination for restore of datafile 00029: /data/oradata/users05.dbf
destination for restore of datafile 00030: /data/oradata/users06.dbf
destination for restore of datafile 00031: /data/oradata/users07.dbf
destination for restore of datafile 00034: /data/oradata/sysaux01.dbf
destination for restore of datafile 00035: /data/oradata/users08.dbf
destination for restore of datafile 00036: /data/oradata/users09.dbf
destination for restore of datafile 00037: /data/oradata/users10.dbf
destination for restore of datafile 00038: /data/oradata/users11.dbf
channel ORA_DISK_1: reading from backup piece /DBback/1_GNNT_pdb_shwjs_20181126_1824_1.DBFILE
channel ORA_DISK_1: errors found reading piece handle=/DBback/1_GNNT_pdb_shwjs_20181126_1824_1.DBFILE
channel ORA_DISK_1: failover to piece handle=/data/1_GNNT_pdb_shwjs_20181126_1824_1.DBFILE tag=TAG20181126T001008
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:18:46
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /data/oradata/system.257.972470727
destination for restore of datafile 00003: /data/oradata/sysaux.258.972470787
destination for restore of datafile 00004: /data/oradata/undotbs1.259.972470823
destination for restore of datafile 00007: /data/oradata/users.260.972470825
destination for restore of datafile 00009: /data/oradata/undotbs2.273.972471285
destination for restore of datafile 00032: /data/oradata/system01.dbf
destination for restore of datafile 00033: /data/oradata/sysaux.dbf
channel ORA_DISK_1: reading from backup piece /DBback/1_GNNT_pdb_shwjs_20181126_1825_1.DBFILE
channel ORA_DISK_1: errors found reading piece handle=/DBback/1_GNNT_pdb_shwjs_20181126_1825_1.DBFILE
channel ORA_DISK_1: failover to piece handle=/data/1_GNNT_pdb_shwjs_20181126_1825_1.DBFILE tag=TAG20181126T001008
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:10:26
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00023: /data/oradata/undotbs1.291.972569465
destination for restore of datafile 00028: /data/oradata/undo_2.295.974139333
destination for restore of datafile 00034: /data/oradata/sysaux01.dbf
destination for restore of datafile 00036: /data/oradata/users09.dbf
destination for restore of datafile 00037: /data/oradata/users10.dbf
destination for restore of datafile 00038: /data/oradata/users11.dbf
channel ORA_DISK_1: reading from backup piece /DBback/1_GNNT_pdb_shwjs_20181127_1830_1.DBFILE
channel ORA_DISK_1: errors found reading piece handle=/DBback/1_GNNT_pdb_shwjs_20181127_1830_1.DBFILE
channel ORA_DISK_1: failover to piece handle=/data/1_GNNT_pdb_shwjs_20181127_1830_1.DBFILE tag=TAG20181127T001010
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:22:46

starting media recovery

archived log for thread 1 with sequence 3585 is already on disk as file /data/acfs_arch/1_3585_972470900.dbf
archived log for thread 1 with sequence 3586 is already on disk as file /data/acfs_arch/1_3586_972470900.dbf
archived log for thread 2 with sequence 2937 is already on disk as file /data/acfs_arch/2_2937_972470900.dbf
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2917
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3567
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3568
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3569
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2918
channel ORA_DISK_1: reading from backup piece /DBback/arch_bak/arch_GNNT_20181126_1828_1.ACR
channel ORA_DISK_1: errors found reading piece handle=/DBback/arch_bak/arch_GNNT_20181126_1828_1.ACR
channel ORA_DISK_1: failover to piece handle=/data/arch_bak/arch_GNNT_20181126_1828_1.ACR tag=TAG20181126T030616
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:06:05
archived log file name=/data/acfs_arch/2_2917_972470900.dbf thread=2 sequence=2917
archived log file name=/data/acfs_arch/1_3567_972470900.dbf thread=1 sequence=3567
archived log file name=/data/acfs_arch/1_3568_972470900.dbf thread=1 sequence=3568
archived log file name=/data/acfs_arch/1_3569_972470900.dbf thread=1 sequence=3569
archived log file name=/data/acfs_arch/2_2918_972470900.dbf thread=2 sequence=2918
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2919
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3570
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3571
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2920
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2921
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3572
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2922
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3573
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2923
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3574
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2924
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3575
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3576
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2925
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3577
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3578
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3579
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2926
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3580
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3581
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2927
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2928
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2929
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3582
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2930
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2931
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2932
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3583
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2933
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2934
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2935
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3584
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=2936
channel ORA_DISK_1: reading from backup piece /DBback/arch_bak/arch_GNNT_20181127_1834_1.ACR
channel ORA_DISK_1: errors found reading piece handle=/DBback/arch_bak/arch_GNNT_20181127_1834_1.ACR
channel ORA_DISK_1: failover to piece handle=/data/arch_bak/arch_GNNT_20181127_1834_1.ACR tag=TAG20181127T033133
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:22:26
archived log file name=/data/acfs_arch/2_2919_972470900.dbf thread=2 sequence=2919
archived log file name=/data/acfs_arch/1_3570_972470900.dbf thread=1 sequence=3570
archived log file name=/data/acfs_arch/1_3571_972470900.dbf thread=1 sequence=3571
archived log file name=/data/acfs_arch/2_2920_972470900.dbf thread=2 sequence=2920
archived log file name=/data/acfs_arch/2_2921_972470900.dbf thread=2 sequence=2921
archived log file name=/data/acfs_arch/1_3572_972470900.dbf thread=1 sequence=3572
archived log file name=/data/acfs_arch/2_2922_972470900.dbf thread=2 sequence=2922
archived log file name=/data/acfs_arch/1_3573_972470900.dbf thread=1 sequence=3573
archived log file name=/data/acfs_arch/2_2923_972470900.dbf thread=2 sequence=2923
archived log file name=/data/acfs_arch/1_3574_972470900.dbf thread=1 sequence=3574
archived log file name=/data/acfs_arch/2_2924_972470900.dbf thread=2 sequence=2924
archived log file name=/data/acfs_arch/1_3575_972470900.dbf thread=1 sequence=3575
archived log file name=/data/acfs_arch/1_3576_972470900.dbf thread=1 sequence=3576
archived log file name=/data/acfs_arch/2_2925_972470900.dbf thread=2 sequence=2925
archived log file name=/data/acfs_arch/1_3577_972470900.dbf thread=1 sequence=3577
archived log file name=/data/acfs_arch/1_3578_972470900.dbf thread=1 sequence=3578
archived log file name=/data/acfs_arch/1_3579_972470900.dbf thread=1 sequence=3579
archived log file name=/data/acfs_arch/2_2926_972470900.dbf thread=2 sequence=2926
archived log file name=/data/acfs_arch/1_3580_972470900.dbf thread=1 sequence=3580
archived log file name=/data/acfs_arch/1_3581_972470900.dbf thread=1 sequence=3581
archived log file name=/data/acfs_arch/2_2927_972470900.dbf thread=2 sequence=2927
archived log file name=/data/acfs_arch/2_2928_972470900.dbf thread=2 sequence=2928
archived log file name=/data/acfs_arch/2_2929_972470900.dbf thread=2 sequence=2929
archived log file name=/data/acfs_arch/1_3582_972470900.dbf thread=1 sequence=3582
archived log file name=/data/acfs_arch/2_2930_972470900.dbf thread=2 sequence=2930
archived log file name=/data/acfs_arch/2_2931_972470900.dbf thread=2 sequence=2931
archived log file name=/data/acfs_arch/2_2932_972470900.dbf thread=2 sequence=2932
archived log file name=/data/acfs_arch/1_3583_972470900.dbf thread=1 sequence=3583
archived log file name=/data/acfs_arch/2_2933_972470900.dbf thread=2 sequence=2933
archived log file name=/data/acfs_arch/2_2934_972470900.dbf thread=2 sequence=2934
archived log file name=/data/acfs_arch/2_2935_972470900.dbf thread=2 sequence=2935
archived log file name=/data/acfs_arch/1_3584_972470900.dbf thread=1 sequence=3584
archived log file name=/data/acfs_arch/2_2936_972470900.dbf thread=2 sequence=2936
archived log file name=/data/acfs_arch/2_2937_972470900.dbf thread=2 sequence=2937
archived log file name=/data/acfs_arch/1_3585_972470900.dbf thread=1 sequence=3585
archived log file name=/data/acfs_arch/1_3586_972470900.dbf thread=1 sequence=3586
media recovery complete, elapsed time: 02:18:38
Finished recover at 2018-11-28 12:18:32
点击展开

 3、12c新特性还原

RMAN 自动恢复到 REDO 终点的步骤简化

语法如下

RMAN> RECOVER DATABASE UNTIL AVAILABLE REDO;    //限制:只针对全库恢复使用这个命令

 

还原后的调整

修改数据库redo log位置,可根据下面sql查询出来的结果,将asm位置修改为正确目录

SQL> select 'alter database rename file '''||member||q'[' to '/u01/app/oracle/fast_recovery_area/redo';]' from v$logfile;   
//需创建红色标识目录
 将查询到的结果修改redo后面的编号,进行执行
alter database rename file '+DATA/GNNT/ONLINELOG/group_8.267.972470901' to '/u01/app/oracle/fast_recovery_area/redo1';
alter database rename file '+DATA/GNNT/ONLINELOG/group_7.266.972470901' to '/u01/app/oracle/fast_recovery_area/redo2';
alter database rename file '+DATA/GNNT/ONLINELOG/group_6.265.972470901' to '/u01/app/oracle/fast_recovery_area/redo3';
alter database rename file '+DATA/GNNT/ONLINELOG/group_5.264.972470901' to '/u01/app/oracle/fast_recovery_area/redo4';
alter database rename file '+DATA/GNNT/ONLINELOG/group_2.263.972470901' to '/u01/app/oracle/fast_recovery_area/redo5';
alter database rename file '+DATA/GNNT/ONLINELOG/group_1.262.972470901' to '/u01/app/oracle/fast_recovery_area/redo6';
alter database rename file '+DATA/GNNT/ONLINELOG/group_3.274.972471515' to '/u01/app/oracle/fast_recovery_area/redo7';
alter database rename file '+DATA/GNNT/ONLINELOG/group_4.275.972471541' to '/u01/app/oracle/fast_recovery_area/redo8';
alter database rename file '+DATA/GNNT/ONLINELOG/group_9.276.972471563' to '/u01/app/oracle/fast_recovery_area/redo9';
alter database rename file '+DATA/GNNT/ONLINELOG/group_10.277.972471587' to '/u01/app/oracle/fast_recovery_area/redo10';
alter database rename file '+DATA/GNNT/ONLINELOG/group_11.278.972471609' to '/u01/app/oracle/fast_recovery_area/redo11';
alter database rename file '+DATA/GNNT/ONLINELOG/group_12.279.972471631' to '/u01/app/oracle/fast_recovery_area/redo12';

 

创建spfile:create spfile from pfile

 问题解决

完成后尝试打开数据库

可能问题1:
RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 11/25/2018 18:22:48
ORA-19751: could not create the change tracking file
ORA-19750: change tracking file: '+DATA/ORCL/CHANGETRACKING/ctf.282.992257129'
ORA-17502: ksfdcre:1 Failed to create file +DATA/ORCL/CHANGETRACKING/ctf.282.992257129
ORA-17501: logical block size 4294967295 is invalid
ORA-29701: ?????????????????
ORA-17503: ksfdopn:2 Failed to open file +DATA/ORCL/CHANGETRACKING/ctf.282.992257129
ORA-15001: diskgroup "DATA" does not exist or is not mounted
ORA-15374: invalid cluster configuration

问题解决https://blog.csdn.net/jaso5935/article/details/41117733

 可能问题2

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 7 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 7 thread 1:
'/data/u01/app/oracle/fast_recovery_area/ORCL/redo2'

解决链接:https://www.linuxidc.com/Linux/2014-11/108886.html

SQL> select group#,bytes/1024/1024||'M',status from v$log;

    GROUP# BYTES/1024/1024||'M'                      STATUS
---------- ----------------------------------------- ----------------
         1 800M                                      CLEARING
         2 800M                                      CLEARING
         6 800M                                      CLEARING
         8 800M                                      CLEARING
         7 800M                                      CLEARING_CURRENT
         5 800M                                      CLEARING
        10 800M                                      CLEARING
        11 800M                                      CLEARING_CURRENT
        12 800M                                      CLEARING
         9 800M                                      CLEARING
         4 800M                                      CLEARING

    GROUP# BYTES/1024/1024||'M'                      STATUS
---------- ----------------------------------------- ----------------
         3 800M                                      CLEARING

12 rows selected.

SQL> alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database clear logfile group 4;
alter database clear logfile group 5;
alter database clear logfile group 6;
alter database clear logfile group 7;
alter database clear logfile group 8;
alter database clear logfile group 9;
alter database clear logfile group 10;
alter database clear logfile group 11;
alter database clear logfile group 12;
Database altered.
SQL> select group#,bytes/1024/1024||'M',status from v$log;

    GROUP# BYTES/1024/1024||'M'                      STATUS
---------- ----------------------------------------- ----------------
         1 800M                                      UNUSED
         2 800M                                      UNUSED
         6 800M                                      UNUSED
         8 800M                                      UNUSED
         7 800M                                      CURRENT
         5 800M                                      UNUSED
        10 800M                                      UNUSED
        11 800M                                      CURRENT
        12 800M                                      UNUSED
         9 800M                                      UNUSED
         4 800M                                      UNUSED

    GROUP# BYTES/1024/1024||'M'                      STATUS
---------- ----------------------------------------- ----------------
         3 800M                                      UNUSED

12 rows selected.

SQL> alter database open resetlogs;

Database altered.
问题解决

 可能问题3:

RMAN> recover database until available redo;

Starting recover at 04-DEC-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5643 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/04/2018 20:28:24
ORA-19698: /u01/app/oracle/fast_recovery_area/ORCL/redo5 is from different database: id=1508459345, db_name=ORCL

问题解决

命令行删除报错的redo,后重新执行recover
[oracle@swnode2 ~]$ rm /u01/app/oracle/fast_recovery_area/ORCL/redo
redo/ redo1 redo2 redo3 redo4 redo5 redo7 redo8
[oracle@swnode2 ~]$ rm /u01/app/oracle/fast_recovery_area/ORCL/redo*

 

 

恢复完成!!!

恢复完成测试启动、关闭、查询、查看Oracle运行日志。

 

最后一步:远程连接配置监听

1、新恢复的数据库没有密码文件,我们需要手动创建

创建前查看到没有用户密码信息
SQL> select * from v$pwfile_users;

no rows selected

手动创建
[oracle@swnode2 dbs]$orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=xxxxxx force=y entries=5    //这里不创建密码文件的话sys用户登录会报 ORA-01017

2、注册监听

动态注册:

[oracle@swnode2 dbs]$ sqlplus sys/password@192.168.12.121:1521/gnnt  as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Dec 21 15:40:09 2018

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

Last Successful login time: Fri Dec 21 2018 15:32:46 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      gnnt

SQL> alter system set local_listener='';

System altered.

SQL> alter system register;

System altered.

SQL> quit

查看监听状态

[oracle@swnode2 dbs]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 21-DEC-2018 15:43:10

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-DEC-2018 11:29:53
Uptime                    0 days 4 hr. 13 min. 17 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/swnode2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=swnode2)(PORT=1521)))
Services Summary...
Service "68e9f82a20250d37e053650da8c0828f" has 1 instance(s).
  Instance "gnnt2", status READY, has 1 handler(s) for this service...
Service "6900b0297cc66549e053650da8c0b038" has 2 instance(s).
  Instance "gnnt2", status READY, has 2 handler(s) for this service...
  Instance "gnnt2", status READY, has 1 handler(s) for this service...
Service "gnnt" has 1 instance(s).
  Instance "gnnt2", status READY, has 1 handler(s) for this service...
Service "gnntXDB" has 1 instance(s).
  Instance "gnnt2", status READY, has 1 handler(s) for this service...
Service "gnntpdb01" has 1 instance(s).
  Instance "gnnt2", status READY, has 1 handler(s) for this service...
Service "pdb_shwjs" has 2 instance(s).
  Instance "gnnt2", status READY, has 2 handler(s) for this service...
  Instance "gnnt2", status READY, has 1 handler(s) for this service...
The command completed successfully

远程连接测试

 #sqlplus sys/psswd@IP:1521/sid  as sysdba

 

转载于:https://www.cnblogs.com/-abm/p/10024815.html

你可能感兴趣的:(数据库,网络,操作系统)