Tuesday, August 26, 2014

DB Creation Using Silent Mode of DBCA

Oracle Provides lots of alternatives to create database among which there is a very popular and handy tool called database Configuration Assistant (DBCA).DBCA can run in either GUI or silent mode and most of the times people prefer to use GUI mode but many Times there are requirement to create database but without using GUI.

So here We are going to Create Database using Database Configuration Assistant but in silent mode i.e. without using GUI of Database Assistant tool. The keyword “dbca -silent” invokes the binary of dbca from bin directory in silent mode.

Prerequisites:

1. Check oratab file whether entry/name of the database you are creating is already existing or not because if at all “xyz” database is not running but if “xyz” was running long back and its entry is still there in oratab though its been deleted from server then your database creation operation will get failed.

2. Create all the required directories(viz. data directory)

Implementation :

1. Create a file and write whole dbca command which will run later. here I have used vi editor to create it manually.

[oracle@neeraj]$ vi dbca_KYTE.sh
[oracle@neeraj]$ chmod 775 dbca_KYTE.sh
[oracle@neeraj]$ cat dbca_KYTE.sh
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName KYTE -sid KYTE -sysPassword earth01 -systemPassword earth01 -emConfiguration NONE -datafileDestination /oracle/dbawork/KYTE/oradata -recoveryAreaDestination /oracle/dbawork/KYTE/oradata -storageType FS -datafileJarLocation $ORACLE_HOME/assistants/dbca/templates -characterSet AL32UTF8 -nationalCharacterSet UTF8 -totalMemory 2096 -registerWithDirService false -obfuscatedPasswords false -sampleSchema false -oratabLocation /etc/oratab

here we logged into server “neeraj″ and using vi editor created file called ‘dbca_KYTE.sh’ where mentioned whole command to perform database creation operation and provided necessary permission. All Directories mentioned in the command has already been created.

2. Now we can run the file ‘dbca_KYTE.sh’ to create database automatically in the backend but it will show the result in the foreground and simultaneously write the log into a logfile. Below is the demonstration:

[oracle@neeraj]$ ./dbca_KYTE.sh
Copying database files
1% complete
3% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file “/u01/app/oracle/cfgtoollogs/dbca/KYTE/KYTE.log” for further details.

3. If you open the above log file(/u01/app/oracle/cfgtoollogs/dbca/KYTE/KYTE.log) you will see the result the as follows :

[oracle@neeraj]$ cat /u01/app/oracle/cfgtoollogs/dbca/KYTE/KYTE.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/KYTE.
Database Information:
Global Database Name:KYTE
System Identifier(SID):KYTE
[oracle@neeraj]$

4. Now lets see database status as follows :

[oracle@neeraj]$ . oraenv
ORACLE_SID = [DRPROC] ? DCPROC
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@neeraj]$ sqlplus “/as sysdba”

SQL*Plus: Release 11.2.0.3.0 Production on Tue May 27 20:20:16 2014

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 OLAP, Data Mining and Real Application Testing options

SQL> select instance_name, status from v$instance;

INSTANCE_NAME STATUS
------------- ------
DCPROC          OPEN

SQL>

Here we have successfully created database called “DCPROC” :)

No comments:

Post a Comment