不用图形界面,也不用DBCA的静默方式,下面是用Shell+SQL创建Oracle数据库的脚本。
创建12C和11G的数据库的脚本
Usage: ./create_ora11g.sh <ORACLE_SID> create_ora11g.sh #!/bin/bash # check SID if [ "$#" -ne "3" ]; then echo "USAGE: $0 <ORACLE_SID> <ORADATA> <PASSWORD>" exit 1 fi SID=$1 ORADATA=`mkdir -p $2 && cd $2 && pwd` PASSWD=$3 export ORACLE_SID=$SID # check ORACLE_BASE if [ -z "$ORACLE_BASE" ]; then echo "ERROR: please set ORACLE_BASE" exit 1 fi # check ORACLE_HOME if [ -z "$ORACLE_HOME" ]; then echo "ERROR: please set ORACLE_HOME" exit 1 fi # check sqlplus if [ -z "`which sqlplus`" ]; then export PATH=$ORACLE_HOME/bin:$PATH if [ -z "`which sqlplus`" ]; then echo "ERROR: no sqlplus found in $ORACLE_HOME/bin" exit 1 fi fi # create dir echo creating directories ... mkdir -p -m 750 $ORADATA/$SID mkdir -p -m 750 $ORACLE_BASE/diag/rdbms/$SID/$SID/trace mkdir -p -m 750 $ORACLE_BASE/diag/rdbms/$SID/$SID/cdump mkdir -p -m 750 $ORACLE_BASE/flash_recovery_area mkdir -p -m 750 $ORACLE_BASE/admin/$SID/adump # create password file echo creating password file ... rm -f $ORACLE_HOME/dbs/orapw$SID orapwd file=$ORACLE_HOME/dbs/orapw$SID password=$PASSWD entries=9 # create pfile echo creating pfile ... PFILE=/tmp/init$SID.ora cat > $PFILE << EOD *.audit_file_dest='$ORACLE_BASE/admin/$SID/adump' *.control_files='$ORADATA/$SID/control01.ctl','$ORADATA/$SID/control02.ctl','$ORADATA/$SID/control03.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='$SID' *.dispatchers='(PROTOCOL=TCP) (SERVICE=${SID}XDB)' *.open_cursors=3000 *.processes=1500 *.remote_login_passwordfile='EXCLUSIVE' *.sga_max_size=1238860800 # 1200M *.sga_target=1238860800 # 1200M *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1' EOD # startup sqlplus and create db echo creating database ... sqlplus / as sysdba > /dev/null 2>&1 <<EOD set echo on spool create_$SID.log startup nomount pfile='$PFILE'; create spfile from pfile='$PFILE'; CREATE DATABASE "$SID" MAXINSTANCES 8 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 5 MAXDATAFILES 100 DATAFILE '$ORADATA/$SID/system01.dbf' SIZE 325M AUTOEXTEND ON NEXT 10M EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '$ORADATA/$SID/sysaux01.dbf' SIZE 325M AUTOEXTEND ON NEXT 10M DEFAULT TABLESPACE users DATAFILE '$ORADATA/$SID/users01.dbf' SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '$ORADATA/$SID/temp01.dbf' SIZE 200M AUTOEXTEND ON MAXSIZE UNLIMITED UNDO TABLESPACE "UNDOTBS1" DATAFILE '$ORADATA/$SID/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED LOGFILE GROUP 1 ('$ORADATA/$SID/redo01.log') SIZE 2G, GROUP 2 ('$ORADATA/$SID/redo02.log') SIZE 2G, GROUP 3 ('$ORADATA/$SID/redo03.log') SIZE 2G NOARCHIVELOG CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 USER SYS IDENTIFIED BY "$PASSWD" USER SYSTEM IDENTIFIED BY "$PASSWD"; @?/rdbms/admin/catalog.sql @?/rdbms/admin/catproc.sql @?/sqlplus/admin/pupbld.sql startup force spool off EOD echo DONE! Please view create_$SID.log!
如果要创建em需要
emca -config dbcontrol db -repos create
创建一个10G的数据库
#!/bin/bash # check SID if [ "$#" -ne "3" ]; then echo "USAGE: $0 <ORACLE_SID> <ORADATA> <PASSWORD>" exit 1 fi SID=$1 ORADATA=`mkdir -p $2 && cd $2 && pwd` PASSWD=$3 export ORACLE_SID=$SID # check ORACLE_BASE if [ -z "$ORACLE_BASE" ]; then echo "ERROR: please set ORACLE_BASE" exit 1 fi # check ORACLE_HOME if [ -z "$ORACLE_HOME" ]; then echo "ERROR: please set ORACLE_HOME" exit 1 fi # check sqlplus if [ -z "`which sqlplus`" ]; then export PATH=$ORACLE_HOME/bin:$PATH if [ -z "`which sqlplus`" ]; then echo "ERROR: no sqlplus found in $ORACLE_HOME/bin" exit 1 fi fi # create dir echo creating directories ... mkdir -p -m 750 $ORADATA/$SID mkdir -p -m 750 $ORACLE_BASE/admin/$SID/adump mkdir -p -m 750 $ORACLE_BASE/admin/$SID/bdump mkdir -p -m 750 $ORACLE_BASE/admin/$SID/cdump mkdir -p -m 750 $ORACLE_BASE/admin/$SID/udump mkdir -p -m 750 $ORACLE_BASE/flash_recovery_area # create password file echo creating password file ... rm -f $ORACLE_HOME/dbs/orapw$SID orapwd file=$ORACLE_HOME/dbs/orapw$SID password=$PASSWD entries=9 # create pfile echo creating pfile ... PFILE=/tmp/init$SID.ora cat > $PFILE << EOD $SID.__db_cache_size=92274688 # 88M $SID.__large_pool_size=8388608 # 8M $SID.__shared_pool_size=26214400 # 25M $SID.__streams_pool_size=0 *.audit_file_dest='$ORACLE_BASE/admin/$SID/adump' *.background_dump_dest='$ORACLE_BASE/admin/$SID/bdump' *.compatible='10.2.0.1.0' *.control_files='$ORADATA/$SID/control01.ctl','$ORADATA/$SID/control02.ctl','$ORADATA/$SID/control03.ctl' *.core_dump_dest='$ORACLE_BASE/admin/$SID/cdump' *.db_block_size=8192 *.db_domain='' *.db_file_multiblock_read_count=16 *.db_name='$SID' *.db_recovery_file_dest='$ORACLE_BASE/flash_recovery_area' *.db_recovery_file_dest_size=2147483648 *.dispatchers='(PROTOCOL=TCP) (SERVICE=${SID}XDB)' *.job_queue_processes=10 *.open_cursors=300 *.pga_aggregate_target=47185920 # 45M *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_max_size=262144000 # 250M *.sga_target=142606336 # 136M *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1' *.user_dump_dest='$ORACLE_BASE/admin/$SID/udump' EOD # startup sqlplus and create db echo creating database ... sqlplus / as sysdba > /dev/null 2>&1 <<EOD set echo on spool create_$SID.log startup nomount pfile='$PFILE'; create spfile from pfile='$PFILE'; CREATE DATABASE "$SID" MAXINSTANCES 8 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 DATAFILE '$ORADATA/$SID/system01.dbf' SIZE 50M AUTOEXTEND ON NEXT 10M EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '$ORADATA/$SID/sysaux01.dbf' SIZE 10M AUTOEXTEND ON NEXT 10M DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '$ORADATA/$SID/temp01.dbf' SIZE 20M UNDO TABLESPACE "UNDOTBS1" DATAFILE '$ORADATA/$SID/undotbs01.dbf' SIZE 50M LOGFILE GROUP 1 ('$ORADATA/$SID/redo01.log') SIZE 5M, GROUP 2 ('$ORADATA/$SID/redo02.log') SIZE 5M, GROUP 3 ('$ORADATA/$SID/redo03.log') SIZE 5M ARCHIVELOG CHARACTER SET ZHS16GBK NATIONAL CHARACTER SET AL16UTF16 USER SYS IDENTIFIED BY "$PASSWD" USER SYSTEM IDENTIFIED BY "$PASSWD"; @?/rdbms/admin/catalog.sql @?/rdbms/admin/catproc.sql startup force spool off EOD echo DONE! Please view create_$SID.log!