oracle 11g使用DBCA以非交互(静默)方式创建数据库

使用DBCA以非交互(静默)方式创建数据库
通过执行dbca -h | -help来查看帮助选项
[oracle@jyrac1 ~]$ dbca -help

dbca  [-silent | -progressOnly | -customCreate] {  }  | { [ [options] ] -responseFile   } [-continueOnNonFatalErrors ]
Please refer to the manual for details.
You can enter one of the following command:
创建数据库的参数如下:
Create a database by specifying the following parameters:
        -createDatabase
                -templateName  现有模板的名称
                [-cloneTemplate]
                -gdbName   全局数据库名
                [-policyManaged | -adminManaged ]
                        [-createServerPool ]
                        [-force ]
                        -serverPoolName 
                        -[cardinality ]
                [-sid ] 数据库系统标识符
                [-sysPassword ]
                [-systemPassword ]
                [-emConfiguration 
                        -dbsnmpPassword 
                        -sysmanPassword 
                        [-hostUserName 
                         -hostUserPassword 
                         -backupSchedule ]
                        [-smtpServer 
                         -emailAddress ]
                        [-centralAgent ]]
                [-disableSecurityConfiguration 
                [-datafileDestination  所有数据文件的目标位置 |  -datafileNames ]
                [-redoLogFileSize ]
                [-recoveryAreaDestination ]
                [-datafileJarLocation  ] 数据文件 jar 的位置, 只用于复制数据库的创建
                [-storageType < FS | ASM >
                        [-asmsnmpPassword     ]
                         -diskGroupName   
                         -recoveryGroupName       
                [-characterSet ] 数据库的字符集
                [-nationalCharacterSet  ] 数据库的国家字符集
                [-registerWithDirService 
                        -dirServiceUserName     目录服务的用户名
                        -dirServicePassword     目录服务的口令
                        -walletPassword    ]
                [-listeners  ] 监听程序列表, 该列表用于配置具有如下对象的数据库
                [-variablesFile   ]] 用于模板中成对变量和值的文件名
                [-variables  ]
                [-initParams ]
                [-memoryPercentage ]
                [-automaticMemoryManagement ]
                [-totalMemory ]
                [-databaseType ]]

Configure a database by specifying the following parameters:
        -configureDatabase
                -sourceDB    
                [-sysDBAUserName     
                 -sysDBAPassword     ]
                [-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword 
                        -dirServiceUserName    
                        -dirServicePassword    
                        -walletPassword    ]
                [-disableSecurityConfiguration 
                [-enableSecurityConfiguration 
                [-emConfiguration 
                        -dbsnmpPassword 
                        -symanPassword 
                        [-hostUserName 
                         -hostUserPassword 
                         -backupSchedule ]
                        [-smtpServer 
                         -emailAddress ]
                        [-centralAgent ]]

使用现有数据库创建模板的参数如下:
Create a template from an existing database by specifying the following parameters:
        -createTemplateFromDB
                -sourceDB    ::> < 服务采用 :: 格式
                -templateName         新的模板名
                -sysDBAUserName         具有SYSDBA权限的用户名
                -sysDBAPassword      具有SYSDBA权限的用户名的口令
                [-maintainFileLocations ]

使用现有数据库创建复制模板的参数如下:
Create a clone template from an existing database by specifying the following parameters:
        -createCloneTemplate
                -sourceSID      源数据库 sid
                -templateName        新的模板名
                [-sysDBAUserName      具有SYSDBA权限的用户名
                 -sysDBAPassword     ] 具有SYSDBA权限的用户名的口令
                [-maintainFileLocations ]
                [-datafileJarLocation       ] 存放压缩格式数据文件的目录

Generate scripts to create database by specifying the following parameters:
        -generateScripts
                -templateName 
                -gdbName 
                [-scriptDest       ]
通过指定以下参数来删除数据库
Delete a database by specifying the following parameters:
        -deleteDatabase
                -sourceDB    
                [-sysDBAUserName     
                 -sysDBAPassword     ]

使用silent模式可以通过数据库创建模析和通过模板来创建数据库

通过模板来创建数据库

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11g -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration LOCAL
Enter SYS user password:

Enter SYSTEM user password:

Enter DBSNMP user password:

Enter SYSMAN user password:

Copying database files
1% complete
3% complete
11% complete
18% complete
26% 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/ora11g/ora11g.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
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/ora11g.
Database Information:
Global Database Name:ora11g
System Identifier(SID):ora11gThe Database Control URL is https://jyrac1:5500/em

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman/config/emkey.ora.   Please ensure this file is backed up as the encrypted data will become unusable if this file is lost.

数据库创建成功执行下面命令查看ora11g的进程信息

[oracle@jyrac1 ~]$ ps -ef | grep ora11g
oracle    6014     1  0 09:42 pts/1    00:00:00 /u01/app/oracle/11.2.0/db/perl/bin/perl /u01/app/oracle/11.2.0/db/bin/emwd.pl dbconsole /u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman/log/emdb.nohup
oracle    6032  6014  4 09:42 pts/1    00:00:44 /u01/app/oracle/11.2.0/db/jdk/bin/java -server -Xmx384M -XX:MaxPermSize=400M -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -DORACLE_HOME=/u01/app/oracle/11.2.0/db -Doracle.home=/u01/app/oracle/11.2.0/db/oc4j -Doracle.oc4j.localhome=/u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman -DEMSTATE=/u01/app/oracle/11.2.0/db/jyrac1_ora11g -Doracle.j2ee.dont.use.memory.archive=true -Djava.protocol.handler.pkgs=HTTPClient -Doracle.security.jazn.config=/u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/jazn.xml -Djava.security.policy=/u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/java2.policy -Djavax.net.ssl.KeyStore=/u01/app/oracle/11.2.0/db/sysman/config/OCMTrustedCerts.txt-Djava.security.properties=/u01/app/oracle/11.2.0/db/oc4j/j2ee/home/config/jazn.security.props -DEMDROOT=/u01/app/oracle/11.2.0/db/jyrac1_ora11g -Dsysman.md5password=true -Drepapi.oracle.home=/u01/app/oracle/11.2.0/db -Ddisable.checkForUpdate=true -Doracle.sysman.ccr.ocmSDK.websvc.keystore=/u01/app/oracle/11.2.0/db/jlib/emocmclnt.ks -Dice.pilots.html4.ignoreNonGenericFonts=true -Djava.awt.headless=true -jar /u01/app/oracle/11.2.0/db/oc4j/j2ee/home/oc4j.jar -config /u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/server.xml
oracle    6083     1  1 09:42 ?        00:00:11 oracleora11g (LOCAL=NO)
oracle    6132     1  0 09:42 ?        00:00:02 oracleora11g (LOCAL=NO)
oracle    6220     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6466     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6468     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6480     1  0 09:43 ?        00:00:02 oracleora11g (LOCAL=NO)
oracle    6658     1  0 09:43 ?        00:00:01 oracleora11g (LOCAL=NO)
oracle    6664     1  1 09:43 ?        00:00:12 oracleora11g (LOCAL=NO)
oracle    6718     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    6720     1  0 09:43 ?        00:00:00 oracleora11g (LOCAL=NO)
oracle    8954     1  0 09:58 ?        00:00:00 ora_j000_ora11g
oracle    8956     1  0 09:58 ?        00:00:00 ora_j001_ora11g
oracle    8962 29918  0 09:59 pts/1    00:00:00 grep ora11g
oracle   31058     1  0 09:40 ?        00:00:00 ora_pmon_ora11g
oracle   31060     1  0 09:40 ?        00:00:00 ora_vktm_ora11g
oracle   31064     1  0 09:40 ?        00:00:00 ora_gen0_ora11g
oracle   31066     1  0 09:40 ?        00:00:00 ora_diag_ora11g
oracle   31068     1  0 09:40 ?        00:00:00 ora_dbrm_ora11g
oracle   31070     1  0 09:40 ?        00:00:00 ora_psp0_ora11g
oracle   31072     1  0 09:40 ?        00:00:00 ora_dia0_ora11g
oracle   31074     1  0 09:40 ?        00:00:00 ora_mman_ora11g
oracle   31076     1  0 09:40 ?        00:00:00 ora_dbw0_ora11g
oracle   31078     1  0 09:40 ?        00:00:00 ora_lgwr_ora11g
oracle   31080     1  0 09:40 ?        00:00:00 ora_ckpt_ora11g
oracle   31082     1  0 09:40 ?        00:00:00 ora_smon_ora11g
oracle   31084     1  0 09:40 ?        00:00:00 ora_reco_ora11g
oracle   31086     1  0 09:40 ?        00:00:00 ora_mmon_ora11g
oracle   31088     1  0 09:40 ?        00:00:00 ora_mmnl_ora11g
oracle   31090     1  0 09:40 ?        00:00:00 ora_d000_ora11g
oracle   31092     1  0 09:40 ?        00:00:00 ora_s000_ora11g
oracle   31161     1  0 09:40 ?        00:00:00 ora_qmnc_ora11g
oracle   31177     1  0 09:40 ?        00:00:00 ora_cjq0_ora11g
oracle   31262     1  0 09:40 ?        00:00:00 ora_q000_ora11g
oracle   31264     1  0 09:40 ?        00:00:00 ora_q001_ora11g
oracle   31344     1  0 09:41 ?        00:00:00 ora_smco_ora11g
oracle   31346     1  0 09:41 ?        00:00:00 ora_w000_ora11g

以silent方式来删除数据库

[oracle@jyrac1 ~]$ dbca -silent -deleteDatabase -sourceDB ora11g -sysDBAUserName sys -sysDBAPassword zzh_2046
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 "/u01/app/oracle/cfgtoollogs/dbca/ora11g.log" for further details.

[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/ora11g.log
The Database Configuration Assistant will delete the Oracle instance and datafiles for your database. All information in the database will be destroyed. Do you want to proceed?
Connecting to database
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 14%
DBCA_PROGRESS : 19%
DBCA_PROGRESS : 23%
DBCA_PROGRESS : 28%
DBCA_PROGRESS : 47%
Updating network configuration files
DBCA_PROGRESS : 48%
DBCA_PROGRESS : 52%
Deleting instance and datafiles
DBCA_PROGRESS : 76%
DBCA_PROGRESS : 100%
Database deletion completed.

删除数据库后执行下面的命令来查看ora11g进程信息发现没有了

[oracle@jyrac1 ~]$ ps -ef | grep ora11g
oracle   11194 29918  0 10:05 pts/1    00:00:00 grep ora11g



[oracle@jyrac1 ~]$ ps -ef | grep pmon
oracle    9288     1  0 Apr04 ?        00:00:07 ora_pmon_jycs
oracle   11285 29918  0 10:06 pts/1    00:00:00 grep pmon

使用现有数据库jycs来创建模板

[oracle@jyrac1 ~]$ dbca -silent -createTemplateFromDB -sourceDB jycs -templateName jycstemplate -sysDBAUserName sys -sysDBAPassword zzh_2046
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" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/silent.log
Creating a template from the database
DBCA_PROGRESS : 10%
DBCA_PROGRESS : 20%
DBCA_PROGRESS : 30%
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 80%
DBCA_PROGRESS : 90%
DBCA_PROGRESS : 100%
The template "jycstemplate" creation completed.

[oracle@jyrac1 templates]$ cd /u01/app/oracle/11.2.0/db/assistants/dbca/templates
[oracle@jyrac1 templates]$ ls -lrt
total 285632
-rw-r--r-- 1 oracle oinstall     11492 Feb 25  2009 New_Database.dbt
-rw-r--r-- 1 oracle oinstall      5106 Aug 15  2009 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall      4986 Aug 15  2009 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 258654208 Aug 15  2009 Seed_Database.dfb
-rwxr-xr-x 1 oracle oinstall   9748480 Aug 15  2009 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall   1179648 Aug 15  2009 example.dmp
-rwxr-xr-x 1 oracle oinstall  22544384 Aug 15  2009 example01.dfb
-rw-r----- 1 oracle oinstall      5124 Mar 24 13:31 jycs.dbc
-rw-r----- 1 oracle oinstall     13476 Apr  8 10:12 jycstemplate.dbt

使用现有数据库jycs创建带数据文件的模板

[oracle@jyrac1 ~]$ dbca -silent -createCloneTemplate -sourceDB jycs -templateName jycsCloneTemplate -sysDBAUserName sys -sysDBAPassword  zzh_2046 -datafileJarLocation /u01/app/oracle/11.2.0/db/assistants/dbca/templates
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/silent0.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/silent0.log
Gathering information from the source database
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 8%
DBCA_PROGRESS : 13%
DBCA_PROGRESS : 17%
DBCA_PROGRESS : 22%
Backup datafiles
DBCA_PROGRESS : 28%
DBCA_PROGRESS : 88%
Creating template file
DBCA_PROGRESS : 100%
The generation of the clone database template "jycsCloneTemplate" is successful.

查看生成的模板文件

[oracle@jyrac1 templates]$ ls -lrt
total 621628
-rw-r--r-- 1 oracle oinstall     11492 Feb 25  2009 New_Database.dbt
-rw-r--r-- 1 oracle oinstall      5106 Aug 15  2009 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall      4986 Aug 15  2009 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 258654208 Aug 15  2009 Seed_Database.dfb
-rwxr-xr-x 1 oracle oinstall   9748480 Aug 15  2009 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall   1179648 Aug 15  2009 example.dmp
-rwxr-xr-x 1 oracle oinstall  22544384 Aug 15  2009 example01.dfb
-rw-r----- 1 oracle oinstall      5124 Mar 24 13:31 jycs.dbc
-rw-r----- 1 oracle oinstall     13476 Apr  8 10:12 jycstemplate.dbt
-rw-r----- 1 oracle oinstall 333955072 Apr  8 10:24 jycsCloneTemplate.dfb
-rw-r----- 1 oracle oinstall   9748480 Apr  8 10:24 jycsCloneTemplate.ctl
-rw-r----- 1 oracle oinstall      4903 Apr  8 10:24 jycsCloneTemplate.dbc

利用带数据文件的模板jycsCloneTemplate生成克隆数据库

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName jycsCloneTemplate.dbc -gdbName test -sid test -datafileJarLocation /u01/app/oracle/11.2.0/db/assistants/dbca/templates -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:

Enter SYSTEM user password:

Copying database files
1% complete
3% complete
11% complete
18% complete
26% 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/test/test.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/test/test.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
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/test.
Database Information:
Global Database Name:test
System Identifier(SID):test
[oracle@jyrac1 ~]$ ps -ef  | grep pmon
oracle   12381     1  0 10:22 ?        00:00:00 ora_pmon_jycs
oracle   14396     1  0 10:39 ?        00:00:00 ora_pmon_test
oracle   14689 29918  0 10:41 pts/1    00:00:00 grep pmon

利用不带数据文件的模板生成新的数据库

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName New_Database.dbt -gdbname jytest  -sid jytest -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:

Enter SYSTEM user password:

Creating and starting Oracle instance
1% complete
3% complete
Creating database files
4% complete
7% complete
Creating data dictionary views
8% complete
9% complete
10% complete
11% complete
12% complete
13% complete
14% complete
16% complete
17% complete
18% complete
19% complete
Adding Oracle JVM
25% complete
30% complete
36% complete
38% complete
Adding Oracle Text
40% complete
41% complete
Adding Oracle XML DB
43% complete
44% complete
45% complete
49% complete
Adding Oracle Multimedia
50% complete
60% complete
Adding Oracle OLAP
61% complete
62% complete
63% complete
64% complete
Adding Oracle Spatial
65% complete
66% complete
67% complete
71% complete
Adding Enterprise Manager Repository
73% complete
75% complete
Adding Oracle Application Express
78% complete
82% complete
Adding Oracle Warehouse Builder
86% complete
90% complete
Completing Database Creation
91% complete
92% complete
93% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jytest/jytest.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/jytest/jytest.log
Creating and starting Oracle instance
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
Creating database files
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 7%
Creating data dictionary views
DBCA_PROGRESS : 8%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 10%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 12%
DBCA_PROGRESS : 13%
DBCA_PROGRESS : 14%
DBCA_PROGRESS : 16%
DBCA_PROGRESS : 17%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 19%
Adding Oracle JVM
DBCA_PROGRESS : 25%
DBCA_PROGRESS : 30%
DBCA_PROGRESS : 36%
DBCA_PROGRESS : 38%
Adding Oracle Text
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 41%
Adding Oracle XML DB
DBCA_PROGRESS : 43%
DBCA_PROGRESS : 44%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 49%
Adding Oracle Multimedia
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 60%
Adding Oracle OLAP
DBCA_PROGRESS : 61%
DBCA_PROGRESS : 62%
DBCA_PROGRESS : 63%
DBCA_PROGRESS : 64%
Adding Oracle Spatial
DBCA_PROGRESS : 65%
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 67%
DBCA_PROGRESS : 71%
Adding Enterprise Manager Repository
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 75%
Adding Oracle Application Express
DBCA_PROGRESS : 78%
DBCA_PROGRESS : 82%
Adding Oracle Warehouse Builder
DBCA_PROGRESS : 86%
DBCA_PROGRESS : 90%
Completing Database Creation
DBCA_PROGRESS : 91%
DBCA_PROGRESS : 92%
DBCA_PROGRESS : 93%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/jytest.
Database Information:
Global Database Name:jytest
System Identifier(SID):jytest

发表评论

电子邮件地址不会被公开。