在没有图形界面的情况下,可以使用dbca命令进行静默安装数据库。
静默安装的的速度是比图形界面安装的速度快的。
使用oracle软件自带的响应文件建库
需要响应的文件
可以使用oracle磁盘响应文件夹中的dbca.rsp [oracle@dongyang database]$ ls doc install response runInstaller stage welcome.html [oracle@dongyang database]$ cd response/ [oracle@dongyang response]$ ls custom.rsp dbca.rsp emca.rsp enterprise.rsp netca.rsp standard.rsp [oracle@dongyang response]$
|
查看dbca命令如何使用
[oracle@dongyang ~]$ dbca -help |more dbca [-silent | -progressOnly | -customCreate] { } | { [ nd> [options] ] -responseFile } [-continueOnNonFatalErrors | 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 [-cloneTemplate] --选择模板 (默认为通用模板) -gdbName --数据库的名字 [-sid ] --实例名 [-sysPassword ] --创建SYS用户密码(使用响应文件安装数据库 必须指定密码) [-systemPassword ] –创建SYSTEM用户密码 [-emConfiguration <CENTRAL|LOCAL|ALL|NOBACKUP|NOEMAIL|NONE> --配置EM --参数选择配置的方式 -dbsnmpPassword --创建dbsnmp密码 -sysmanPassword --创建sysman密码 以上参数基本可以建库了,在加上响应文件就可以了。
[-hostUserName -hostUserPassword -backupSchedule m>] [-smtpServer
ations> -emailAddress ] [-centralAgent ]] [-datafileDestination <destination directory for all database files > | -datafileNames tablespaces, redo log files and spfile to their corresponding raw device file names mappings in name=value format.>] 这个参数指定数据文件、日志文件、控制文件存放路径,默认为$ORACLE_BASE/oradata 设置了变量就不需要写 [-recoveryAreaDestination iles>] [-datafileJarLocation r clone database creation>] [-storageType < FS | ASM | RAW> [-asmSysPassword ] [-diskString ] [-diskList tabase area disk group> -diskGroupName -redundancy ] [-recoveryDiskList r the recovery area disk group> -recoveryGroupName -recoveryGroupRedundancy ]] [-characterSet ] -指定字符集 [-nationalCharacterSet ] --指定国家字符集 [-registerWithDirService -dirServiceUserName -dirServicePassword -walletPassword ] [-listeners ] [-variablesFile les in the template>]] [-variables ] [-initParams ] [-memoryPercentage ] [-databaseType ]]
Configure a database by specifying the following parameters: -configureDatabase -sourceDB [-sysDBAUserName -sysDBAPassword ] [-registerWithDirService|-unregisterWithDirService|-regenerateDBPas sword -dirServiceUserName -dirServicePassword -walletPassword ] [-emConfiguration -dbsnmpPassword -symanPassword [-hostUserName -hostUserPassword -backupSchedule m>] [-smtpServer ations> -emailAddress ] [-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 param eters: -createCloneTemplate -sourceSID -templateName [-sysDBAUserName -sysDBAPassword ] [-maintainFileLocations ] [-datafileJarLocation compressed format>]
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 ]
Configure ASM DiskGroups by specifying the following parameters: -configureASM [-asmSysPassword ] [-diskString ] [-diskList a disk group> -diskGroupName -redundancy ]] [-recoveryDiskList tabase area disk group> -recoveryGroupName --More-- |
根据帮助写出建库命令
[oracle@dongyang response]$ dbca -silent -cloneTemplate -gdbName orcl -sid orcl -sysPassword oracle -systemPassword oracle -emConfiguration LOCAL -dbsnmpPassword oracle -sysmanPassword oracle characterSet AL32UTF8 -nationaICharaterSet AL16UTF16 -responseFile /home/oracle/database/response/dbca.rsp
|
等待完成。
登录到数据库进行相关设置
[oracle@dongyang ~]$ export ORACLE_SID=orcl [oracle@dongyang ~]$ sqlplus "/ as sysdba" 查询数据库当前可以的登录的账号 SQL> select username,account_status from dba_users where account_status='OPEN';
USERNAME ACCOUNT_STATUS ------------------------------ -------------------------------- SYSTEM OPEN SYS OPEN MGMT_VIEW OPEN SYSMAN OPEN DBSNMP OPEN
SQL> 修改可以登录的账号密码 使用SQL生成一个修改用户密码的脚本 SQL> select 'alter user '||username||' identified by oracle111;' from dba_users 2 where account_status='OPEN';
'ALTERUSER'||USERNAME||'IDENTIFIEDBYORACLE111;' ------------------------------------------------------------------ alter user SYSTEM identified by oracle111; alter user SYS identified by oracle111; alter user MGMT_VIEW identified by oracle111; alter user SYSMAN identified by oracle111; alter user DBSNMP identified by oracle111;
将结果保存到/u01/app/oracle/pass.sql 开启spool创建一个文件 SQL> spool /u01/app/oracle/pass.sql 执行的结果都会保留在文件中 SQL> /
'ALTERUSER'||USERNAME||'IDENTIFIEDBYORACLE111;' ------------------------------------------------------------------ alter user SYSTEM identified by oracle111; alter user SYS identified by oracle111; alter user MGMT_VIEW identified by oracle111; alter user SYSMAN identified by oracle111; alter user DBSNMP identified by oracle111; 关闭spool SQL> spool off 使用OS命令 只保留/u01/app/oracle/pass.sql文件中以alter开头的所有行、
SQL> ho sed -n '/^alter/p' /u01/app/oracle/pass.sql -i 查看/u01/app/oracle/pass.sql文件内容 SQL> ho cat /u01/app/oracle/pass.sql alter user SYSTEM identified by oracle111; alter user SYS identified by oracle111; alter user MGMT_VIEW identified by oracle111; alter user SYSMAN identified by oracle111; alter user DBSNMP identified by oracle111; 执行脚本修改密码 SQL> @/u01/app/oracle/pass.sql
User altered.
User altered.
User altered.
User altered.
User altered.
SQL>
|
使用OS的模板建库
查看OS自带模板
[oracle@dongyang templates]$ pwd /u01/app/oracle/product/10.2.0/db_1/assistants/dbca/templates [oracle@dongyang templates]$ ls Data_Warehouse.dbc New_Database.dbt Seed_Database.dfb example.dmp General_Purpose.dbc Seed_Database.ctl Transaction_Processing.dbc example01.dfb [oracle@dongyang templates]$
|
使用通用模板静默建库
[oracle@dongyang ~]$ dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc -gdbName orcl1 sid orcl1 -sysPassword oracle -systemPassword oracle -responseFile NO_VALUE characterSet AL32UTF8 -nationaICharaterSet AL16UTF16 –emConfiguration LOCAL -dbsnmpPassword oracle -sysmanPassword oracle
-responseFile NO_VALUE --不使用响应文件 |
也可以自己手工定义一个模板来建库
确认要克隆的库
[oracle@dongyang ~]$ ps -ef |grep ora_ oracle 4063 1 0 09:04 ? 00:00:12 ora_pmon_fengzi oracle 4065 1 0 09:04 ? 00:00:06 ora_psp0_fengzi oracle 4067 1 0 09:04 ? 00:00:06 ora_mman_fengzi oracle 4069 1 0 09:04 ? 00:00:10 ora_dbw0_fengzi oracle 4071 1 0 09:04 ? 00:00:09 ora_lgwr_fengzi oracle 4073 1 0 09:04 ? 00:00:20 ora_ckpt_fengzi oracle 4075 1 0 09:04 ? 00:00:02 ora_smon_fengzi oracle 4077 1 0 09:04 ? 00:00:00 ora_reco_fengzi oracle 4079 1 0 09:04 ? 00:00:15 ora_cjq0_fengzi oracle 4081 1 0 09:04 ? 00:00:11 ora_mmon_fengzi oracle 4083 1 0 09:04 ? 00:00:12 ora_mmnl_fengzi oracle 4085 1 0 09:04 ? 00:00:00 ora_d000_fengzi oracle 4087 1 0 09:04 ? 00:00:00 ora_s000_fengzi oracle 4090 1 0 09:04 ? 00:00:05 ora_asmb_fengzi oracle 4094 1 0 09:04 ? 00:00:06 ora_rbal_fengzi oracle 4097 1 0 09:04 ? 00:00:00 ora_o000_fengzi oracle 4101 1 0 09:04 ? 00:00:06 ora_rvwr_fengzi oracle 4107 1 0 09:04 ? 00:00:00 ora_arc0_fengzi oracle 4111 1 0 09:04 ? 00:00:01 ora_arc1_fengzi oracle 4115 1 0 09:04 ? 00:00:01 ora_qmnc_fengzi oracle 4127 1 0 09:05 ? 00:00:00 ora_q000_fengzi oracle 4129 1 0 09:05 ? 00:00:01 ora_q001_fengzi oracle 5468 4016 0 11:44 pts/2 00:00:00 grep ora_ [oracle@dongyang ~]$
|
克隆SID为fengzi的数据库
注意:
要克隆的数据库必须可以正常的打开与关闭。否则克隆模板不能正常使用。
[oracle@dongyang ~]$ dbca -help Create a clone template from an existing database by specifying the following parameters: -createCloneTemplate --创建克隆模板 -sourceSID --指定SID -templateName --新的模板名字 [-sysDBAUserName -sysDBAPassword ] [-maintainFileLocations ] [-datafileJarLocation ]
[oracle@dongyang ~]$ dbca -silent -createCloneTemplate -sourceSID fengzi -templateName clonefengzi |
模板默认地址
[oracle@dongyang ~]$ ls $ORACLE_HOME/assistants/dbca/templates Data_Warehouse.dbc New_Database.dbt Seed_Database.dfb example.dmp General_Purpose.dbc Seed_Database.ctl Transaction_Processing.dbc example01.dfb Clonefengzi.dbc Clonefengzi.dfb Clonefengzi.ctl [oracle@dongyang ~]$
.ctl后缀文件 --是控制文件的备份 .dbc后缀文件 -- 这个就是克隆的模板 .dfb后缀文件 --RMAN进行的备份集,其中包括库中所有数据文件 |
使用自定义模板方式建库
使用这个模板,数据库其中的内容跟SID为fengzi的数据库中的内容是一样的。(也就是克隆技术)
[oracle@dongyang ~]$dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/templates/clonefengzi.dbc -gdbName orcl2 -sid orcl2 -datafileDestination $ORACLE_BASE/oradata -responseFile NO_VALUE characterSet AL32UTF8 -nationaICharaterSet AL16UTF16 –emConfiguration LOCAL -dbsnmpPassword oracle -sysmanPassword oracle
|
静默删除数据库
删除数据库就非常简单了
[oracle@dongyang ~]$ dbca –help Delete a database by specifying the following parameters: -deleteDatabase -sourceDB database sid>(一定是SID ) [-sysDBAUserName -sysDBAPassword ]
[oracle@dongyang ~]$dbca –silent –deleteDatabase -sourceDB orcl1 |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29532781/viewspace-1125838/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29532781/viewspace-1125838/