静默方式创建数据库
使用 DBCA 命令行静默安装非容器数据库
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcldb.yaoyuan.com -sid orcldb -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration LOCAL
然后出现下面的输出信息:
Enter SYS user password: Enter SYSTEM user password: [WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards. CAUSE: a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. b.The password entered is a keyword that Oracle does not recommend to be used as password ACTION: Specify a strong password. If required refer Oracle documentation for guidelines. [WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards. CAUSE: a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. b.The password entered is a keyword that Oracle does not recommend to be used as password ACTION: Specify a strong password. If required refer Oracle documentation for guidelines. Prepare for db operation 10% complete Copying database files 40% complete Creating and starting Oracle instance 42% complete 46% complete 50% complete 54% complete 60% complete Completing Database Creation 66% complete 69% complete 70% complete Executing Post Configuration Actions 100% complete Database creation complete. For details check the logfiles at: /u01/app/oracle/cfgtoollogs/dbca/orcldb. Database Information: Global Database Name:orcldb.yaoyuan.com System Identifier(SID):orcldb Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcldb/orcldb.log" for further details.
创建容器数据库
dbca -silent -createDatabase -createAsContainerDatabase true -templateName General_Purpose.dbc -gdbname orcl.yaoyuan.com -sid orcl -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration LOCAL $ORACLE_HOME/bin/dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl.yaoyuan.com -sid orcl -createAsContainerDatabase true -numberOfPDBs 1 -pdbName pdb1 -useLocalUndoForPDBs true -responseFile NO_VALUE -characterSet AL32UTF8 -totalMemory 1300 -emConfiguration DBEXPRESS -emExpressPort 5505 -enableArchive true -recoveryAreaDestination /u01/app/oracle/fast_recovery_area -recoveryAreaSize 15000 -datafileDestination /u01/app/oracle/oradata
奇怪的现象:如果加了-sysPassword oracle -systemPassword oracle 会出现下面的错误:
100% complete [FATAL] Error while executing "/u01/app/oracle/product/19.3.0/db_1/ord/im/admin/ordlib.sql". Refer to "/u01/app/oracle/cfgtoollogs/dbca/orcl/ordlib0.log" for more details. Error in Process: /u01/app/oracle/product/19.3.0/db_1/perl/bin/perl
命令中使用的参数:
-silent:指定以静默的方式执行 dbca 命令。
-createDatabase:指定以 dbca 命令创建数据库。
-templateName:指定用来创建数据库模板的名称,这里指定为 General_Purpose.dbc,即一 般用 途的数据库模板。使用此参数相当于在图新界面中创建一般用途的数据库。
-gdbname:指定创建的全局数据库名称。
-sid:指定数据库系统标识符,这里指定为 test,与数据库同名。
-responseFile:指定按住响应文件,NO_VALUE 表示没有指定响应文件。
-characterSet:指定数据库使用的字符集,这里指定为 AL32UTF8.
-memoryPercentage:指定用于 Oracle 的物理内存的百分比,
-totalMemory:可用内存以MB为单位。
-emConfiguration:指定 Enterprise Manager 的管理选择。
LOCAL 表示数据库有 Enterprise Manager 本地管理,CENTRAL 表示数据库有 Enterprise Manager 集中管理,NOEMAIL 表示数据库不启用邮件 通知功能,NONE 表示不使用 Enterprise Manager 管理数据库。
在数据库的日志里面可以看到:
ORACLE_HOME: /u01/app/oracle/product/19.3.0/db_1 System name: Linux Node name: oracleace.yaoyuan Release: 5.4.17-2102.201.3.el7uek.x86_64 Version: #2 SMP Fri Apr 23 09:05:55 PDT 2021 Machine: x86_64 Using parameter settings in client-side pfile /u01/app/oracle/cfgtoollogs/dbca/ORCL/initORCLTemp.ora on machine oracleace.yaoyuan System parameters with non-default values: processes = 300 nls_language = "AMERICAN" nls_territory = "AMERICA" sga_target = 1360M control_files = "/u01/app/oracle/oradata/ORCL/control01.ctl" control_files = "/u01/app/oracle/fast_recovery_area/ORCL/control02.ctl" db_block_size = 8192 compatible = "19.0.0" log_archive_format = "%t_%s_%r.dbf" db_recovery_file_dest = "/u01/app/oracle/fast_recovery_area" db_recovery_file_dest_size= 15000M _no_recovery_through_resetlogs= TRUE undo_tablespace = "UNDOTBS1" remote_login_passwordfile= "EXCLUSIVE" dispatchers = "(PROTOCOL=TCP) (SERVICE=ORCLXDB)" local_listener = "LISTENER_ORCL" job_queue_processes = 0 audit_file_dest = "/u01/app/oracle/admin/ORCL/adump" audit_trail = "DB" db_name = "ORCL" open_cursors = 300 pga_aggregate_target = 450M aq_tm_processes = 0 _enable_automatic_maintenance= 0 _diag_hm_rc_enabled = FALSE diagnostic_dest = "/u01/app/oracle" enable_pluggable_database= TRUE 2022-03-23T14:02:16.779097+08:00
使用create database创建数据库
创建一个pfile:
[oracle@oracleace ~]$ cat > $ORACLE_HOME/dbs/initcdb2.ora db_name=cdb2 ENABLE_PLUGGABLE_DATABASE=true DB_CREATE_FILE_DEST='/u01/app/oracle/oradata'
创建数据:
export ORACLE_SID=cdb2 sqlplus / as sysdba SQL> STARTUP NOMOUNT SQL> CREATE DATABASE cdb2 USER SYS IDENTIFIED BY oracle USER SYSTEM IDENTIFIED BY oracle EXTENT MANAGEMENT LOCAL DEFAULT TEMPORARY TABLESPACE temp UNDO TABLESPACE undotbs DEFAULT TABLESPACE users ENABLE PLUGGABLE DATABASE;
运行catcdb.sql创建视图、存储过程和包。
@?/rdbms/admin/catcdb.sql
12.2中有了大的改进,catcdb.sql引用的是catcdb.pl这样一个Perl脚本,你不会直接看到catalog.sql,catproc.sql这样的字眼了,这些都被封装起来了。