如何利用Direct NFS克隆Oracle数据库(3)

在这里,我们选择脚本方式,通过脚本执行过程中的输出,对比ORACLE官方文档,我们可以发现两者其实是一样的,只不过手动创建所需要的命令写到脚本里面去了。

首先在克隆数据库所在的主机上设置环境变量

[oracle@node2 ~]$ export MASTER_COPY_DIR=/prod/backup
[oracle@node2 ~]$ export CLONE_FILE_CREATE_DEST=/u01/app/oracle/oradata/orcl
[oracle@node2 ~]$ export CLONEDB_NAME=orcl

其中MASTER_COPY_DIR指的是备份所在的目录,CLONE_FILE_CREATE_DEST指的是数据文件、日志文件、控制文件所在的目录,CLONEDB_NAME指定数据库名

执行数据库提供的perl脚本,关于脚本所在的目录及其执行的方式,我们来看看官方的说明:

因为我的数据库版本为11.2.0.4,��直接COPY到home目录下

[oracle@node2 ~]$ cp /u01/app/oracle/product/11.2.0.1/db_1/rdbms/install/clonedb.pl ~

执行脚本

[oracle@node2 ~]$ perl clonedb.pl /prod/backup/pfile.ora crtdb.sql dbren.sql

在/home/oracle下会生成两个文件,crtdb.sql和dbren.sql

登录数据库,执行crtdb.sql

[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 24 18:26:46 2015

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

Connected to an idle instance.

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/0cq553i6_1_1',
 11  '/prod/backup/cf_D-PROD_id-289579616_0aq553hp',
 12  '/prod/backup/data_D-PROD_I-289579616_TS-SYSAUX_FNO-2_08q553gd',
 13  '/prod/backup/data_D-PROD_I-289579616_TS-SYSTEM_FNO-1_07q553dp',
 14  '/prod/backup/data_D-PROD_I-289579616_TS-UNDOTBS1_FNO-3_09q553hj',
 15  '/prod/backup/data_D-PROD_I-289579616_TS-USERS_FNO-4_0bq553i5',
 16  '/prod/backup/lost+found',
 17  '/prod/backup/pfile.ora'
 18  CHARACTER SET WE8DEC;
CREATE CONTROLFILE REUSE SET DATABASE orcl RESETLOGS
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-00058: DB_BLOCK_SIZE must be 16384 to mount this database (not 8192)

报以上错误,再来看看datafile下面的文件,然后它把/prod/backup下面的所有的文件都包括其中了,包括控制文件的备份和lost+found文件,而这并不是数据文件,关闭数据库,删除该目录下的其它文件,将pfile move到/home/oracle下,重新执行clonedb.pl脚本

SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@node2 ~]$ cd /prod/backup/
[oracle@node2 backup]$ ls
0cq553i6_1_1
cf_D-PROD_id-289579616_0aq553hp
data_D-PROD_I-289579616_TS-SYSAUX_FNO-2_08q553gd
data_D-PROD_I-289579616_TS-SYSTEM_FNO-1_07q553dp
data_D-PROD_I-289579616_TS-UNDOTBS1_FNO-3_09q553hj
data_D-PROD_I-289579616_TS-USERS_FNO-4_0bq553i5
lost+found
pfile.ora
[oracle@node2 backup]$ rm 0cq553i6_1_1
[oracle@node2 backup]$ rm cf_D-PROD_id-289579616_0aq553hp
[oracle@node2 backup]$ rm -rf lost+found/
[oracle@node2 backup]$ mv pfile.ora ~
[oracle@node2 backup]$ cd ~
[oracle@node2 ~]$ perl clonedb.pl pfile.ora crtdb.sql dbren.sql

重新执行crtdb.sql脚本,结果如下:

[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Apr 27 18:13:39 2015

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

Connected to an idle instance.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9c223881a4ba7f13dd4a59bc63481d25.html