oracle-DBCA删除数据库

DBCA
DBCA是Oracle软件包中用来安装/卸载/配置数据库的一个工具,其提供了两种方式对数据库进行安装或卸载,分别是 GUI界面 和 静默模式。

图形化安装的方式相对来说比较简单,容易上手,但是不具备重复利用性。每次重新安装数据库的时候都可能需要进行相同的配置,而这无疑会消耗工作者的精力。相比来说,静默模式则可以将创建数据的配置参数持久化到文件中,以便下一次重新安装数据库时再次调用,但因为需要配置相关参数,需要额外一部分成本了解各项参数的含义。不过,总体感觉吧,利大于弊。

DBCA命令行帮助信息
如果你直接在终端命令行下执行 dbca -help,那么很可能你会遇到 DISPLAY not set 这样的一个提示。这是因为Oracle启动DBCA工具时,需要使用到 DISPLAY 的环境变量,而当前用户并未设置改环境变量导致的。

# dbca -help
DISPLAY not set.
Set DISPLAY environment variable, then re-run.

解决方式通过在终端执行 export DISPLAY={local_ip}:{port} 即可。

# export DISPLAY=172.16.xx.xx:1
再次执行 dbca -help 即可看到DBCA工具提供的一些功能。

# dbca -help
Usage:  dbca [<flag>] [<command> <option>]
Following are the possible flags:
    -help
        -contextId <RAC | SI>
    -ignorePreReqs - Ignore prerequisite checks for current operation.
    -ignorePrereqFailure  - Ignore all prerequisites failures.
    -silent - This flag allows you to carry on configuration in silent mode.
        -<command>

Following are the possible commands:
    -addInstance - Command to Add an instance to an admin managed cluster database.
    -configureDatabase - Command to Configure a database.
    -configurePluggableDatabase - Command to Configure a pluggable database.
    -createCloneTemplate - Command to Create a clone template from an existing database.
    -createDatabase - Command to Create a database.
    -createDuplicateDB - Command to Duplicate a database.
    -createPluggableDatabase - Command to Create a pluggable database.
    -createTemplateFromDB - Command to Create a template from an existing database.
    -createTemplateFromTemplate - Command to Create a template from an existing template.
    -deleteDatabase - Command to Delete a database.
    -deleteInstance - Command to Delete an instance from an admin managed cluster database.
    -deletePluggableDatabase - Command to Delete a pluggable database.
    -deleteTemplate - Command to delete a template.
    -executePrereqs - Command to execute prerequisite checks.
    -generateScripts - Command to Generate scripts which can be used to create database.
    -relocatePDB - Command to Relocate a pluggable database.
    -unplugDatabase - Command to Unplug a pluggable database.

工具提示包含两部分的内容,分别为 flags 和 commands。flags 部分提供了安装时可选的一些参数,例如,-silent 指定安装时使用静默模式安装;-ignorePreReqs 则会在安装数据库前跳过数据库依赖的检查;-ignorePrereqFailure 同理,只是针对安装前检查失败的依赖项结果忽略处理。

commands 部分就是DBCA可以使用的功能了。例如 -addInstance 为当前集群添加一个数据库实例;-configureDatabase 配置数据库的一些选项;-createDatabase 功能则可以用来创建数据库;-deleteDatabase 功能则可以用来删除数据库。

删除数据库
这里主要使用 dbca -silent 模式在终端下删除数据库。删除数据库时,也可以通过制作dbca响应文件的方式进行删除数据库的操作。不过,通常情况下,删除数据库需要指定的参数并不会像创建数据库那么多,因此,也可以直接在终端通过 命令+参数 的方式进行删除。

删除数据库的具体参数如下

# dbca -silent -deleteDatabase -help
    -deleteDatabase - Command to Delete a database.
        -sourceDB <Database unique name for RAC database or SID for Single Instance database>
        [-useWalletForDBCredentials <true | false> Specify true to load database credentials from wallet]
            -dbCredentialsWalletLocation <Path of the directory containing the wallet files>
            [-dbCredentialsWalletPassword <Password to open wallet with auto login disabled>]
        [-unregisterWithDirService <true | false>]
            -dirServiceUserName <User name for directory service>
            [-dirServicePassword <Password for directory service>]
            [-walletPassword <Password for database wallet>]
        [-deRegisterEMCloudControl ]
            -emUser <EM Admin username to add or modify targets>
            -omsHost <EM management server host name>
            -omsPort <EM management server port number>
            [-emPassword <EM Admin user password>]
        [-sysDBAUserName <User name  with SYSDBA privileges>]
        [-forceArchiveLogDeletion <To delete archive logs of a database>]
        [-sysDBAPassword <Password for sysDBAUserName user name>]
        [-sid <Database system identifier>]

sourceDB: 数据库名称。必须指定

useWalletForDBCredentials: 是否使用wallet作为数据库凭证。默认为false。

unregisterWithDirService: 是否使用DirService服务注销数据库。

deRegisterEMCloudControl: 企业版功能。将注册的数据库服务从EM云控制服务中注销。

sysDBAUserName: 删除数据库需要指定系统管理员用户。推荐配置

forceArchiveLogDeletion: 删除数据库强制删除归档日志。

sysDBAPassword: 删除数据库的系统管理员认证密码。推荐配置

sid: 数据库实例标识符。

删除数据库

# dbca -silent -deleteDatabase -sourceDB test -sysDBAUserName sys -sysDBAPassword oracle
[WARNING] [DBT-19202] The Database Configuration Assistant will delete the Oracle instances and datafiles for your database. All information in the database will be destroyed.
Prepare for db operation
32% complete
Connecting to database
39% complete
42% complete
45% complete
48% complete
52% complete
55% complete
58% complete
65% complete
Updating network configuration files
68% complete
Deleting instances and datafiles
77% complete
87% complete
97% complete
100% complete
Database deletion completed.
Look at the log file "/xxxx/cfgtoollogs/dbca/test/test0.log" for further details.

使用DBCA静默删除的方式删除数据库很快,执行结束后,操作系统上的数据库就没了,如果需要将数据库对应的日志文件也一并删除,可以手动进行删除。

作者:归源
链接:https://www.jianshu.com/p/9b4213756def
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

posted @   deshell  阅读(369)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
点击右上角即可分享
微信分享提示