clone database using direct nfs
Before cloning the database we need to configure the direct NFS , below is the procedure for DNFS configuration.
Direct NFS
Direct NFS is one of the new feature in 11.2. This is used to improve the performance. To use Direct NFS Client, the NFS file systems must first be mounted and available over regular NFS mounts. The mount options used in mounting the file systems are not relevant, as Direct NFS Client manages the configuration after installation.
Below is the link for the basic nfs configuration.
http://srinivasoguri.blogspot.in/2016/04/how-to-configure-nfs-in-redhat-linux.html
Direct NFS Client can use a new configuration file ‘oranfstab’ or the mount tab file (/etc/mtab on Linux) to determine the mount point settings for NFS storage devices.
Oracle first looks for the mount settings in $ORACLE_HOME/dbs/oranfstab, which specifies the Direct NFS Client settings for a single database. Next, Oracle looks for settings in /etc/oranfstab, which specifies the NFS mounts available to all Oracle databases on that host. Finally, Oracle reads the mount tab file (/etc/mtab on Linux) to identify available NFS mounts.
Step by step procedure to enable the DNFS
1) Install database software.
2) login as a root user
cd $ORACLE_HOME/bin
[root@node3 bin]# chown root:root oradism
[root@node3 bin]# ls -l oradism
-rwxr-x— 1 root root 68278 Aug 14 2009 oradism
[root@node3 bin]# chmod 4755 oradism
[root@node3 bin]# ls -l oradism
-rwsr-xr-x 1 root root 68278 Aug 14 2009 oradism
3) as a oracle user execute below commands.
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk dnfs_on
[oracle@node3 lib]$ make -f ins_rdbms.mk dnfs_on
rm -f /oradisk/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libodm11.so; cp /oradisk/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libnfsodm11.so /oradisk/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libodm11.so
4) make below entry in oranfstab file.
server:node2.oracle.com — NFS SERVER
path:192.9.1.101 — IP ADDRESS OF NFS SERVER
export: /u01/BACKUP mount: /BACKUP — export is the directory in NFS server , mount is the mount point we created in NFS client
Now the DFS configuration is complete.
CloneDB using the directNFS :-
My Configuration :
Oracle version : 11.2.0.3
Source DB : PROD
Destination DB : TEST
Destination SID : TEST
Now direct NFS Client configuration is completed. We can clone the database using the backup of that database over the NFS. This clone db use the copy-on-write techique. It will use the backup files as datafiles to read the data, it will take very minimal storage. If you do any DML or DDL operations then it will write the data into the datafiles files.
Refer below link for copy-on-write :-
https://en.wikipedia.org/wiki/Copy-on-write
Step-by-Step procedure for cloning the database.
1) Take a cold backup of the source database you want to clone, in the NFS filesystem(avilable for both source and destination).
configure controlfile autobackup off;
run
{
set nocfau;
backup as copy database format ‘/u01/BACKUP/%U’;
}
2) On destination server export the below variables.
export ORACLE_SID=TEST — SID of the database
export MASTER_COPY_DIR=/BKP — NFS mountpoint where the backup exists
export CLONE_FILE_CREATE_DEST=/DATA/TEST — Location to create datafiles and logfiles for the clonedb
export CLONEDB_NAME=TEST — Database name
3) There is a perl script in the metalink Note 1210656.1, execute the script to create sql scripts to create the clone database.
perl /tmp/Clone.pl /oradisk/oracle/app/oracle/product/11.2.0.3/dbhome_1/dbs/initTEST.ora crtdb.sql dbren.sql
This will create two sql files. (crtdb.sql , dbren.sql)
4) Open the pfile created in the location “/DATA/TEST” and add the below parameter.
clonedb=TRUE
5) execute below commands
export ORACLE_SID=TEST
export ORACLE_HOME=/oradisk/oracle/app/oracle/product/11.2.0.3/dbhome_1
[oracle@node3 tmp]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 18 12:08:50 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> @crtdb
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=/DATA/TEST/initTEST.ora
ORACLE instance started.
Total System Global Area 684822528 bytes
Fixed Size 2231432 bytes
Variable Size 629146488 bytes
Database Buffers 50331648 bytes
Redo Buffers 3112960 bytes
SQL> CREATE CONTROLFILE REUSE SET DATABASE TEST RESETLOGS
2 MAXLOGFILES 32
3 MAXLOGMEMBERS 2
4 MAXINSTANCES 1
5 MAXLOGHISTORY 908
6 LOGFILE
7 GROUP 1 ‘/DATA/TEST/TEST_log1.log’ SIZE 100M BLOCKSIZE 512,
8 GROUP 2 ‘/DATA/TEST/TEST_log2.log’ SIZE 100M BLOCKSIZE 512
9 DATAFILE
10 ‘/BKP/data_D-PROD_I-2820641880_TS-PROD_FNO-5_0mr3bdbg’,
11 ‘/BKP/data_D-PROD_I-2820641880_TS-SYSAUX_FNO-2_0ir3bd9f’,
12 ‘/BKP/data_D-PROD_I-2820641880_TS-SYSTEM_FNO-1_0hr3bd81’,
13 ‘/BKP/data_D-PROD_I-2820641880_TS-UNDOTBS1_FNO-3_0jr3bdai’,
14 ‘/BKP/data_D-PROD_I-2820641880_TS-USERS_FNO-4_0lr3bdbe’
15 CHARACTER SET WE8DEC;
Control file created.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@node3 tmp]$ vi dbren.sql
[oracle@node3 tmp]$
[oracle@node3 tmp]$
[oracle@node3 tmp]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 18 12:09:21 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @dbren
PL/SQL procedure successfully completed.
No errors.
Database altered.
drop tablespace TEMP
*
ERROR at line 1:
ORA-12906: cannot drop default temporary tablespace
create temporary tablespace TEMP
*
ERROR at line 1:
ORA-01543: tablespace ‘TEMP’ already exists
SQL>
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
——— ——————–
TEST READ WRITE
To Check the DNFS server :-
SQL> select * from v$dnfs_servers;
ID SVRNAME DIRNAME MNTPORT NFSPORT WTMAX RTMAX
———- ——————– ——————– ———- ———- ———- ———-
1 192.9.1.101 /u01/BACKUP 896 2049 32768 32768
Issues I faced :-
1) After executing the “dbren.sql”.
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-17513: dNFS package call failed
ORA-06512: at “SYS.X$DBMS_DNFS”, line 10
ORA-06512: at line 3
The datafile and logfile location should also be a NFS file system. (/DATA/TEST is a NFS file system)
2) [oracle@node3 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 13 20:03:37 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile=/oradisk/DATA/TEST/initTEST.ora
ORA-00845: MEMORY_TARGET not supported on this system
SQL> quit
shared memory is less than memory_target.
3) crtdb.sql script got hanged. in the alert log below error message is coming.
Direct NFS: please check that oradism is setuid
Step 2 in the DNFS configuration is missed.
4) dbren.sql script got failed with below error.
c] ORA-01511: error in renaming log/data files
ORA-01141: error renaming data file x – new file ‘xxxxxxx’ not found
ORA-01110: data file x:xxxxxx
ORA-17515: Creation of clonedb failed using snapshot file xxxxxxxxx
ORA-06512: at “SYS.X$DBMS_DNFS”, line 10
clonedb=true is missing in the clonedb pfile.
This will cause the above errors .If the clonedb parameter is not updated ,it will link the backup source datafiles.So dont use “DROP DATABASE” to cleanup as this will cleanup the source backup files.
5) while executing the dbren.sql faced the below error.
[1349998404222404] kgnfscrechan:2954: Failed to get root fsinfo on filer
If this message comes ,we need to set the “insecure” option in export file of the nfs server.
6) SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1:
‘/BKP/data_D-PROD_I-2820641880_TS-SYSTEM_FNO-1_0cr3bb7c’
Sol : We need to use the cold backup for this , or we need to make the archivelogs avilable for recovery.
References :-
Step by Step – Configure Direct NFS Client (DNFS) on Linux (11g) (Doc ID 762374.1)