Bo's Oracle Station

查看: 2022|回复: 0

2022.2.13: 模板建库的controlfile creation脚本和跨平台迁移的对应脚本的对比

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2022-2-13 16:45:03 | 显示全部楼层 |阅读模式
1. 模板建库的controlfile creation脚本:dbca模板建库时,设定库名为emrep,保存脚本如下:
  1. create controlfile reuse set database "emrep"
  2. MAXINSTANCES 8
  3. MAXLOGHISTORY 1
  4. MAXLOGFILES 16
  5. MAXLOGMEMBERS 3
  6. MAXDATAFILES 100
  7. Datafile
  8. '&&file0',
  9. '&&file1',
  10. '&&file2',
  11. '&&file3'
  12. LOGFILE GROUP 1  SIZE 1024M,
  13. GROUP 2  SIZE 1024M,
  14. GROUP 3  SIZE 1024M,
  15. GROUP 4  SIZE 1024M,
  16. GROUP 5  SIZE 1024M RESETLOGS;
复制代码
注意:建库的create controlfile语句里有“set”,而用于恢复controlfile的trace脚本(有set1和set2两段)都没有“set”。下面查看一下该建库的create controlfile语句创建的emrep数据库的化身:
[oracle@classroom ~]$ rman target  /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Feb 13 16:44:13 2022
Version 19.3.0.0.0

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

connected to target database: EMREP (DBID=22794985)

RMAN> list incarnation of database;

using target database control file instead of recovery catalog

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       EMREP    22794985         PARENT  1          17-APR-19
2       2       EMREP    22794985         CURRENT 1920977    23-JAN-22

RMAN>
发现会记录原模板中的化身,就是说会保留PARENT 化身,而用于恢复controlfile的trace脚本(有set1和set2两段)都清除历史化身,只会留下当前化身。注意区别。

2. 跨平台迁移的controlfile creation脚本(与改数据库名字的脚本一样):
跨平台迁移时,rman的执行“convert database to platform”会话的trace文件里有create controlfile语句保存成脚本如下:
  1. CREATE CONTROLFILE REUSE SET DATABASE mydb RESETLOGS  ARCHIVELOG
  2.    MAXLOGFILES 16
  3.    MAXLOGMEMBERS 3
  4.    MAXDATAFILES 100
  5.    MAXINSTANCES 8
  6.    MAXLOGHISTORY 292
  7. LOGFILE
  8.    GROUP 1 '/u01/app/oracle/oradata/orcl2/redo01.log' SIZE 500M BLOCKSIZE 512,
  9.    GROUP 2 '/u01/app/oracle/oradata/orcl2/redo02.log' SIZE 500M BLOCKSIZE 512,
  10.    GROUP 3 '/u01/app/oracle/oradata/orcl2/redo03.log' SIZE 500M BLOCKSIZE 512
  11. DATAFILE
  12.    '/u01/app/oracle/oradata/orcl2/sysaux01.dbf',
  13.    '/u01/app/oracle/oradata/orcl2/system01.dbf',
  14.    '/u01/app/oracle/oradata/orcl2/undotbs1.dbf',
  15.    '/u01/app/oracle/oradata/orcl2/users01.dbf'
  16. CHARACTER SET ZHS16GBK
  17. ;
复制代码
create controlfile语句里也有“set”,与模板建库情况相同,与用于恢复controlfile的trace脚本(有set1和set2两段)的情况不同,因此化身也会保留PARENT部分:
[oracle@classroom ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Feb 13 16:43:16 2022
Version 19.3.0.0.0

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

connected to target database: MYDB (DBID=376305118)

RMAN> list incarnation of database;

using target database control file instead of recovery catalog

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       MYDB     376305118        PARENT  2103854    13-FEB-22
2       2       MYDB     376305118        CURRENT 2188190    13-FEB-22

3. “nid”命令改dbid和dbname后的数据库会保留历史化身(与改数据库名字的脚本一样)
将上面的mydb数据库改名字成orcl2数据库,使用“nid target=sys/oracle_4U dbname=orcl2”命令,数据库重新启动:
[oracle@classroom dbs]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Feb 13 16:53:49 2022
Version 19.3.0.0.0

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

SQL> conn / as sysdba
Connected.
SQL> shutdown abort
ORACLE instance shut down.
SQL> create spfile from pfile;

File created.

SQL> startup
ORACLE instance started.

Total System Global Area 2566913256 bytes
Fixed Size            8899816 bytes
Variable Size          553648128 bytes
Database Buffers     1996488704 bytes
Redo Buffers            7876608 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@classroom dbs]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Feb 13 16:55:45 2022
Version 19.3.0.0.0

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

connected to target database: ORCL2 (DBID=1077418382)

RMAN> list incarnation of database;

using target database control file instead of recovery catalog

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORCL2    1077418382       PARENT  2103854    13-FEB-22
2       2       ORCL2    1077418382       PARENT  2188190    13-FEB-22
3       3       ORCL2    1077418382       CURRENT 2189976    13-FEB-22

RMAN>





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-21 14:24 , Processed in 0.032753 second(s), 24 queries .

快速回复 返回顶部 返回列表