Views

Thursday, December 22, 2016

Oracle - Database Creation in Silent Mode 12c

Oracle - Database Creation in Silent Mode 12c

You might have to do an unattended installation or you have to perform similar installations on multiple systems
or you have to create database where X Window software is not installed or you want to schedule database creation
through cron. All this can be achieved through silent mode installation.

In Silent mode, database can be created either using
1. Using response file or
2. Command line

[oracle@testing ~]$ dbca -help

dbca  [-silent | -progressOnly] {<command> <options> }  | { [<command> [options] ] -responseFile  <response file > } [-continueOnNonFatalErrors <true | false>]

 <command> : -createDatabase | -configureDatabase | -createTemplateFromDB | -createCloneTemplate | -generateScripts | -deleteDatabase | -createPluggableDatabase | -unplugDatabase | -deletePluggableDatabase | -configurePluggableDatabase

Enter "dbca -<command> -help" for more option

-- response file example

1. dbca -progress_only -responseFile <response file>                  
   Display a progress bar depicting progress of database creation process.                                                        
                                                                                                                                                                  
2. dbca -silent -responseFile <response file>                      
   Creates database silently. No user interface is displayed.      
                                                                                                                                                                  
3. dbca -silent -createDatabase -cloneTemplate -responseFile <response file>                    
   Creates database silently with clone template. The template in responsefile is a clone template.                                
                                                                                                                                                                  
4. dbca -silent -deleteDatabase -responseFile <response file>      
   Deletes database silently.     

$ dbca -silent -responseFile ./dbca.rsp

dbca -silent -createDatabase \
 -templateName General_Purpose.dbc \
 -gdbname cdb12 -sid cdb12 -responseFile NO_VALUE \
 -characterSet AL32UTF8 \
 -sysPassword oracle123 \
 -systemPassword oracle123 \
 -emConfiguration NONE \
 -datafileDestination /u03/app/oracle/oradata/cdb12 \
 -createAsContainerDatabase true \
 -numberOfPDBs 2 \
 -pdbName pdb12 \
 -pdbAdminPassword oracle123 \
 -databaseType MULTIPURPOSE \
 -automaticMemoryManagement false \
 -storageType FS \
 -memoryPercentage 15 \
 -ignorePreReqs

[oracle@testing ~]$ dbca -silent -createDatabase \
>  -templateName General_Purpose.dbc \
>  -gdbname cdb12 -sid cdb12 -responseFile NO_VALUE \
>  -characterSet AL32UTF8 \
>  -sysPassword oracle123 \
>  -systemPassword oracle123 \
>  -emConfiguration NONE \
>  -datafileDestination /u03/app/oracle/oradata/cdb12 \
>  -createAsContainerDatabase true \
>  -numberOfPDBs 2 \
>  -pdbName pdb12 \
>  -pdbAdminPassword oracle123 \
>  -databaseType MULTIPURPOSE \
>  -automaticMemoryManagement false \
>  -storageType FS \
>  -memoryPercentage 15 \
>  -ignorePreReqs
Copying database files
1% complete
2% complete
8% complete
13% complete
19% complete
27% complete
Creating and starting Oracle instance
29% complete
32% complete
33% complete
34% complete
38% complete
42% complete
43% complete
45% complete
Completing Database Creation
48% complete
51% complete
53% complete
62% complete
70% complete
72% complete
Creating Pluggable Databases
78% complete
83% complete
100% complete
Look at the log file "/u03/app/oracle/cfgtoollogs/dbca/cdb12/cdb12.log" for further details.

-- If you check alert log, you can see creation of SEED and PDB database creation.

cd /u03/app/oracle/diag/rdbms/cdb12/cdb12/trace
[oracle@testing trace]$ cat alert_cdb12.log |grep -i "Completed: Create Pluggable"

Completed: CREATE PLUGGABLE DATABASE PDB$SEED AS CLONE  USING '/u03/app/oracle/product/12.1.0/db_1/assistants/dbca/templates//pdbseed.xml'  source_file_name_convert = ('/oradata/seeddata/pdbseed/temp01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/pdbseed_temp012016-12-22_02-18-07-AM.dbf',
'/oradata/seeddata/pdbseed/system01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/system01.dbf',
'/oradata/seeddata/pdbseed/sysaux01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/sysaux01.dbf') NOCOPY

Completed: CREATE PLUGGABLE DATABASE pdb121 ADMIN USER PDBADMIN IDENTIFIED BY * ROLES=(CONNECT)  file_name_convert=('/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/sysaux01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdb121/sysaux01.dbf',
'/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/pdbseed_temp012016-12-22_02-18-07-AM.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdb121/temp012016-12-22_02-18-07-AM.dbf',
'/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/system01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdb121/system01.dbf')

Completed: CREATE PLUGGABLE DATABASE pdb122 ADMIN USER PDBADMIN IDENTIFIED BY * ROLES=(CONNECT)  file_name_convert=('/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/sysaux01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdb122/sysaux01.dbf',
'/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/pdbseed_temp012016-12-22_02-18-07-AM.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdb122/temp012016-12-22_02-18-07-AM.dbf',
'/u03/app/oracle/oradata/cdb12/cdb12/pdbseed/system01.dbf','/u03/app/oracle/oradata/cdb12/cdb12/pdb122/system01.dbf')

-- Verify database by logging in :

[oracle@testing ~]$ . oraenv
ORACLE_SID = [cdb12] ?
The Oracle base remains unchanged with value /u03/app/oracle
[oracle@testing ~]$ s
bash: s: command not found
[oracle@testing ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 22 04:24:45 2016

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select name from v$database;

NAME
---------
CDB12


SQL> select pdb_id, con_uid, pdb_name from dba_pdbs order by 1;

    PDB_ID    CON_UID PDB_NAME
---------- ---------- ------------------------------
         2 1333152744 PDB$SEED
         3  702246092 PDB121
         4 1163680132 PDB122

SQL> select con_id, name from v$pdbs;

    CON_ID NAME
---------- ------------------------------
         2 PDB$SEED
         3 PDB121
         4 PDB122

SQL> select con_id, name from v$datafile order by 1;
CON_ID NAME
-------- -----------------------------------------------------------
       1 /u03/app/oracle/oradata/cdb12/cdb12/users01.dbf
       1 /u03/app/oracle/oradata/cdb12/cdb12/sysaux01.dbf
       1 /u03/app/oracle/oradata/cdb12/cdb12/undotbs01.dbf
       1 /u03/app/oracle/oradata/cdb12/cdb12/system01.dbf
       2 /u03/app/oracle/oradata/cdb12/cdb12/pdbseed/system01.dbf
       2 /u03/app/oracle/oradata/cdb12/cdb12/pdbseed/sysaux01.dbf
       3 /u03/app/oracle/oradata/cdb12/cdb12/pdb121/system01.dbf
       3 /u03/app/oracle/oradata/cdb12/cdb12/pdb121/sysaux01.dbf
       3 /u03/app/oracle/oradata/cdb12/cdb12/pdb121/pdb121_users01.dbf
       4 /u03/app/oracle/oradata/cdb12/cdb12/pdb122/system01.dbf
       4 /u03/app/oracle/oradata/cdb12/cdb12/pdb122/sysaux01.dbf
       4 /u03/app/oracle/oradata/cdb12/cdb12/pdb122/pdb122_users01.dbf

12 rows selected.

SQL> select con_id, name from v$controlfile;

    CON_ID NAME
---------- -------------------------------------------------
         0 /u03/app/oracle/oradata/cdb12/cdb12/control01.ctl
         0 /u03/app/oracle/fast_recovery_area/cdb12/control02.ctl

-- to drop database in silent mode

$ dbca -silent -deleteDatabase -sourceDB cdb12 -sysDBAUserName sys -sysDBAPassword ora123

[oracle@testing ~]$ dbca -silent -deleteDatabase -sourceDB cdb12 -sysDBAUserName sys -sysDBAPassword ora123
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/u03/app/oracle/cfgtoollogs/dbca/cdb12.log" for further details.

No comments:

Post a Comment

Leave a Reply...