#关闭实例,切换为nomount状态:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 2471931904 bytes
Fixed Size 2255752 bytes
Variable Size 671089784 bytes
Database Buffers 1795162112 bytes
Redo Buffers 3424256 bytes
#进入rman:
[oracle@node1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri May 6 16:10:59 2022
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ZLHISCS (not mounted)
#恢复控制文件:
RMAN> restore controlfile from '/backup/rmanbak/cntrl_33_1_33';
Starting restore at 06-MAY-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 instance=ZLHISCS1 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=+DATA/zlhiscs/controlfile/current.272.1103216865
output file name=+ARCH/zlhiscs/controlfile/current.256.1103216865
Finished restore at 06-MAY-22
#启动到mount状态:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
#删除原备份
RMAN> delete noprompt expired backup;
Starting implicit crosscheck backup at 07-MAY-22
allocated channel: ORA_DISK_1
Crosschecked 33 objects
Finished implicit crosscheck backup at 07-MAY-22
#分类编目
RMAN> catalog start with '/backup/rmanbak/';
searching for all files that match the pattern /backup/rmanbak
List of Files Unknown to the Database
=====================================
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0ovrq9e5_1_1
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0rvrq9e5_1_1
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0pvrq9e5_1_1
File Name: /backup/rmanbak/arc_1069360622_32
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0qvrq9e5_1_1
File Name: /backup/rmanbak/cntrl_33_1_33
File Name: /backup/rmanbak/arc_1069360622_31
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0ovrq9e5_1_1
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0rvrq9e5_1_1
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0pvrq9e5_1_1
File Name: /backup/rmanbak/arc_1069360622_32
File Name: /backup/rmanbak/db_ZLHISCS_20210408_0qvrq9e5_1_1
File Name: /backup/rmanbak/cntrl_33_1_33
File Name: /backup/rmanbak/arc_1069360622_31
#恢复数据文件:
RMAN> run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
set newname for database to '+DATA';
restore database;
switch datafile all;
switch tempfile all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
datafile 23 switched to datafile copy
input datafile copy RECID=96 STAMP=1103996423 file name=+DATA/zlhiscs/datafile/zlbak2019.297.1103996287
datafile 24 switched to datafile copy
input datafile copy RECID=97 STAMP=1103996423 file name=+DATA/zlhiscs/datafile/zlmsgdata.287.1103996289
renamed tempfile 1 to +DATA in control file
renamed tempfile 2 to +DATA in control file
released channel: c1
released channel: c2
released channel: c3
released channel: c4
#redo重命名
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ZLHISCS/redo04.log
/u01/app/oracle/oradata/ZLHISCS/redo05.log
/u01/app/oracle/oradata/ZLHISCS/redo06.log
SQL> alter database rename file '/u01/app/oracle/oradata/ZLHISCS/redo04.log' to '+DATA/ZLHISCS/ONLINELOG/group_4';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ZLHISCS/redo05.log' to '+DATA/ZLHISCS/ONLINELOG/group_5';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ZLHISCS/redo06.log' to '+DATA/ZLHISCS/ONLINELOG/group_6';
Database altered.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/zlhiscs/onlinelog/group_4
+DATA/zlhiscs/onlinelog/group_5
+DATA/zlhiscs/onlinelog/group_6
#恢复数据库:
RMAN> recover database;
unable to find archived log
archived log thread=1 sequence=12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/06/2022 17:42:50
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 12 and starting SCN of 2998774
#不完全恢复:
RMAN> recover database until scn 2998774;
Starting recover at 06-MAY-22
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 06-MAY-22
#启动数据库到open状态
SQL> alter database open resetlogs;
Database altered.
--------------------
Mon May 09 11:12:12 2022
Completed: alter database open resetlogs
[root@node1 trace]# pwd
/u01/app/oracle/diag/rdbms/zlhiscs/ZLHISCS1/trace
#添加临时表空间
SQL> alter tablespace ZLTOOLSTMP add tempfile '+DATA' SIZE 50m;
Tablespace altered.
SQL> select status,enabled, name, bytes/1024/1024 file_size from v_$tempfile;
STATUS ENABLED
------- ----------
NAME
--------------------------------------------------------------------------------
FILE_SIZE
----------
ONLINE READ WRITE
+DATA/zlhiscs/tempfile/zltoolstmp.297.1104234219
50
ONLINE READ WRITE
+DATA/zlhiscs/tempfile/temp.295.1104232319
20
STATUS ENABLED
------- ----------
NAME
--------------------------------------------------------------------------------
FILE_SIZE
----------
ONLINE READ WRITE
+DATA/zlhiscs/tempfile/zltoolstmp.296.1104232319
50
#添加thred2的redo
SQL> alter database add logfile thread 2 group 7 '+DATA' size 50M;
Database altered.
SQL> alter database add logfile thread 2 group 8 '+DATA' size 50M;
Database altered.
SQL> alter database add logfile thread 2 group 9 '+DATA' size 50m;
Database altered.
#修改rac参数
SQL> alter system set thread=1 scope=spfile sid='ZLHISCS1';
System altered.
SQL> alter system set thread=2 scope=spfile sid='ZLHISCS2';
System altered.
SQL> alter system set instance_number=1 scope=spfile sid='ZLHISCS1';
System altered.
SQL> alter system set instance_number=2 scope=spfile sid='ZLHISCS2';
System altered.
SQL> alter system set cluster_database_instances=2 scope=spfile;
System altered.
SQL> alter system set cluster_database=true scope=spfile;
System altered.
#创建undo表空间
SQL> create undo tablespace undotbs2 datafile '+DATA/ZLHISCS/datafile/undotbs2.dbf' size 50m;
Tablespace created.
SQL> alter system set undo_tablespace='undotbs2' scope=spfile sid='ZLHISCS2';
System altered.
#启动thread 2
SQL> select THREAD#,STATUS,ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED DISABLED
SQL> alter database enable thread 2;
Database altered.
SQL> select THREAD#,STATUS,ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PRIVATE
#查看实例状态
[oracle@node1 ~]$ srvctl status database -d ZLHISCS
实例 ZLHISCS1 正在节点 node1 上运行
实例 ZLHISCS2 正在节点 node2 上运行
#重启数据库
[oracle@node1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon May 9 14:11:38 2022
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup open;
ORACLE instance started.
Total System Global Area 5311328256 bytes
Fixed Size 2262568 bytes
Variable Size 1073744344 bytes
Database Buffers 4227858432 bytes
Redo Buffers 7462912 bytes
Database mounted.
Database opened.
SQL>
[oracle@node2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon May 9 11:52:13 2022
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 5311328256 bytes
Fixed Size 2262568 bytes
Variable Size 1073744344 bytes
Database Buffers 4227858432 bytes
Redo Buffers 7462912 bytes
Database mounted.
Database opened.
rman异机恢复(单机到rac)
于 2022-06-15 15:24:52 首次发布