阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

DBCA静默方式创建数据库实例

137次阅读
没有评论

共计 6040 个字符,预计需要花费 16 分钟才能阅读完成。

这两天装了几套开发环境的 Oracle 数据库,其中有 11.2.0.4 的版本也有 12.2.0.1 的版本。由于网络环境复杂,没有办法使用图形界面的方式安装,只能使用静默方式安装,之前也写过关于静默安装数据库软件和创建实例的 http://www.linuxidc.com/Linux/2016-12/138678.htm 有兴趣的可以参考,这两天用的也是这样的方法,但是之前看到有人在分享中使用过 dbca 的静默方法来创建数据库实例,还没有做过尝试,趁安装空闲的时间研究了一下,在此也做一个简单的分享。

dbca 有两种静默的安装实例的方式:一种是使用 responseFile,另一种是直接使用命令行的方式。本次测试是用 responseFile 的方式。

使用 responseFile 方式自然需要有 responseFile 文件了,这个文件可以到 database 解压包目录下的 response 目录中找到,还可以在 $ORACLE_HOME/assistants/dbca/ 目录下找到。文件名叫 dbca.rsp。

创建流程:

1、复制一个 dbca.rsp 文件进行修改,来做为创建实例时使用。

[oracle@rhel6 dbca]$ pwd

/u01/app/oracle/product/11.2/db1/assistants/dbca

[oracle@rhel6 dbca]$ cp dbca.rsp /home/oracle

2、修改刚复制的 dbca.rsp 文件

这里解释部分文件中的参数

RESPONSEFILE_VERSION = “11.2.0”  #指定版本号

OPERATION_TYPE = “createDatabase”  #指定使用 dbca 要做的操作,这里要创建实例就选择 createDatabase,如果要删除实例则为 deleteDatabase

# 创建实例有只需要修改创建实例部分的参数就可以了,看到 #———————–*** End of CREATEDATABASE section ***———————— 部分就算是配置完了

[CREATEDATABASE]

GDBNAME = “dbs”  #数据库的 Global database name

SID = “dbs”  #数据库的实例名

SYSPASSWORD = “123456”  #指定 sys 用户密码

SYSTEMPASSWORD = “123456” #指定 system 用户密码

DATAFILEDESTINATION =/home/oracle/11201/dbs #指定数据文件存放的目录

CHARACTERSET = “ZHS16GBK”  #指定字符集

NATIONALCHARACTERSET= “AL16UTF16”  #指定国家字符集

DATABASETYPE = “OLTP”  #指定实例的类型

AUTOMATICMEMORYMANAGEMENT = “TRUE” #指定使用自动内存管理

TOTALMEMORY = “800”  #指定使用内存的大小,单位是 MB

上面的参数是创建单实例时用到的参数,dbca.rsp 文件中还有很多其他的参数,如果有进一步的需求可以自行修改相应的需求

3、开始创建数据库实例

执行下面的命令几分钟就可以创建一个实例:

[oracle@rhel6 11201]$ dbca -silent -responseFile /home/oracle/dbca.rsp

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/dbs/dbs1.log” for further details.

4、检查实例是否正常

[oracle@rhel6 11201]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 14 20:55:55 2017

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

sys@DBS>select status from v$instance;

STATUS

————————————

OPEN

sys@DBS>select name from v$datafile;

NAME

—————————————————

/home/oracle/11201/dbs/dbs/system01.dbf

/home/oracle/11201/dbs/dbs/sysaux01.dbf

/home/oracle/11201/dbs/dbs/undotbs01.dbf

/home/oracle/11201/dbs/dbs/users01.dbf

这里简单说一下为什么这么快的原因,从 alert 日志中可以看到如下图的日志

DBCA 静默方式创建数据库实例

从上图可以看出数据文件是被从 copy 中恢复出来的,而不是新创建的,这也可以解释为什么创建实例时第一行的日志是“Copying database files”的原因了。

说到这里也要说一下创建实例的三种类型,如下图:

DBCA 静默方式创建数据库实例

从图中可以看出创建实例的三种类型,其中“General Purpose or Transaction processiong”和“Data Warehose”分别对应的是 OLTP 系统和数据仓库,它们后面的“Includes Datafiles”为 Yes 说明使用这两种方式创建时是用数据文件的备份来恢复出来的。最后修改字符集就可以 了。如下图 alert 日志

DBCA 静默方式创建数据库实例

而“Custom Database”自定义模式则没有对应的数据文件来恢复,而是全新创建的数据文件,因此这种方式创建实例时耗费的时间也相对较长,因为需要跑数据字典。

上面简单介绍了使用 responseFile 方式创建实例的方法,另外一种方法是直接使用命令行,可以用 dbca - h 命令查看命令参数

[oracle@rhel6 trace]$ dbca -h
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>
        [-cloneTemplate]
        -gdbName <global database name>
        [-policyManaged | -adminManaged <Policy managed or Admin managed Database, default is Admin managed database>]
            [-createServerPool <To create ServerPool which will be used by the database to be created>]
            [-force <To create serverpool by force when adequate free servers are not available. This may affect already running database>]
            -serverPoolName <One serverPool Name in case of create server pool and comma separated list of serverPool name in case of use serverpool>
            -[cardinality <Specify cardinality for new serverPool to be created, default is the number of qualified nodes>]
        [-sid <database system identifier>]
        [-sysPassword <SYS user password>]
        [-systemPassword <SYSTEM user password>]
        [-emConfiguration <CENTRAL|LOCAL|ALL|NOBACKUP|NOEMAIL|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>]
            [-smtpServer <Outgoing mail (SMTP) server for email notifications>
            -emailAddress <Email address for email notifications>]
            [-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 th
eir 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 seperated list of name=value pairs>]
        [-initParams <comma seperated list of name=value pairs>]
        [-memoryPercentage <percentage of physical memory for Oracle>]
        [-automaticMemoryManagement]
        [-totalMemory <memory allocated for Oracle in MB>]
        [-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]]

官方文档:http://docs.oracle.com/cd/E11882_01/install.112/e47689/app_nonint.htm#LADBI1353

更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新���接地址 :http://www.linuxidc.com/Linux/2017-03/141830.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-22发表,共计6040字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中