rac恢复到单实例

发布时间:2020-08-11 15:27:47 作者:shilei1
来源:ITPUB博客 阅读:175



1、将使用rman备份的rac的备份文件传输到异地单节点上
[oracle@ora0 ~]$ ls /data_back/racbk/
20120514_3snav1p2_1_1.bk  40nav1sh_1_1_20120514.arc  43nav1sh_1_1_20120514.arc    48nav1vu_1_1_20120514.ctl
20120514_3tnav1p2_1_1.bk  41nav1sh_1_1_20120514.arc  44nav1t7_1_1_20120514.arc
20120514_3unav1pa_1_1.bk  42nav1sh_1_1_20120514.arc  46nav1uq_1_1_20120514.spfil

2、解决pfile
[oracle@ora0 ~]$ rman target /
RMAN> startup

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/oracle/product/10.2.0/dbs/initora10g.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 05/14/2012 13:17:11
ORA-00205: error in identifying control file, check alert log for more info
#############报错,不用理会############################
恢复spfile
RMAN> restore spfile from '/data_back/racbk/46nav1uq_1_1_20120514.spfil';

连入sql界面
SQL> conn /as sysdba
Connected.
SQL> select status from  v$instance;

STATUS
------------
STARTED

SQL> create pfile from spfile;

File created.

删除spfile 修改pfile
从RAC数据库中创建参数文件,如果RAC使用PFILE,可以直接COPY后修改。
         修改的参数有: audit_file_dest, background_dump_dest, core_dump_dest,user_dump_dest, log_archive_dest_1等,
         与路径有关的参数,修改为你单实例环境的对应路径。如:
        background_dump_dest=/u01/oracle/ora/9.2.0/admin/DEV_dbtest/bdump
       重要的: 移除cluster_database_instances,cluster_database参数,因为恢复到的是单实例环境。
                      移除一个UNDO_TABLESPACE设置,这里假设保留的是APPS_UNDOTBS1

#############################
*.audit_file_dest='/u01/oracle/admin/db/adump'
*.background_dump_dest='/u01/oracle/admin/db/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/product/10.2.0/dbs/control_01.ctl'
*.core_dump_dest='/u01/oracle/admin/db/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='db'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/home/oracle/arc'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=283115520
*.undo_management='AUTO'
undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/admin/db/udump'
################################################
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  2020224 bytes
Variable Size              92277888 bytes
Database Buffers          188743680 bytes
Redo Buffers                2170880 bytes
SQL>

3、恢复控制文件,启动数据库到mount状态
RMAN> restore controlfile from '/data_back/racbk/48nav1vu_1_1_20120514.ctl';
RMAN> alter database mount;
database mounted
released channel: ORA_DISK

4、修改数据文件和日志文件路径
select 'set newname  for datafile '||chr(39)||name||chr(39)||' to '||chr(39)||replace(name,'+DG0/db/datafile/','/home/oracle/data2/')||chr(39)||';' from v$datafile;
#######################

SQL> select 'set newname  for datafile '||chr(39)||name||chr(39)||' to '||chr(39)||replace(name,'+DG0/db/datafile/','/home/oracle/data2/')||chr(39)||';' from v$datafile;

'SETNEWNAMEFORDATAFILE'||CHR(39)||NAME||CHR(39)||'TO'||CHR(39)||REPLACE(NAME,'+DG0/DB/DATAFILE/','/HOME/ORACLE/DATA2/')||CHR(39)||';'
------------------------------------------------------------------------------------------------------------------------------------------------------
set newname  for datafile '+DG0/db/datafile/sysaux.257.780159407' to '/home/oracle/data2/sysaux.257.780159407';
set newname  for datafile '+DG0/db/datafile/system.256.780159407' to '/home/oracle/data2/system.256.780159407';
set newname  for datafile '+DG0/db/datafile/timelineweb01.dbf' to '/home/oracle/data2/timelineweb01.dbf';
set newname  for datafile '+DG0/db/datafile/undotbs1.258.780159409' to '/home/oracle/data2/undotbs1.258.780159409';
set newname  for datafile '+DG0/db/datafile/undotbs2.264.780159511' to '/home/oracle/data2/undotbs2.264.780159511';
set newname  for datafile '+DG0/db/datafile/users.259.780159409' to '/home/oracle/data2/users.259.780159409';

6 rows selected.

######################
5. 恢复数据库到新的目录(我的环境是原来是RAW恢复到文件系统)
 select 'alter database rename file  '||chr(39)||member||chr(39)||' to '||chr(39)||replace(member,'+DG0/db/onlinelog/','/home/oracle/data2/')||chr(39)||';' from v$logfile;
SQL>  select 'alter database rename file  '||chr(39)||member||chr(39)||' to '||chr(39)||replace(member,'+DG0/db/onlinelog/','/home/oracle/data2/')||chr(39)||';' from v$logfile;

'ALTERDATABASERENAMEFILE'||CHR(39)||MEMBER||CHR(39)||'TO'||CHR(39)||REPLACE(MEMBER,'+DG0/DB/ONLINELOG/','/HOME/ORACLE/DATA2/')||CHR(39)||';'
------------------------------------------------------------------------------------------------------------------------------------------------------
alter database rename file  '+DG0/db/onlinelog/group_2.262.780159469' to '/home/oracle/data2/group_2.262.780159469';
alter database rename file  '+DG0/db/onlinelog/group_1.261.780159467' to '/home/oracle/data2/group_1.261.780159467';
alter database rename file  '+DG0/db/onlinelog/group_3.265.780159539' to '/home/oracle/data2/group_3.265.780159539';
alter database rename file  '+DG0/db/onlinelog/group_4.266.780159539' to '/home/oracle/data2/group_4.266.780159539';

在sql界面执行与日志文件有关的语句:
alter database rename file  '+DG0/db/onlinelog/group_2.262.780159469' to '/home/oracle/data2/group_2.262.780159469';
alter database rename file  '+DG0/db/onlinelog/group_1.261.780159467' to '/home/oracle/data2/group_1.261.780159467';
alter database rename file  '+DG0/db/onlinelog/group_3.265.780159539' to '/home/oracle/data2/group_3.265.780159539';
alter database rename file  '+DG0/db/onlinelog/group_4.266.780159539' to '/home/oracle/data2/group_4.266.780159539';

在rman界面执行如下脚本:

RMAN> catalog start with '/data_back/racbk/';
查出catalog的scn号
Rman > list backup #找出最大的scn
然后运行如下脚本
run {
set newname  for datafile '+DG0/db/datafile/sysaux.257.780159407' to '/home/oracle/data2/sysaux.257.780159407';
set newname  for datafile '+DG0/db/datafile/system.256.780159407' to '/home/oracle/data2/system.256.780159407';
set newname  for datafile '+DG0/db/datafile/timelineweb01.dbf' to '/home/oracle/data2/timelineweb01.dbf';
set newname  for datafile '+DG0/db/datafile/undotbs1.258.780159409' to '/home/oracle/data2/undotbs1.258.780159409';
set newname  for datafile '+DG0/db/datafile/undotbs2.264.780159511' to '/home/oracle/data2/undotbs2.264.780159511';
set newname  for datafile '+DG0/db/datafile/users.259.780159409' to '/home/oracle/data2/users.259.780159409';
set until scn 1385018;
restore database ;
switch datafile all;
recover database;
}

6,打开数据库
SQL> alter database open resetlogs;

Database altered.

7、
处理临时文件:
先创建一个临时表空间temp1
SQL> create temporary tablespace temp1 tempfile  '/home/oracle/data2/temp2.dbf' size 512m  autoextend on next 1m maxsize unlimited;

Tablespace created.
SQL> alter database default temporary tablespace temp1;

Database altered.

删掉不用的undo表空间及文件
SQL> select tablespace_name,status from dba_data_files;

TABLESPACE_NAME                STATUS
------------------------------ ---------
USERS                          AVAILABLE
SYSAUX                         AVAILABLE
UNDOTBS1                       AVAILABLE
SYSTEM                         AVAILABLE
UNDOTBS2                       AVAILABLE
TIMELINEWEB                    AVAILABLE

6 rows selected.

SQL> show parameter undo

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1
SQL> drop tablespace undotbs2 including contents and datafiles;

Tablespace dropped.

SQL>

删除通过RMAN回复过来的临时文件。完成临时文件的整个处理过程。
SQL> drop tablespace temp including contents and datafiles;
Tablespace dropped.

删除不用的日志
select thread#,status,enabled from v$thread; --查找thread,那个可以删除

SQL> select thread#,status,enabled from v$thread;

   THREAD# STATUS ENABLED
---------- ------ --------
         1 OPEN   PUBLIC
         2 CLOSED PUBLIC

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          0   52428800          1 YES UNUSED                       0
         2          1          1   52428800          1 NO  CURRENT                1385019 14-MAY-12
         3          2          0   52428800          1 YES UNUSED                       0
         4          2          1   52428800          1 NO  CURRENT                1385019 14-MAY-12

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                        IS_
---------- ------- ------- --------------------------------------------- ---
         2         ONLINE  /home/oracle/data2/group_2.262.780159469      NO
         1         ONLINE  /home/oracle/data2/group_1.261.780159467      NO
         3         ONLINE  /home/oracle/data2/group_3.265.780159539      NO
         4         ONLINE  /home/oracle/data2/group_4.266.780159539      NO

SQL> ALTER DATABASE DISABLE THREAD 2;

Database altered.

SQL> alter database drop logfile group 3
  2  ;

Database altered.

SQL> alter database drop logfile group 4;
alter database drop logfile group 4
*
ERROR at line 1:
ORA-00350: log 4 of instance db2 (thread 2) needs to be archived
ORA-00312: online log 4 thread 2: '/home/oracle/data2/group_4.266.780159539'

SQL>  alter database clear unarchived logfile group 4;

Database altered.

SQL> alter database drop logfile group 4;

Database altered.

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          0   52428800          1 YES UNUSED                       0
         2          1          1   52428800          1 NO  CURRENT                1385019 14-MAY-12

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                        IS_
---------- ------- ------- --------------------------------------------- ---
         2         ONLINE  /home/oracle/data2/group_2.262.780159469      NO
         1         ONLINE  /home/oracle/data2/group_1.261.780159467      NO

SQL>

推荐阅读:
  1. Oracle 12C Rac到Rac搭建ADG
  2. NBU Linux上oracle单实例恢复到单实例

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

rac 单实例 实例

上一篇:image与view标签上下有空隙怎么办

下一篇:Solaris,一个优秀的系统末路

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》