使用RMAN迁移单库到RAC

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 一、源库 create pfile='/home/oracle/rman_bk/pfile.ora' from spfile; backup incremental level 0 format '/home/oracle/rman_bk/orcl_%U' dat...
一、源库

create pfile='/home/oracle/rman_bk/pfile.ora' from spfile;

backup incremental level 0 format '/home/oracle/rman_bk/orcl_%U' database plus archivelog delete all input;

backup current controlfile format '/home/oracle/rman_bk/control_%U';


将/home/oracle/rman_bk目录下文件拷贝到目标库相应目录下


二、目标库(其中一个节点上操作)

1、根据源库生成的pfile创建rac的spfile

(1)修改参数文件
[oracle@centosnode1 rman]$ vim pfile.ora
*.__db_cache_size=104857600
*.__java_pool_size=4194304
*.__large_pool_size=4194304
*.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.__pga_aggregate_target=192937984
*.__sga_target=343932928
*.__shared_io_pool_size=0
*.__shared_pool_size=213909504
*.__streams_pool_size=8388608
db021.instance_name='db021'
db022.instance_name='db022'
db021.instance_number=1
db022.instance_number=2
*.audit_file_dest='/u01/app/oracle/admin/db02/adump'
*.audit_trail='db'
*.cluster_database=true
*.cluster_database_instances=2
db021.thread=1
*.compatible='11.2.0.1.0'
*.control_files='+DATA/db02/controlfile/current.1214.911838439'#Restore Controlfile
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='db02'
*.db_recovery_file_dest=''
*.log_archive_dest_1='location=+DATA/db02/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.job_queue_processes=10
*.remote_login_passwordfile='EXCLUSIVE'
*.memory_target=1606418432
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
db022.undo_tablespace='UNDOTBS2'
db021.undo_tablespace='UNDOTBS1'

注意:1、这个时候不能加orcl2.thread=2参数,否则后面无法将数据库启动到mount状态
      2、*.compatible='11.2.0.1.0'指定的版本号一定要和源库的版本号一致,否则后面恢复控制文件后,启动实例到mount状态是报错:
         ORA-00201: control file version 11.2.0.1.0 incompatible with ORACLE version11.2.0.0.0

(2)创建共享参数文件spfile
SQL> create spfile='+DATA/db02/parameterfile/spfiledb02.ora' from pfile='/home/oracle/rman/pfile.ora';

(3)在两个节点上分别创建审计目录、pfile以及密码文件
[oracle@centosnode1 rman]$ mkdir -p /u01/app/oracle/admin/db02/adump
[oracle@centosnode1 rman]$ cd $ORACLE_HOME/dbs
[oracle@centosnode1 dbs]$ echo 'spfile=+DATA/db02/parameterfile/spfiledb02.ora' > initdb021.ora
[oracle@centosnode1 dbs]$ orapwd file=orapwdb021 password=oracle

2、将节点实例启动到nomount状态,然后从备份中恢复控制文件
RMAN> restore controlfile from '/home/oracle/rman/control_0sr5lmfp_1_1';

3、恢复控制文件后重新启动实例到mount状态,恢复数据文件

run{
    set newname for datafile 1 to '+DATA/db02/datafile/system01.dbf';
    set newname for datafile 2 to '+DATA/db02/datafile/sysaux01.dbf';
    set newname for datafile 3 to '+DATA/db02/datafile/undotbs01.dbf';
    set newname for datafile 4 to '+DATA/db02/datafile/users01.dbf';
    set newname for datafile 5 to '+DATA/db02/datafile/tbs01.dbf';
    set newname for datafile 6 to '+DATA/db02/datafile/citibank.dbf';
    set newname for tempfile 1 to '+DATA/db02/tempfile/temp01.dbf';
    restore database;
    switch datafile all;
    switch tempfile all;
}

recover database;

4、对在线重做日志文件进行更名,添加thread 2日志组

SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo01.log' to '+DATA/db02/onlinelog/redo01.log';

SQL>  alter database rename file '/u01/app/oracle/oradata/db02/redo02.log' to '+DATA/db02/onlinelog/redo02.log';

SQL>  alter database rename file '/u01/app/oracle/oradata/db02/redo03.log' to  '+DATA/db02/onlinelog/redo03.log';

SQL>  alter database add logfile thread 2 group 4 '+DATA' size 50M;

SQL> alter database add logfile thread 2 group 5  '+DATA' size 50M;

SQL> alter database add logfile thread 2 group 6 '+DATA' size 50M;

SQL> select thread#,bytes/(1024*1024),status from v$log;

   THREAD# BYTES/(1024*1024) STATUS
---------- ----------------- ----------------
     1          50 CURRENT
     1          50 INACTIVE
     1          50 INACTIVE
     2          50 UNUSED
     2          50 UNUSED
     2          50 UNUSED


5、使用open resetlogs方式打开数据库

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 2609022 generated at 05/15/2016 16:05:49 needed for thread 1
ORA-00289: suggestion : +DATA/db02/arch/1_60_908532301.dbf
ORA-00280: change 2609022 for thread 1 is in sequence #60


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;

Database altered.

SQL> select open_mode,name from gv$database;

OPEN_MODE         NAME
-------------------- ---------
READ WRITE         DB02


6、修改相关的初始化参数,创建undotbs2表空间,启用thread 2日志组
SQL> alter system set thread=1 scope=spfile sid='db021';

SQL> alter system set thread=2 scope=spfile sid='db022';

SQL> select bytes/(1024*1024) MB from dba_data_files where tablespace_name='UNDOTBS1';

    MB
----------
    75

SQL> create undo tablespace undotbs2 datafile '+DATA/db02/datafile/undotbs02.dbf' size 75M;

SQL> alter system set undo_tablespace=undotbs2 sid='db022';

SQL> alter database enable thread 2;
alter database enable thread 2
*
ERROR at line 1:
ORA-01612: instance UNNAMED_INSTANCE_2 (thread 2) is already enabled

注:此处已经启动,如果没有启动需要手动启动日志进程thread 2

7、重新启动节点1实例,再启动节点2实例


三、添加db02库到srvctl管理

[oracle@centosnode1 ~]$ srvctl add database -d db02 -o /u01/app/oracle/product/11.2.0/db_1 -p +DATA/orcl/spfileorcl.ora
[oracle@centosnode1 ~]$ srvctl add instance -d db02 -i db021 -n centosnode1
[oracle@centosnode1 ~]$ srvctl add instance -d db02 -i db022 -n centosnode2
[oracle@centosnode1 ~]$ srvctl start database -d db02
[oracle@centosnode1 ~]$ srvctl status database -d db02
Instance db021 is running on node centosnode1
Instance db022 is running on node centosnode2

注意:要使用oracle用户添加

备注:srvctl删除数据库信息命令:
      [oracle@rac1 ~]$ srvctl stop database -d db02
      [oracle@rac1 ~]$ srvctl  remove database -d db02
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
数据库 数据安全/隐私保护
使用rman把单机的备份集恢复到RAC的方法
环境准备 在ASM磁盘组里面创建相应的目录
207 0
|
Oracle 关系型数据库 测试技术
Oracle 11G ADG 搭建 RAC to Single 详细教程(RMAN DUPLICATE)
经过交流群中朋友的多次要求,这次给大家分享一下 RAC to Single 的 ADG 搭建教程!
Oracle 11G ADG 搭建 RAC to Single 详细教程(RMAN DUPLICATE)
Oracle RAC迁移到单实例DB
这篇文章记录Oracle RAC通过RMAN备份如何迁移到单机DB,文章中描述了几个容易出错的地方,如下:    ①RAC到单机redo文件位置处理    ②RAC多个UNDO处理    ③RAC到单机临时表空间处理下面开始文章正文。
8264 0
rac库数据文件创建在os本地的解决办法
按照影响程度大小,方案A需要down库,方案B需要offline tablespace,方案C只需offline datafile即可。综合来看,下面的Testcase_C_2的方法来的最简单。影响也最小。
1241 0