DBCA静默方式建库

  1. DBCA静默方式建库

本篇blog结构图:

 

使用DBCA的图形方式建库实在有诸多不便,但是使用静默方式建库就比较方便了,一个命令即可搞定

 

使用dbca安装oracle数据库实例也有差不多两种方法:

一种就是根据模板文件进行安装,在上文中提到了在oracle安装程序的安装文件夹下的response目录中有一个dbca.rsp文件就是dbca的模板文件。当然我们也可以通过复制这个模板文件来修改其中的内容来建立定制的数据库,在这个模板文件中对于各个参数的说明非常详细,对这个文件的内容在此不做说明。

另外一种就是根据oracle自身的数据库模板来建立数据库实例(模板文件位置:$ORACLE_HOME/assistants/dbca/templates/*.dbc

ORACLE为我们提供了几个dbc模板:

Data Warehouse 数据仓库

Transaction Processing 事务处理

General Purpose 一般用途

这几个模板是比较易用的模板,oracle针对不同的数据库用途做了专门的优化,当然我们也可以创建我们自己的模板(也是使用dbca命令),

 

 

首先说明一点,在安装之前需要注意的几个问题:

1、/etc/hosts文件中,本机的hostname必须和lo对应(如果你有改过hostname的话,需要修改该文件)

2、$ORACLE_HOME/network/admin/listener.ora文件必须配置服务器监听,为了保险起见,将tnsnames和sqlnet文件都配置了吧

3、在dbca命令中出现的文件参数,必须使用全路径

4、注意在使用dbca命令的时候各个同级别的参数的必要性,有些是必要的,有些是不必要的。具体可参考dbca -help

 

 

根据模版文件创建数据库:

dbca -silent -cloneTemplate -gdbName orcl -sid orcl -datafileDestination /u01/oradata -responseFile /mnt/hgfs/software/oracle/database/response/dbca.rsp

一些参数的说明:

-silent 指定dbca的静默安装方式

-cloneTemplate 指定自模版文件创建

-gdbName Global Database Name

-sid 创建数据库的sid

-datafileDestination 数据文件存放的目标路径

-responseFIle 模版文件的路径

 

 

根据Oracle提供的数据库模版创建数据库:

dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/template/Transaction_Processing.dbc -gdbName orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK

 

Silent模式采用命令行方式一次将所有信息提供给DBCA完成数据库的建立,在建立过程中不存在交互作用,所有的信息、错误和告警都写到日志文件中,只在结束时屏幕上打印出日志文件的位置,除此以外,没有其他的消息。

 

  1. 12c静默方式建库

 

[oracle@test ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname oradb.example.com -sid oradb -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration LOCAL

Enter SYS user password:

   

Enter SYSTEM user password:

   

Copying database files

1% complete

3% complete

11% complete

18% complete

26% complete

33% 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 "/12c/app/oracle/cfgtoollogs/dbca/oradb/oradb.log" for further details.

 

 

[oracle@test ~]$ export ORACLE_SID=oradb

[oracle@test ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 12.1.0.1.0 Production on Fri Jan 30 17:02:50 2015

 

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

 

 

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

 

SYS@oradb >show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cell_offloadgroup_name               string

db_file_name_convert                 string

db_name                              string      oradb

db_unique_name                       string      oradb

global_names                         boolean     FALSE

instance_name                        string      oradb

lock_name_space                      string

log_file_name_convert                string

pdb_file_name_convert                string

processor_group_name                 string

service_names                        string      oradb.example.com

SYS@oradb >

SYS@oradb >select name from v$datafile;

 

NAME

--------------------------------------------------------------------------------

/12c/app/oracle/oradata/oradb/system01.dbf

/12c/app/oracle/oradata/oradb/sysaux01.dbf

/12c/app/oracle/oradata/oradb/undotbs01.dbf

/12c/app/oracle/oradata/oradb/users01.dbf

  1. 11g静默方式建库

[oracle@testdb ora11g]$ dbca -help

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

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 <name of an existing template in default location or the complete template path>

        [-cloneTemplate]

        -gdbName <global database name>

        [-sid <database system identifier>]

        [-sysPassword <SYS user password>]

        [-systemPassword <SYSTEM user password>]

        [-emConfiguration <CENTRAL|LOCAL|ALL|NONE>

            -dbsnmpPassword <DBSNMP user password>

            -sysmanPassword <SYSMAN user password>

            [-hostUserName <Host user name for EM backup job>

             -hostUserPassword <Host user password for EM backup job>

             -backupSchedule <Daily backup schedule in the form of hh:mm>]

            [-centralAgent <Enterprise Manager central agent home>]]

        [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>

        [-datafileDestination <destination directory for all database files> | -datafileNames <a text file containing database objects such as controlfiles, tablespaces, redo log files and spfile to their corresponding raw device file names mappings in name=value format.>]

        [-redoLogFileSize <size of each redo log file in megabytes>]

        [-recoveryAreaDestination <destination directory for all recovery files>]

        [-datafileJarLocation <location of the data file jar, used only for clone database creation>]

        [-storageType < FS | ASM >

            [-asmsnmpPassword <ASMSNMP password for ASM monitoring>]

             -diskGroupName <database area disk group name>

             -recoveryGroupName <recovery area disk group name>

        [-characterSet <character set for the database>]

        [-nationalCharacterSet <national character set for the database>]

        [-registerWithDirService <true | false>

            -dirServiceUserName <user name for directory service>

            -dirServicePassword <password for directory service >

            -walletPassword <password for database wallet >]

        [-listeners <list of listeners to configure the database with>]

        [-variablesFile <file name for the variable-value pair for variables in the template>]]

        [-variables <comma separated list of name=value pairs>]

        [-initParams <comma separated list of name=value pairs>]

        [-sampleSchema <true | false> ]

        [-memoryPercentage <percentage of physical memory for Oracle>]

        [-automaticMemoryManagement ]

        [-totalMemory <memory allocated for Oracle in MB>]

        [-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]]

 

Configure a database by specifying the following parameters:

    -configureDatabase

        -sourceDB <source database sid>

        [-sysDBAUserName <user name with SYSDBA privileges>

         -sysDBAPassword <password for sysDBAUserName user name>]

        [-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword <true | false>

            -dirServiceUserName <user name for directory service>

            -dirServicePassword <password for directory service >

            -walletPassword <password for database wallet >]

        [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>

        [-enableSecurityConfiguration <true|false>

        [-emConfiguration <CENTRAL|LOCAL|ALL|NONE>

            -dbsnmpPassword <DBSNMP user password>

            -sysmanPassword <SYSMAN user password>

            [-hostUserName <Host user name for EM backup job>

             -hostUserPassword <Host user password for EM backup job>

             -backupSchedule <Daily backup schedule in the form of hh:mm>]

            [-centralAgent <Enterprise Manager central agent home>]]

 

 

Create a template from an existing database by specifying the following parameters:

    -createTemplateFromDB

        -sourceDB <service in the form of <host>:<port>:<sid>>

        -templateName <new template name>

        -sysDBAUserName <user name with SYSDBA privileges>

        -sysDBAPassword <password for sysDBAUserName user name>

        [-maintainFileLocations <true | false>]

 

 

Create a clone template from an existing database by specifying the following parameters:

    -createCloneTemplate

        -sourceSID <source database sid>

        -templateName <new template name>

        [-sysDBAUserName <user name with SYSDBA privileges>

         -sysDBAPassword <password for sysDBAUserName user name>]

        [-maintainFileLocations <true | false>]

        [-datafileJarLocation <directory to place the datafiles in a compressed format>]

 

Generate scripts to create database by specifying the following parameters:

    -generateScripts

        -templateName <name of an existing template in default location or the complete template path>

        -gdbName <global database name>

        [-scriptDest <destination for all the scriptfiles>]

 

Delete a database by specifying the following parameters:

    -deleteDatabase

        -sourceDB <source database sid>

        [-sysDBAUserName <user name with SYSDBA privileges>

         -sysDBAPassword <password for sysDBAUserName user name>]

Query for help by specifying the following options: -h | -help

[oracle@testdb ora11g]$

 

 

 

[oracle@testdb oracle]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11g -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u01/app/oracle/oradata/ -redoLogFileSize 50 -recoveryAreaDestination /u01/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE

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

57% 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.

 

  1. 10g静默建库

 

给出命令,结果略去:

 

dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11g -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u01/app/oracle/oradata/ -recoveryAreaDestination /u01/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -databaseType OLTP -emConfiguration NONE

 

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。