SQL> @crtdb.sql
SQL> SET FEEDBACK 1
SQL> SET NUMWIDTH 10
SQL> SET LINESIZE 80
SQL> SET TRIMSPOOL ON
SQL> SET TAB OFF
SQL> SET PAGESIZE 100
SQL>
SQL> STARTUP NOMOUNT PFILE=/u01/app/oracle/oradata/orcl/initorcl.ora
ORACLE instance started.
Total System Global Area 313860096 bytes
Fixed Size 1364340 bytes
Variable Size 272633484 bytes
Database Buffers 33554432 bytes
Redo Buffers 6307840 bytes
SQL> CREATE CONTROLFILE REUSE SET DATABASE orcl RESETLOGS
2 MAXLOGFILES 32
3 MAXLOGMEMBERS 2
4 MAXINSTANCES 1
5 MAXLOGHISTORY 908
6 LOGFILE
7 GROUP 1 '/u01/app/oracle/oradata/orcl/orcl_log1.log' SIZE 100M BLOCKSIZE 512,
8 GROUP 2 '/u01/app/oracle/oradata/orcl/orcl_log2.log' SIZE 100M BLOCKSIZE 512
9 DATAFILE
10 '/prod/backup/data_D-PROD_I-289579616_TS-SYSAUX_FNO-2_0pq5eur7',
11 '/prod/backup/data_D-PROD_I-289579616_TS-SYSTEM_FNO-1_0oq5eunu',
12 '/prod/backup/data_D-PROD_I-289579616_TS-UNDOTBS1_FNO-3_0rq5euss',
13 '/prod/backup/data_D-PROD_I-289579616_TS-USERS_FNO-4_0qq5eusl'
14 CHARACTER SET WE8DEC;
Control file created.
执行dbren.sql脚本
SQL> @dbren.sql
SQL> declare
2 begin
3 dbms_dnfs.clonedb_renamefile('/prod/backup/data_D-PROD_I-289579616_TS-SYSAUX_FNO-2_0pq5eur7' , '/u01/app/oracle/oradata/orcl/ora_data_orcl0.dbf');
4 dbms_dnfs.clonedb_renamefile('/prod/backup/data_D-PROD_I-289579616_TS-SYSTEM_FNO-1_0oq5eunu' , '/u01/app/oracle/oradata/orcl/ora_data_orcl1.dbf');
5 dbms_dnfs.clonedb_renamefile('/prod/backup/data_D-PROD_I-289579616_TS-UNDOTBS1_FNO-3_0rq5euss' , '/u01/app/oracle/oradata/orcl/ora_data_orcl2.dbf');
6 dbms_dnfs.clonedb_renamefile('/prod/backup/data_D-PROD_I-289579616_TS-USERS_FNO-4_0qq5eusl' , '/u01/app/oracle/oradata/orcl/ora_data_orcl3.dbf');
7 end;
8 /
PL/SQL procedure successfully completed.
SQL> show errors;
No errors.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/ora_data_orcl1.dbf'
SQL> drop tablespace TEMP;
drop tablespace TEMP
*
ERROR at line 1:
ORA-01109: database not open
SQL> create temporary tablespace TEMP;
create temporary tablespace TEMP
*
ERROR at line 1:
ORA-01109: database not open
下面我们来看看三个检查点:
1. 系统检查点
SQL> select checkpoint_change# from v$database;
CHECKPOINT_CHANGE#
------------------
791020
1 row selected.
2. 数据文件检查点
SQL> select file#,checkpoint_change#,last_change# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 791020 791020
2 791020 791020
3 791020 791020
4 791020 791020
4 rows selected.
3. 数据文件头检查点
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
791019
791019
791019
791019
4 rows selected.
大家发现没有?系统检查点和数据文件检查点是一致的,但数据文件头检查点是不一致的。
总结:
尝试了很多次,包括关闭数据库进行数据库冷备,数据文件头检查点和上述两个检查点的数值总是不一致,而且总是比上述检查点的数值少1,怀疑这是个bug,总之,这次实验就这样不了了之了,后续有时间的话再行测试。同时,官方文档中有一段话:
Because CloneDB databases use the backup files as their backend storage, the backup files must be available to each CloneDB database for it to run.If the backup files become unavailable, then the CloneDB databases return errors.
意思就是在运行克隆数据库的时候,备份文件必须是可用的,如果删除了备份文件或者卸载了NFS文件系统,则克隆数据库将不可用。
很好奇,可惜没有机会进行测试。
尽管该实验最后没有成功,但反复做了很多次,中间结果并不像实验步骤这样直观,有以下几点主要注意:
1> 刚开始做测试的时候,写的是/u01 *(rw),后来启用Direct NFS,创建tablespace做测试时会报以下错误: