Oracle DBCA 命令 进行实例 复制 说明

 

在我们创建实例的时候可以保存为模板,其实也可以直接用DBCA命令来创建我们的实例模板,并且利用这个功能进行实例的复制。只是这个功能很少被关注。


 

 

这里我们选择ManageTemplate:

 


注意创建模板的三种类型,官网也有相关的说明:

Installing Oracle Database and Creating aDatabase

http://docs.oracle.com/cd/E11882_01/server.112/e10897/install.htm#ADMQS023

 

(1)From an existing template

Using anexisting template, you can create a new template based on the predefinedtemplate settings. You can add or change any template settings such asinitialization parameters, storage parameters, or whether to use customscripts.

--根据已经存在的模板来创建新的模板,在此基础之上可以修改旧模板的参数。

 

(2)From an existing database(structure only)

You can create anew template that contains structural information from an existing database,including database options, tablespaces, data files, and initializationparameters. User-defined schemas and their data will not be part ofthe created template. The source database can be either local or remote. Selectthis option when you want the new database to be structurally similar to thesource database, but not contain the same data.

--根据已经存在的数据库实例来创建新的模板,这种只包含structural 的信息,如database options,tablespaces,datafiles 和initialization parameters。 用户定义的schemas 和data 不会被包含在模版中。因此这种模板只包含基本的架构信息。

 

(3)From an existing database(structure as well as data)

You can create anew template that has both the structural information and physical data filesof an existing database. Databases created using such a template are identicalto the source database. User-defined schemas and their data will bepart of the created template. The source database must be local. Select thisoption when you want a template from which you can create an exact replica ofthe source database.

       这种模板是包含架构和数据,因此这个模板的数据和我们源库会完全相同,使用这个功能可以用来进行数据的复制。 这个功能是我们需要关注的,也是我写这篇Blog的一个目的。

 

 

模板存放的目录:

{ORACLE_HOME}/assistants/dbca/templates/dave.dfb

 




 

这里选择No,退出:

 

查看一下我们生成模板的大小:

DG1:/u01/app/oracle/product/11.2.0.3/db_1/assistants/dbca/templates>ll -lh

total 555M

-rw-r--r-- 1 oracle oinstall 5.0K Sep 1710:24 Data_Warehouse.dbc

-rw-r----- 1 oracleoinstall 9.3M Dec 14 17:56 dave.ctl

-rw-r----- 1 oracleoinstall 6.2K Dec 14 17:58 dave.dbc

-rw-r----- 1 oracleoinstall 260M Dec 14 17:56 dave.dfb

-rwxrw-rwx 1 oracle oinstall  21M Sep 22 15:22 example01.dfb

-rwxrw-rwx 1 oracle oinstall 1.5M Sep 2215:22 example.dmp

-rw-r--r-- 1 oracle oinstall 4.9K Sep 1710:24 General_Purpose.dbc

-rw-r--r-- 1 oracle oinstall  12K Feb 15 2010 New_Database.dbt

-rwxrw-rwx 1 oracle oinstall 9.3M Sep 2215:21 Seed_Database.ctl

-rwxrw-rwx 1 oracle oinstall 254M Sep 2215:22 Seed_Database.dfb

 

 

这里的模板有几种不同的扩展名,官网对扩展名的解释如下:

 

Type

File Extension

Includes Data Files

Database Structure

Seed

.dbc

Yes

This type of template contains both the structure and the physical data files of an existing database, referred to as the seed database. Your new database starts as a copy of the seed database, and requires only the following changes:

  • Name of the database
  • Destination of the data files
  • Number of control files
  • Number of online redo log groups
  • Initialization parameters

Other changes can be made after database creation using custom scripts that can be invoked by DBCA, command-line SQL statements, or Oracle Enterprise Manager Database Control.

The data files for the seed database are stored in compressed RMAN backup format in a file with a .dfb extension. The seed database control file is stored in a file with .ctl extension. (This file is needed only when storing data files in Oracle Automatic Storage Management (Oracle ASM) disk groups or as Oracle Managed Files.) The .dbc file contains the location of the seed database data files and contains the source database name used to mount the control file.

Nonseed

.dbt

No

This type of template is used to create a new database. It contains the characteristics of the database to be created. Nonseed templates are more flexible than their seed counterparts because all data files and online redo log files are created to your specification, and names, sizes, and other attributes can be changed as required.

 

根据上面的说明,dfb 是一个RMAN 压缩备份的文件,ctl保存的是控制文件,dbc 包含data files 等文件的位置信息。

 

当我们创建完之后,就可以利用这个模板来进行实例复制,因为这个模板和源实例一模一样,所以如果在同一台server 创建,就需要修改一些参数值,在创建实例的时候可以直接修改这些参数的值,如下图:

 

 

 

小结:

      此篇Blog主要讲一个内容:可以利用DBCA 来进行实例的复制。

 

 

 

 

 

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

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

Blog:     http://blog.youkuaiyun.com/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Email:   tianlesoftware@gmail.com

Skype: tianlesoftware

 

-------加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请----

DBA1 群:62697716(满);   DBA2 群:62697977(满)  DBA3 群:62697850(满)  

DBA 超级群:63306533(满);  DBA4 群:83829929   DBA5群: 142216823

DBA6 群:158654907    DBA7 群:172855474  

转载于:https://www.cnblogs.com/Hiberniane/archive/2011/12/14/2488297.html

<think>嗯,用户想知道如何使用dbca命令行工具创建Oracle数据库实例。我需要先回忆一下dbca的相关知识。根据引用[1]、[2]、[3]、[5],dbcaOracle自带的工具,可以通过图形界面或命令行来创建数据库。用户这里需要的是命令行方式,所以应该重点讲dbca的静默模式。 首先,用户可能对dbca命令行不太熟悉,所以需要给出具体的命令示例。比如,dbca -silent -createDatabase这样的命令结构。参数方面,像-templateName、gdbName、sid这些是关键,需要解释清楚每个参数的作用。 接下来,步骤要分清楚。可能需要先准备响应文件,或者直接使用命令行参数。根据引用[5],手动创建涉及到实例定义和参数设置,但用户的问题是关于dbca命令行的,所以应该集中在静默模式的使用上。 另外,用户可能需要知道如何验证创建是否成功,比如检查日志文件,或者用sqlplus连接数据库。这部分也要包含在步骤里,确保用户能确认数据库已经正确创建。 还要考虑常见问题,比如参数错误、权限不足等。例如,用户可能没有正确设置ORACLE_HOME环境变量,或者权限不够导致创建失败。这时候需要提醒用户检查环境变量和权限。 还有,引用[3]提到使用DBCA进行复杂环境下的实例创建,可能涉及高级配置,比如初始化参数文件优化。但用户的问题是基础步骤,所以这部分可能不需要深入,但可以提到高级配置的选项,供用户进一步学习。 最后,生成的相关问题要围绕dbca的其他用途、静默模式的优势、响应文件的使用,以及手动创建与自动创建的区别。这样用户如果有更多疑问,可以继续探索这些方面。</think>### 使用 DBCA 命令行工具创建 Oracle 数据库实例的步骤 #### 1. **环境准备** - 确保已安装 Oracle 数据库软件,并配置好 `ORACLE_HOME` 环境变量。 - 检查 `$ORACLE_HOME/bin` 是否包含在系统 `PATH` 中[^3][^5]。 #### 2. **静默模式创建数据库实例** 通过以下命令格式调用 DBCA 静默模式: ```bash dbca -silent -createDatabase \ -templateName <模板名称> \ -gdbName <全局数据库名> \ -sid <实例名称> \ -sysPassword <SYS用户密码> \ -systemPassword <SYSTEM用户密码> \ -emConfiguration NONE \ -datafileDestination <数据文件存储路径> \ -storageType FS \ -characterSet AL32UTF8 \ -nationalCharacterSet AL16UTF16 \ -sampleSchema false \ -memoryPercentage 40 \ -automaticMemoryManagement false ``` **参数说明**: - `-templateName`: 使用预定义的数据库模板(如 `General_Purpose.dbc`) - `-gdbName`: 全局数据库名(格式:`数据库名.域名`) - `-sid`: 实例唯一标识符(需与 `ORACLE_SID` 一致) - `-sysPassword`/`-systemPassword`: 系统管理员密码 - `-datafileDestination`: 数据文件存储路径(需提前创建并授权) #### 3. **验证创建结果** - 检查日志文件:默认生成在 `$ORACLE_BASE/cfgtoollogs/dbca/<数据库名>`[^3] - 连接测试: ```bash sqlplus sys/<密码>@<数据库名> as sysdba SELECT name, open_mode FROM v$database; ``` #### 4. **高级配置(可选)** - **响应文件模式**:通过 `-responseFile` 参数指定预配置的响应文件,批量处理复杂参数 - **初始化参数调整**:创建后通过 `ALTER SYSTEM` 修改 `SGA_TARGET` 等参数 --- ### 关键注意事项 1. **权限要求**:需以 Oracle 软件安装用户(通常为 `oracle`)执行命令 2. **模板选择**:生产环境建议使用 `Data_Warehouse.dbc` 或 `Transaction_Processing.dbc` 3. **字符集兼容性**:`AL32UTF8` 为推荐字符集,需与应用程序一致[^2] 4. **内存分配**:`-memoryPercentage` 按物理内存比例分配,建议不超过 80% --- ### 示例命令 ```bash dbca -silent -createDatabase \ -templateName General_Purpose.dbc \ -gdbName teaching.example.com \ -sid TEACHING \ -sysPassword Oracle123 \ -systemPassword Oracle123 \ -datafileDestination /u01/oradata \ -characterSet AL32UTF8 ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值