该命令方式在rhas4下执行通过,需要一个运行正常的数据库的spfile
执行方式:
createdatabase 数据库名称
脚本如下:
#!/bin/bash
#createdatabase
if [ $# = 0 ]; then
echo -e "usage:`basename $0` database_name"
exit 1
fi
export ORACLE_SID=$1
export DB_HOME=$ORACLE_BASE/oradata
#mkdir needed
if [ -d $ORACLE_BASE/admin/$1 ]; then
echo 'Sorry , Your SID is exist, pls enter correct sid'
exit 1
fi
mkdir -p $ORACLE_BASE/admin/$1
cd $ORACLE_BASE/admin/$1
mkdir adump bdump cdump udump pfile dpdump
mkdir -p $DB_HOME/$1
mkdir -p $DB_HOME/$1/archive
chmod -R 750 $DB_HOME/$1
#create pfile,orapw
cd $ORACLE_HOME/dbs
strings spfileanze.ora >init$1.ora
sed -e "s/anze/${1}/g" < init$1.ora >kk
cat kk > init$1.ora
rm kk
orapwd file=orapw$1 password=$1
####################################################
#####################################################
#createdatabase.sql
sqlplus "/as sysdba"<
create spfile from pfile;
spool $ORACLE_BASE/admin/$1/createdb.log;
startup nomount;
create database $1
LOGFILE
GROUP 1 ('$DB_HOME/$1/redo01.log','$DB_HOME/$1/redo01_1.log') size 50m reuse,
GROUP 2 ('$DB_HOME/$1/redo02.log','$DB_HOME/$1/redo02_1.log') size 50m reuse,
GROUP 3 ('$DB_HOME/$1/redo03.log','$DB_HOME/$1/redo03_1.log') size 50m reuse
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXLOGHISTORY 200
MAXDATAFILES 500
MAXINSTANCES 5
ARCHIVELOG
CHARACTER SET UTF8
NATIONAL CHARACTER SET UTF8
DATAFILE '$DB_HOME/$1/system01.dbf' SIZE 500M EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '$DB_HOME/$1/sysaux01.dbf' SIZE 500M
UNDO TABLESPACE UNDOTBS1 DATAFILE '$DB_HOME/$1/undo.dbf' SIZE 500M
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE
'$DB_HOME/$1/temp.dbf' SIZE 200M
;
@$ORACLE_HOME/rdbms/admin/catalog.sql;
@$ORACLE_HOME/rdbms/admin/catproc.sql;
@$ORACLE_HOME/rdbms/admin/catdbsyn.sql;
alter user system identified by $1;
grant sysdba to system;
shutdown immediate;
startup;
spool off;
exit
eof
阅读(1257) | 评论(0) | 转发(0) |