Skip to Main Content
  • Questions
  • Using dbca -silent -createTemplateFromDB xxxxxx command to create template file?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Quanwen.

Asked: August 13, 2017 - 11:00 am UTC

Last updated: February 25, 2020 - 8:42 am UTC

Version: 11.2.0.4.0

Viewed 10K+ times! This question is

You Asked

hello,
i use ' dbca -silent -createTemplateFromDB -sourceDB host:port:sid -templateName sidbak -sysDBAUserName xxxxxx -sysDBAPassword xxxxxx' to generate template file,
for example,
[oracle@orcl13 ~]$ dbca -silent -createTemplateFromDB -sourceDB orcl13:1521:orcl13 -templateName orcl13bak -sysDBAUserName sys -sysDBAPassword sys
Creating a template from the database
10% complete
20% complete
30% complete
40% complete
50% complete
60% complete
70% complete
80% complete
90% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent.log_2017-08-10_04-44-42-PM" for further details.

later,i found that there is a template file 'orcl13bak.dbt' in '/u01/app/oracle/product/11.2.0/db_1/assistants/dbca/templates', and why has no 'orcl13bak.ctl' or 'orcl13bak.dfb' about two seed template files ?

[oracle@orcl13 ~]$ cd /u01/app/oracle/product/11.2.0/db_1/assistants/dbca/templates/
[oracle@orcl13 templates]$ ls -lrht
total 295M
-rw-r--r-- 1 oracle oinstall 12K Apr 28 10:38 New_Database.dbt
-rwxr-xr-x 1 oracle oinstall 9.3M Apr 28 10:38 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall 263M Apr 28 10:38 Seed_Database.dfb
-rw-r--r-- 1 oracle oinstall 5.0K Apr 28 10:38 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall 4.9K Apr 28 10:38 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 21M Apr 28 10:38 example01.dfb
-rwxr-xr-x 1 oracle oinstall 1.5M Apr 28 10:38 example.dmp
-rw-r----- 1 oracle oinstall 32K Aug 10 16:51 orcl13bak.dbt

because after installing oracle database software,there are some default template file 'General_Purpose.dbc','Seed_Database.ctl' and 'Seed_Database.dfb' and etc.
and in dbca of GUI (Graphical User Interface),it has option about 'from an existing database (structure as well as data)',if do this,could generate three template files of seed database,such as 'orcl13bak.dbt','orcl13bak.dfb' and 'orcl13bak.ctl'.

please give me some advices about 'dbca -silent ......' to create a template file,thanks!

Best Regards
Quanwen Zhao

and Connor said...

Sorry, I'm not sure what it is exactly you are asking. I just did a template generation, eg

C:\Users\hamcdc>dbca -silent -createTemplateFromDB -sourceDB orcl -templateName orclbak -sysDBAUserName system -sysDBAPassword oracle
Creating a template from the database
10% complete
20% complete
30% complete
40% complete
50% complete
60% complete
70% complete
80% complete
90% complete
100% complete
Look at the log file "c:\oracle\cfgtoollogs\dbca\silent.log_2017-08-17_11-17-58-AM" for further details.


and when I fired up dbca, the template was there as expected

DBCA_TEMPLATE

Is your experience different ?

Rating

  (11 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

is there two seed template files ('orclbak.dfb' and 'orclbak.ctl') ?

Quanwen Zhao, August 17, 2017 - 7:31 am UTC

I only wanna know whether has generated by another two seed template files about 'orclbak.dfb' and 'orclbak.ctl' in your environment.
As you know,after installing oracle db successfully,usually there are some default template files (such as Seed_Database.dfb,Seed_Database.ctl,General_Purpose.dbc and etc.) in path of '$ORACLE_HOME/assistants/dbca/templates'.
And if creating a template file from an existing database (structure as well as data) in dbca's GUI,it has this option to choose,this could generate seed template files.
But dbca -silent mode why not ? i have only orcl13bak.dbt in my test environment,and which parameter added to 'dbca -silent -createTemplateFromDB -sourceDB host:port:sid -templateName orcl13bak xxxxxx' to implement this function ?

By the way, how to attach your screenshot ? i mean to attach my two screenshot for your understanding easily.

Best Regards
Quanwen Zhao

Seed Database Files

paul, August 17, 2017 - 1:56 pm UTC

I think the mechanism now for creating a template DB with data is to use the --createCloneTemplate rather than the --createTemplateFromDB.

This process will package up an RMAN Cold Backup of your source DB that can be used to populate the target.
That is how the .ctl and .dfb's are generated.

https://docs.oracle.com/cd/E17559_01/em.111/e16599/appdx_creating_db_templates.htm
Connor McDonald
August 18, 2017 - 12:48 pm UTC

nice input

createCloneTemplate output

paul, August 17, 2017 - 7:04 pm UTC

[oracle@localhost db_1]$ dbca -silent -createCloneTemplate -sourceDB orcl12c -templateName pdbClone -maintainFileLocations false -sysDBAPassword oracle -sysDBAUserName sys
Gathering information from the source database
4% complete
8% complete
13% complete
17% complete
22% complete
Backup datafiles 
28% complete
88% complete
Creating template file
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent.log_2017-08-17_02-57-03-PM" for further details.


and the files are shown here

[oracle@localhost u01]$ find . -type f -name 'pdbClone*.*'
./app/oracle/product/12.2/db_1/assistants/dbca/templates/pdbClone.dfb1
./app/oracle/product/12.2/db_1/assistants/dbca/templates/pdbClone.dfb2
./app/oracle/product/12.2/db_1/assistants/dbca/templates/pdbClone.dfb3
./app/oracle/product/12.2/db_1/assistants/dbca/templates/pdbClone.ctl
./app/oracle/product/12.2/db_1/assistants/dbca/templates/pdbClone.dbc




createCloneTemplate is OK

Quanwen Zhao, August 18, 2017 - 2:29 am UTC

Hello,paul
Thank you very much and it's my what wanna to do!
Following your suggestion about with parameter '-cleateCloneTemplate',it generated seed template 'oracdgbak.dfb','oracdgbak.ctl' and 'oracdgbak.dbc'.
By the way,my test environment is Oracle RAC 11.2.0.4.0 and i use ASM diskgroup '+DATA' to storage data,at the same time,i see some contents of my 'oracdgbak.dbc',as follows,
......
<InitParamAttributes>
      <InitParams>
         <initParam name="db_create_file_dest" value="{ORACLE_BASE}/oradata"/>
......
<initParam name="log_archive_dest_1" value="'LOCATION={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/+ARCH'"/>
......
 <initParam name="control_files" value="(&quot;{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/current.259.952166659&quot;, &quot;{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/current.261.952166683&quot;, &quot;{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/current.262.952166681&quot;)"/>
......
</InitParamAttributes>
<StorageAttributes>
      <DataFiles>
         <Location>{ORACLE_HOME}/assistants/dbca/templates/oracdgbak.dfb</Location>
         <SourceDBName>oracdg</SourceDBName>
         <Name id="1" Tablespace="SYSTEM" Contents="PERMANENT" Size="740" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/system.272.952102331</Name>
......
 </DataFiles>
<ControlfileAttributes id="Controlfile">
         <maxDatafiles>100</maxDatafiles>
         <maxLogfiles>16</maxLogfiles>
         <maxLogMembers>3</maxLogMembers>
         <maxLogHistory>1</maxLogHistory>
         <maxInstances>8</maxInstances>
         <image name="current.259.952166659" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
         <image name="current.261.952166683" filepath="{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/"/>
         <image name="current.262.952166681" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
      </ControlfileAttributes>
<RedoLogGroupAttributes id="1">
         <reuse>false</reuse>
         <fileSize unit="KB">51200</fileSize>
         <Thread>1</Thread>
         <member ordinal="0" memberName="group_1.277.952179539" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
      </RedoLogGroupAttributes>
......
</StorageAttributes>

Such as the path of controlfiles,datafiles,tempfiles and redo logfiles, have i need to change it to '+DATA' if i use my created template file to clone another db 'racdg' ? I think that using ASM,oracle will auto generate directory of dbname in '+DATA' and subdir of 'DATAFILE','CONTROLFILE','ONLINELOG','PARAMETERFILE' and 'TEMPFILE'.

Regards
Quanwen Zhao

ASM etc.

paul, August 18, 2017 - 12:38 pm UTC

Hello Quanwen Zhao

Glad I could help out a little bit.
Unfortunately ASM is not something I have a lot of experience with and I don't have 11gR2 here to play with.


Looking at the dbca options for creating the Database from the template I see
-storageType [FS|ASM] so you can target ASM as the new storage Type

If selecting ASM there are additional parameters
When ASM is specified, specify the following additional parameters:

-asmsnmpPassword: ASMSNMP password for ASM monitoring. This parameter is optional.
-diskGroupName: Database area disk group name. This parameter is required.
-recoveryGroupName: Recovery area disk group name. This parameter is required

I found these in the 12.2 Administrators Guide.
Your Mileage may vary in 11.2
I don;t think there is anything you need to do on your template end of things.

Try it and see!

i need to manual modify path of archive log is '+ARCH'

Quanwen Zhao, August 21, 2017 - 9:38 am UTC

hello,paul
according to your suggestions,i put parameter 'storageType=ASM diskGroupName=DATA' into response file 'dbca_racdg.rsp',then execute 'dbca -silent -responseFile /app/oracle/product/11.2.0/db_1/assistants/dbca/dbca_racdg.rsp',a moment later,RAC database 'racdg' is generated.
at the same time,i found the path of datafile,controlfile,logfile,tempfile and parameterfile is right(all is in ASM diskgroup '+DATA/racdg'),but path of archivelog is wrong(such as '/app/oracle/oradata/racdg/+ARCH'),because it's '<initParam name="log_archive_dest_1" value="'LOCATION={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/+ARCH'"/>' in template file 'oracdgbak.dbc' acquiescently,so when i need to change it to be '+ARCH',it's OK.
in the other hand, the number of controlfile is only one(i have no used db_recovery_file_dest),and my original RAC db 'oracdg' has three numbers of controlfile,even though i modify template file,it's useless.

Regards
Quanwen Zhao
Connor McDonald
August 24, 2017 - 1:55 am UTC

in the other hand, the number of controlfile is only one


Have you tried

-maintainFileLocations true


parameter '-maintainFileLocations true' is very nice

Quanwen Zhao, August 24, 2017 - 9:03 am UTC

Hello,Connor
Thanks for your advices,about parameter '-maintainFileLocations' really modify to true path of all files in template file that has been generated by 'dbca -silent -createTemplateFromDB xxxxxx' and 'dbca -silent -createCloneTemplate xxxxxx'.
My issue has solved now,by the way,how do you upload your screenshot(on your first answer) to AskTOM and because you are administrator? we couldn't do this operation(I know it could upload picture on oracle community)?
Connor McDonald
August 26, 2017 - 3:28 am UTC

In terms of screen shots etc... *we* can do it because we're the admins/owners of the site.

We are planning on file upload facility for customers. There is no problem with the functionality on doing it (Apex does it easily) - it is more then about the legal ramifications, eg what if someone uploads confidential data, or what if someone uploads illegal content (pornography) etc etc... So we're just sorting through all that before we make it available as a general function

About uploading screenshot actually need to consider more

A reader, August 26, 2017 - 9:12 am UTC

Yep,i feel what you said is right.Although we can put more code into label '
......
',sometimes picture is not important and it is only visualized for us.
By the way,about numbers of controlfile,how to generate more than one? Is this problem related to managed method(Policy and Admin) about files of oracle or has it changed in Oracle 12cRx(x is 1 or 2) or whether the method of manual create database could be alterant?

Regards
Quanwen Zhao
Connor McDonald
August 28, 2017 - 5:33 am UTC

Manual method in DBCA lets you nominate as many as you like.

Presumably you can use "-initParams" to nominate whatever parameters you like (including control_files)

how to comprehend SQL statement below ?

Quanwen Zhao, August 29, 2017 - 2:57 am UTC

Hi,Connor
Although "-initParams" could nominate control_files,i only wanna know whether generate three numbers of controlfiles automatically after using template that i manual create with 'DBCA -silent'.
Such as,
firstly,my template files check as follows,
[oracle@oracdg1 templates]$ ls -lrht
......
-rw-r----- 1 oracle asmadmin 281M Aug 18 09:41 oracdgbak.dfb
-rw-r----- 1 oracle asmadmin 9.4M Aug 18 09:41 oracdgbak.ctl
-rw-r----- 1 oracle oinstall 7.1K Aug 21 16:37 oracdgbak.dbc
......

secondly,generate scripts before creating RAC DB 'racdg',script files' directory structure as follows,
[oracle@oracdg1 scripts]$ ls -lrth
......
-rw-r----- 1 oracle oinstall 9.4M Aug 18 12:23 tempControl.ctl
-rw-r----- 1 oracle oinstall 2.1K Aug 18 12:23 initracdgTempOMF.ora
-rw-r----- 1 oracle oinstall 2.0K Aug 18 12:23 cloneDBCreation.sql
......

chief of all, this SQL script 'cloneDBCreation.sql',part of content as follows,
[oracle@oracdg1 scripts]$ cat cloneDBCreation.sql
SET VERIFY OFF
connect "SYS"/"&&sysPassword" as SYSDBA
......
column ctl_files NEW_VALUE ctl_files;
select concat('control_files=''', concat(replace(value, ', ', ''','''), '''')) ctl_files from v$parameter where name ='control_files';
......

about above SQL statement,how to comprehend ?

Regards
Quanwen Zhao
Connor McDonald
August 31, 2017 - 1:49 am UTC

You could, but if your control files are in ASM, then you'll probably need to do it after the fact because the file names are generated. So you could get the name of your current controlfile, let say it is:

+DATA/MYDB/controlfile/current.123.456

and do this:

alter system set control_files='+MYDG1','+MYDG2',etc,etc scope=spfile;

rman target /
shutdown immediate
startup nomount
restore controlfile from '+DATA/MYDB/controlfile/current.123.456';
alter database mount;
alter database open;

It's a good way for creating more than one CONTROLFILE in ASM

Quanwen Zhao, August 31, 2017 - 2:10 am UTC

Thank you Connor sincerely,I will try it!
Exactly,it's a good way for creating more than one CONTROLFILE in ASM.

The best instruction so far with practical example

Leah Demetrius, February 21, 2020 - 4:18 am UTC

Out of hundreds of documents and instructions on the web, this is the only instruction that smoothly sailed me through silent dbca template creation from the 1st try.

Thank you so much Tom!




Connor McDonald
February 25, 2020 - 8:42 am UTC

glad we could help!

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database