手动创建数据库脚本
Posted vmsysjack
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了手动创建数据库脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash if [ `whoami` != oracle ];then echo ‘please Use oracle user perform script‘ exit 1 fi read -p "please input your database Name:" dbname #---Create PasswordFile orapwd file=$ORACLE_HOME/dbs/orapw${dbname} password=oracle entries=30 force=y #---Create tnsnames.ora file cat>>$ORACLE_HOME/network/admin/tnsnames.ora<<EOF ${dbname}_NET = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.191)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = ${dbname}) (SID=${dbname}) ) ) EOF mkdir -p /opt/oracle/admin/${dbname}/adump mkdir -p /opt/oracle/oradata/${dbname} #---Create parameter file cat>$ORACLE_HOME/dbs/init${dbname}.ora<<eof db_domain=‘‘ db_name=‘${dbname}‘ db_recovery_file_dest=‘/opt/oracle/flash_recovery_area‘ db_recovery_file_dest_size=2G control_files=‘/opt/oracle/oradata/${dbname}/control01.ctl‘,‘/opt/oracle/oradata/${dbname}/control02.ctl‘,‘/opt/oracle/oradata/${dbname}/control03.ctl‘ db_block_size=8192 memory_target=1G processes=300 undo_management=auto undo_tablespace=undotbs compatible=‘11.2.0‘ dispatchers=‘(PROTOCOL=TCP)(SERVICE=${dbname}xdb)‘ audit_file_dest=‘/opt/oracle/admin/${dbname}/adump‘ audit_trail=‘db‘ remote_login_passwordfile=EXCLUSIVE open_cursors=300 diagnostic_dest=‘/opt/oracle‘ job_queue_processes=10 eof cat>/tmp/a.sql<<EOF create database ${dbname} user sys identified by oracle user system identified by oracle MAXINSTANCES 8 MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXLOGHISTORY 292 NOARCHIVELOG CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 SET DEFAULT SMALLFILE TABLESPACE logfile group 1 (‘/opt/oracle/oradata/${dbname}/redolog1_01‘) size 20M, group 2 (‘/opt/oracle/oradata/${dbname}/redolog2_01‘) size 20M, group 3 (‘/opt/oracle/oradata/${dbname}/redolog3_01‘) size 20M extent management local datafile ‘/opt/oracle/oradata/${dbname}/system.dbf‘ size 200M autoextend on sysaux datafile ‘/opt/oracle/oradata/${dbname}/sysaux.dbf‘ size 200M autoextend on default temporary tablespace temp tempfile ‘/opt/oracle/oradata/${dbname}/temp.dbf‘ size 200M autoextend on undo tablespace undotbs datafile ‘/opt/oracle/oradata/${dbname}/undotbs.dbf‘ size 200M autoextend on default tablespace users datafile ‘/opt/oracle/oradata/${dbname}/users.dbf‘ size 200M autoextend on; EOF export ORACLE_SID=$dbname sqlplus /nolog <<eof conn / as sysdba startup nomount @/tmp/a.sql @$ORACLE_HOME/rdbms/admin/catalog.sql @$ORACLE_HOME/rdbms/admin/catproc.sql conn system/oracle @$ORACLE_HOME/sqlplus/admin/pupbld.sql select open_mode from v$database; exit eof
## #数据库名称 ## db_domain=‘‘ ## db_name=‘${dbname}‘ ## #快速恢复区 ## db_recovery_file_dest=‘/opt/oracle/flash_recovery_area‘ ## db_recovery_file_dest_size=2G ## #控制文件 ## control_files=‘/opt/oracle/oradata/${dbname}/control01.ctl‘,‘/opt/oracle/oradata/${dbname}/control02.ctl‘,‘/opt/oracle/oradata/${dbname}/control03.ctl‘ ## #数据块大小 ## db_block_size=8192 ## #设置内存管理 ## memory_target=1G ## #最大进程数 ## processes=300 ## #撤销表空间 ## undo_management=auto ## undo_tablespace=undotbs ## #兼容性 ## compatible=‘11.2.0‘ ## #共享服务器 ## dispatchers=‘(PROTOCOL=TCP)(SERVICE=${dbname}xdb)‘ ## #设置安全与审计 ## audit_file_dest=‘/opt/oracle/admin/${dbname}/adump‘ ## audit_trail=‘db‘ ## #口令文件 ## remote_login_passwordfile=EXCLUSIVE ## #游标 ## open_cursors=300 ## #诊断与跟踪信息 ## diagnostic_dest=‘/opt/oracle‘ ## #作业队列 ## job_queue_processes=10 ## eof ##创建数据库 ## create database dg ## user sys identified by oracle ## user system identified by oracle ## controlfile reuse ## MAXLOGFILES 16 ## MAXLOGMEMBERS 3 ## MAXDATAFILES 100 ## MAXINSTANCES 8 ## MAXLOGHISTORY 292 ## NOARCHIVELOG ## CHARACTER SET AL32UTF8 ## NATIONAL CHARACTER SET AL16UTF16 ## SET DEFAULT SMALLFILE TABLESPACE ## #--设置重做日志文件 ## logfile ## group 1 (‘/opt/oracle/oradata/dg/redolog1_01‘) size 20M, ## group 2 (‘/opt/oracle/oradata/dg/redolog2_01‘) size 20M, ## group 3 (‘/opt/oracle/oradata/dg/redolog3_01‘) size 20M ## #--设置system表空间 ## extent management local ## datafile ‘/opt/oracle/oradata/dg/system.dbf‘ size 200M autoextend on ## #--设置数据库sysaux表空间 ## sysaux datafile ‘/opt/oracle/oradata/dg/sysaux.dbf‘ size 200M autoextend on ## #--设置数据库撤销表空间 ## undo tablespace undotbs datafile ‘/opt/oracle/oradata/dg/undotbs.dbf‘ size 200M autoextend on ## #--设置数据库默认表空间 ## default tablespace users datafile ‘/opt/oracle/oradata/dg/users.dbf‘ size 20M autoextend on ## #--设置数据库临时表空间 ## default temporary tablespace temp tempfile ‘/opt/oracle/oradata/dg/temp.dbf‘ size 20M autoextend on
以上是关于手动创建数据库脚本的主要内容,如果未能解决你的问题,请参考以下文章