ITPub博客

首页 > 数据库 > Oracle > DBCA静默方式建库

DBCA静默方式建库

原创 Oracle 作者:lhrbest 时间:2015-03-04 16:36:21 0 删除 编辑
  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] { } | { [ [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

        [-sid ]

        [-sysPassword ]

        [-systemPassword ]

        [-emConfiguration

            -dbsnmpPassword

            -sysmanPassword

            [-hostUserName

             -hostUserPassword

             -backupSchedule ]

            [-centralAgent ]]

        [-disableSecurityConfiguration

        [-datafileDestination | -datafileNames ]

        [-redoLogFileSize ]

        [-recoveryAreaDestination ]

        [-datafileJarLocation ]

        [-storageType < FS | ASM >

            [-asmsnmpPassword ]

             -diskGroupName

             -recoveryGroupName

        [-characterSet ]

        [-nationalCharacterSet ]

        [-registerWithDirService

            -dirServiceUserName

            -dirServicePassword

            -walletPassword ]

        [-listeners ]

        [-variablesFile ]]

        [-variables ]

        [-initParams ]

        [-sampleSchema ]

        [-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

            -sysmanPassword

            [-hostUserName

             -hostUserPassword

             -backupSchedule ]

            [-centralAgent ]]

 

 

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

    -createTemplateFromDB

        -sourceDB ::>

        -templateName

        -sysDBAUserName

        -sysDBAPassword

        [-maintainFileLocations ]

 

 

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

    -createCloneTemplate

        -sourceSID

        -templateName

        [-sysDBAUserName

         -sysDBAPassword ]

        [-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 ]

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

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26736162/viewspace-1448220/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
QQ:646634621| 网名:小麦苗| 微信公众号:xiaomaimiaolhr| 11g OCM| QQ群:618766405 微信群:私聊| 《数据库笔试面试宝典》作者| OCP、OCM、高可用(RAC+DG+OGG)网络班开讲啦,有需要的小伙伴可以私聊我。

注册时间:2012-09-23

  • 博文量
    1367
  • 访问量
    8348684