DBCA靜默方式建庫

flywiththewind發表於2016-06-30
  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

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26224914/viewspace-2121254/,如需轉載,請註明出處,否則將追究法律責任。

相關文章