Sie sind auf Seite 1von 4

#!

/bin/ksh
###########################################################
#Set password
##########################################################
setPasswd(){
## PASSWORDS ##
echo
echo Please specify the passwords for the
echo following database administrative
echo accounts.
echo
for dbuser in SYS SYSTEM
do
echo
if [ "${dbuser}" = "SYS" ] || [ "${dbuser}" = "SYSTEM" ]
then
display_user=${dbuser} (Database Administrative Account)
fi
echo -n ${display_user} Password:
while [ 1 ]
do
/bin/stty -echo > /dev/null 2>&1
temp=`echo $IFS`
export IFS=\n
while [ 1 ]
do
read LINE
while [ -z "$LINE" ]
do
echo
echo -n Password can not be null, please try again:
read LINE
done
result=`expr index $LINE [\'\"]`
if [ $result != 0 ];
then
echo
echo -n The password you entered contains invalid characters. Please try again:
else
break
fi
done
echo
echo -n Confirm ${dbuser} password:
read LINE1
echo
if [ "$LINE" != "$LINE1" ];
then
echo
echo -n Passwords do not match. Please enter the password again:
else
break
fi
done

if [ ${dbuser} = "SYS" ]
then
SYS_PWD=$LINE
elif [ ${dbuser} = "SYSTEM" ]
then
SYSTEM_PWD=$LINE
else
echo Invalid database user: ${dbuser}
exit 30
fi
/bin/stty echo > /dev/null 2>&1
export IFS=$temp
done
}
#################################################################
#Set ORacle SID
################################################################
setOraSid(){
echo
echo Please enter the name for your Oracle Database.
echo This name will be used as your
echo -n ORACLE SID (System Identifier):
read LINE
while [ -z "$LINE" ]
do
echo -n ORACLE SID can not be null, please try again:
read LINE
done
NDB_LENGTH=`echo ${LINE} | wc -L`
while [ ${NDB_LENGTH} -gt 8 ]
do
echo The new database name: ${LINE} is too long. The database name must be 8 bytes or less, please try
again:
read LINE
NDB_LENGTH=`echo ${LINE} | wc -L`
done
ORACLE_SID=$LINE
GLOBAL_NAME=$ORACLE_SID
export ORACLE_SID=$LINE
}
##################################################################
# main
##################################################################
Me=$(\basename $0)
mypath=$(\dirname $0)
RUID=`/usr/bin/id|awk -F\( {print $2}|awk -F\) {print $1}`
if [ ${RUID} != "oracle" ];then
echo You must be logged in as oracle to dbca.sh.
echo Log in as oracle and restart dbca.sh execution.
exit 1
fi
if [[ -z $ORACLE_HOME || -z $ORACLE_BASE ]];then
echo
echo either ORACLE_HOME or ORACLE_BASE are not set ,Please set both the variables and restart the script

again
exit 30
fi
setOraSid
setPasswd
export ORACLE_BASE=$ORACLE_BASE
export ORACLE_HOME=$ORACLE_HOME
export SID=$ORACLE_SID
DBCA_TEMPLATE_DIR=${ORACLE_HOME}/assistants/dbca/templates
DBCA_TEMPLATE_NAME=${DBCA_TEMPLATE_DIR}/General_Purpose.dbc
ORACLE_OWNER=oracle
DBCA=${ORACLE_HOME}/bin/dbca
SQLPLUS=${ORACLE_HOME}/bin/sqlplus
DB_FILE_DIR=/u01/app/oradata
RECO_AREA=/u01/app/flash_recovery_area
#mkdir $ORACLE_BASE/admin/${ORACLE_SID}
#mkdir $ORACLE_BASE/admin/${ORACLE_SID}/dbs
#mkdir $ORACLE_BASE/admin/${ORACLE_SID}/adump
${DBCA} -silent -createDatabase -templateName ${DBCA_TEMPLATE_NAME} -gdbName ${GLOBAL_NAME}
-sid ${SID} -sysPassword ${SYS_PWD} -systemPassword ${SYSTEM_PWD} -emConfiguration NONE storageType FS -datafileJarLocation ${DBCA_TEMPLATE_DIR} -sampleSchema false -datafileDestination
${DB_FILE_DIR} -recoveryAreaDestination ${RECO_AREA}
RV=$?
if [ $RV -ne 0 ]
then
echo
echo There was a problem creating your database. Please review the log file shown above.
else
echo
echo The database was created successfully.
fi
Usage :./dbca.sh
either ORACLE_HOME or ORACLE_BASE are not set ,Please set both the variables and restart the script again
exprot ORACLE_HOME=<your oracle home>
export ORACLE_BASE=<oracle base>
./dbca.sh
Please enter the name for your Oracle Database.
This name will be used as your
ORACLE SID (System Identifier): dgprm1
Please specify the passwords for the
following database administrative
accounts.
SYS (Database Administrative Account) Password:
Confirm SYS password:
SYSTEM (Database Administrative Account) Password:
Confirm SYSTEM password:
Sample log:
Copying database files

DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 33%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/dgprm.
Database Information:
Global Database Name:dgprm
System Identifier(SID):dgprm
****script to create database on asm********

Das könnte Ihnen auch gefallen