【Oracle12c自动安装部署脚本】项目地址:https://github.com/domdanrtsey/Oracle12c_autoinstall详细的使用说明请参看项目中的README.md另说明:脚本已经自动配置oracle服务自启动,并配置为系统服务,启动与停止时使用root用户操作停止#service oracle stop启动#service oracle start#!/bin/bash####################Steup 1 Install oracle software #####################script_name: oracle_software.sh#Author: Danrtsey.Shun#Email:mydefiniteaim@126.com#auto_install_oracle12c version=12.1.0.2# attentions1:# 1.上传12c软件安装包至随意路径下,脚本提示路径是 /opt## linuxamd64_12102_database_1of2.zip# linuxamd64_12102_database_2of2.zip## 2.预设oracle用户的密码为 Danrtsey.com 请根据需要修改######################################ORACLE_OS_PWD=##if [ "$ORACLE_OS_PWD" = "" ]; then ##ORACLE_OS_PWD="Danrtsey.com"##fi####################################### 3.执行# chmod + oracle12.1.0.2_install.sh# sh -x oracle12.1.0.2_install.sh##################### Steup 2 Install oracle listener & dbca##################### attentions2:######################################### 1.according to the different environment to set the processes && sessions value# alter system set processes=500 scope=spfile;# alter system set sessions=555 scope=spfile;# 2.ignore these warnings# /u01/database/response/netca.rsp:LINE30: [GENERAL]: command not found# /u01/database/response/netca.rsp:LINE62: [oracle.net.ca]: command not found########################################export PATH=$PATH#Source function library.. /etc/init.d/functions#Require root to run this script.uid=`id | cut -d( -f1 | cut -d= -f2`if [ $uid -ne 0 ];thenaction "Please run this script as root." /bin/falseexit 1fi##set oracle passwordORACLE_OS_PWD=if [ "$ORACLE_OS_PWD" = "" ]; thenORACLE_OS_PWD="Danrtsey.com"fi###install require packagesecho -e "33[34mInstallNotice >>33[0m 33[32moracle install dependency 33[05m...33[0m"yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.develcompat-libstdc++-33 compat-libstdc++-33*.devel elfutils-libelf elfutils-libelf-devel gcc gcc-c++glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devellibgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 zip unzip treevim lrzsz epel-release net-tools wget ntpdate ntpif [[ $? == 0 ]];thenecho -e "33[34mInstallNotice >>33[0m 33[32myum install dependency successed33[0m"elseecho -e "33[34mInstallNotice >>33[0m 33[32myum install dependency faild, pls check your network33[0m"exitfised -e 's!^metalink=!#metalink=!g'-e 's!^#baseurl=!baseurl=!g'-e 's!//download.fedoraproject.org/pub!//mirrors.tuna.tsinghua.edu.cn!g'-e 's!http://mirrors.tuna!https://mirrors.tuna!g'-i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repoyum makecache fast###set firewalld & optimize the os system & set selinuxecho "################# Optimize system parameters##########################"firewall_status=`systemctl status firewalld | grep Active |awk '{print $3}'`if [ ${firewall_status} == "(running)" ];thenfirewall-cmd --permanent --zone=public --add-port=1521/tcp && firewall-cmd --reloadelsesystemctl start firewalldfirewall-cmd --permanent --zone=public --add-port=1521/tcp && firewall-cmd --reloadfiSELINUX=`cat /etc/selinux/config |grep ^SELINUX=|awk -F '=' '{print $2}'`if [ ${SELINUX} == "enforcing" ];thensed -i "s@SELINUX=enforcing@SELINUX=disabled@g" /etc/selinux/configelseif [ ${SELINUX} == "permissive" ];thensed -i "s@SELINUX=permissive@SELINUX=disabled@g" /etc/selinux/configfifisetenforce 0echo "================更改为中文字符集================="cp /etc/locale.conf/etc/locale.conf.$(date +%F)cat >>/etc/locale.conf<<EOFLANG="zh_CN.UTF-8"#LANG="en_US.UTF-8"EOFsource /etc/locale.confgrep LANG /etc/locale.confaction "更改字符集zh_CN.UTF-8完成" /bin/trueecho "================================================="echo ""###set the ip in hostsecho "############################Ip&Hosts Configuration#######################################"hostname=`hostname`HostIP=`ip a|grep 'inet '|grep -v '127.0.0.1'|awk '{print $2}'|awk -F '/' '{print $1}'`for i in ${HostIP}doA=`grep "${i}" /etc/hosts`if [ ! -n "${A}" ];thenecho "${i} ${hostname}" >> /etc/hostselsebreakfidone###create group&userecho "############################Create Group&User#######################################"ora_user=oracleora_group=('oinstall' 'dba' 'oper')for i in ${ora_group[@]}doB=`grep '${i}' /etc/group`if [ ! -n ${B} ];thengroupdel ${i} && groupadd ${i}elsegroupadd ${i}fidoneC=`grep 'oracle' /etc/passwd`if [ ! -n ${C} ];thenuserdel -r ${ora_user} && useradd -u 501 -g ${ora_group[0]} -G ${ora_group[1]},${ora_group[2]} ${ora_user}elseuseradd -u 501 -g ${ora_group[0]} -G ${ora_group[1]},${ora_group[2]} ${ora_user}fiecho "${ORACLE_OS_PWD}" | passwd --stdin ${ora_user}###create directory and grant privecho "############################ Create DIR & set privileges & set OracleSid ##################"echo "############################Create OracleBaseDi #######################################"echo "############################Create OracleHomeDir #######################################"count=0while [ $count -lt 3 ]doread -p "Please input the ORACLE_SID(e.g:orcl):" S1read -p "Please input the ORACLE_SID again(e.g:orcl):" S2if [ "${S1}" == "${S2}" ];thenexport ORACLE_SID=${S1}breakelseecho "You input ORACLE_SID not same."count=$[${count}+1]fidonecount=0while [ $count -lt 3 ]doread -p "Please input the ORACLE_BASE(e.g:/u01/oracle):" S1read -p "Please input the ORACLE_BASE again(e.g:/u01/oracle):" S2if [ "${S1}" == "${S2}" ];thenexport ORACLE_BASE=${S1}breakelseecho "You input ORACLE_BASE not same."count=$[${count}+1]fi donecount=0while [ $count -lt 3 ]doread -p "Please input the ORACLE_HOME(e.g:/u01/oracle/product/12c/dbhome_1):" S1read -p "Please input the ORACLE_HOME again(e.g:/u01/oracle/product/12c/dbhome_1):" S2if [ "${S1}" == "${S2}" ];thenexport ORACLE_HOME=${S1}breakelseecho "You input ORACLE_HOME not same."count=$[${count}+1]fidoneif [ ! -d ${ORACLE_HOME} ];thenmkdir -p ${ORACLE_HOME}fiif [ ! -d ${ORACLE_BASE}/data ];thenmkdir -p ${ORACLE_BASE}/datafiif [ ! -d ${ORACLE_BASE}/recovery ];thenmkdir -p ${ORACLE_BASE}/recoveryfiora_dir=`echo ${ORACLE_BASE}|awk -F '/' '{print $2}'`###set the sysctl,limits and profileecho "############################Configure environment variables #######################################"D=`grep 'fs.aio-max-nr' /etc/sysctl.conf`if [ ! -n "${D}" ];thencat << EOF >> /etc/sysctl.confkernel.shmmax = 68719476736kernel.shmmni = 4096kernel.shmall = 16777216kernel.sem = 1010 129280 1010 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 4194304net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576fs.aio-max-nr = 1048576fs.file-max = 6815744EOF/sbin/sysctl -pelsetail -11f /etc/sysctl.conffiE=`grep 'oracle' /etc/security/limits.conf`if [ ! -n "${E}" ];thencat << EOF >> /etc/security/limits.conforacle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240EOFelsetail -5f /etc/security/limits.conffiF=`grep 'ORACLE_SID' /home/${ora_user}/.bash_profile`if [ ! -n "${F}" ];thencat << EOF >> /home/${ora_user}/.bash_profileexport ORACLE_SID=${ORACLE_SID}export ORACLE_BASE=${ORACLE_BASE}export ORACLE_HOME=${ORACLE_HOME}export PATH=$PATH:$ORACLE_HOME/binEOFelsetail -4f /home/${ora_user}/.bash_profilefiG=`grep 'oracle' /etc/profile`if [ ! -n "${G}" ];thencat << EOF >> /etc/profileif [ $USER = "oracle" ];thenif [ $SHELL = "/bin/ksh" ];thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifiEOFelsetail -8f /etc/profilefi###unzip the install package and set response fileecho "############################unzip the install package#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the zip file location(e.g:/opt/linuxamd64_12102_database_1of2.zip):" zfileoneif [ ! -f ${zfileone} ];thenecho "You input location not found zip file."count=$[${count}+1]elseexport zfileone=${zfileone}breakfidoneunzip ${zfileone} -d /${ora_dir}count=0while [ $count -lt 3 ]doread -p "Please input the zip file location(e.g:/opt/linuxamd64_12102_database_2of2.zip):" zfiltwoif [ ! -f ${zfiltwo} ];thenecho "You input location not found zip file."count=$[${count}+1]elseexport zfiltwo=${zfiltwo}breakfidoneunzip ${zfiltwo} -d /${ora_dir} && chown -R ${ora_user}:${ora_group[0]}/${ora_dir} && chmod -R 775 /${ora_dir}###set Oracle install.db.starterdb installSysPasswordecho "############################set installSysPassword#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the installSysPassword(e.g:orcl20200202):" S1read -p "Please input the installSysPassword again(orcl20200202):" S2if [ "${S1}" == "${S2}" ];thenexport installSysPassword=${S1}breakelseecho "You input installSysPassword not same."count=$[${count}+1]fidone###set Response Fileecho "############################set ResponseFile#######################################"free_m=`free -m | grep 'Mem:'|awk '{print $2}'`db_response_file=`find /${ora_dir} -type f -name db_install.rsp`data_dir=${ORACLE_BASE}/datarecovery_dir=${ORACLE_BASE}/recoverycd `find / -type f -name db_install.rsp | sed -n 's:/[^/]*$::p'` && cd ../install_dir=`pwd`sed -i "s!oracle.install.option=!oracle.install.option=INSTALL_DB_SWONLY!g" ${db_response_file}sed -i "s!ORACLE_HOSTNAME=!ORACLE_HOSTNAME=${hostname}!g" ${db_response_file}sed -i "s!UNIX_GROUP_NAME=!UNIX_GROUP_NAME=${ora_group[0]}!g" ${db_response_file}sed -i "s!INVENTORY_LOCATION=!INVENTORY_LOCATION=${ORACLE_BASE}/oraInventory!g" ${db_response_file}sed -i "s!SELECTED_LANGUAGES=en!SELECTED_LANGUAGES=en,zh_CN!g" ${db_response_file}sed -i "s!ORACLE_HOME=!ORACLE_HOME=${ORACLE_HOME}!g" ${db_response_file}sed -i "s!ORACLE_BASE=!ORACLE_BASE=${ORACLE_BASE}!g" ${db_response_file}sed -i "s!oracle.install.db.InstallEdition=!oracle.install.db.InstallEdition=EE!g" ${db_response_file}sed -i "s!oracle.install.db.DBA_GROUP=!oracle.install.db.DBA_GROUP=${ora_group[1]}!g" ${db_response_file}sed -i "s!oracle.install.db.OPER_GROUP=!oracle.install.db.OPER_GROUP=${ora_group[2]}!g" ${db_response_file}sed -i "s!oracle.install.db.BACKUPDBA_GROUP=!oracle.install.db.BACKUPDBA_GROUP=${ora_group[1]}!g" ${db_response_file}sed -i "s!oracle.install.db.DGDBA_GROUP=!oracle.install.db.DGDBA_GROUP=${ora_group[1]}!g" ${db_response_file}sed -i "s!oracle.install.db.KMDBA_GROUP=!oracle.install.db.KMDBA_GROUP=${ora_group[1]}!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.type=!oracle.install.db.config.starterdb.type=GENERAL_PURPOSE!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.globalDBName=!oracle.install.db.config.starterdb.globalDBName=${ORACLE_SID}!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.SID=!oracle.install.db.config.starterdb.SID=${ORACLE_SID}!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.characterSet=!oracle.install.db.config.starterdb.characterSet=AL32UTF8!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.memoryLimit=!oracle.install.db.config.starterdb.memoryLimit=$[free_m*8/10]!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.password.ALL=!oracle.install.db.config.starterdb.password.ALL=${installSysPassword}!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.storageType=!oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=${data_dir}!g" ${db_response_file}sed -i "s!oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=!oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=${recovery_dir}!g" ${db_response_file}sed -i "s!oracle.installer.autoupdates.option=!oracle.installer.autoupdates.option=SKIP_UPDATES!g" ${db_response_file}sed -i "s/"^SECURITY_UPDATES_VIA_MYORACLESUPPORT=.*"/SECURITY_UPDATES_VIA_MYORACLESUPPORT=false/g" ${db_response_file}sed -i "s/"^DECLINE_SECURITY_UPDATES=.*"/DECLINE_SECURITY_UPDATES=true/g" ${db_response_file}###starting to install oracle softwareecho "############################Oracle Installing#######################################"oracle_out='/tmp/oracle.out'su - oracle -c "${install_dir}/runInstaller -silent -ignorediskWarning -ignoreSysPrereqs -ignorePrereq -responseFile ${db_response_file}" > ${oracle_out} 2>&1echo -e "33[34mInstallNotice >>33[0m 33[32moracle install starting 33[05m...33[0m"sleep 60installActionslog=`find /tmp -name installActions*`echo "You cat check the oracle install log command: tail -100f ${installActionslog}"while true; dogrep '[FATAL] [INS-10101]' ${oracle_out} &> /dev/nullif [[ $? == 0 ]];thenecho -e "33[34mInstallNotice >>33[0m 33[31moracle start install has [ERROR]33[0m"cat ${oracle_out}exitfisleep 120cat /tmp/oracle.out| grep shif [[ $? == 0 ]];then`cat /tmp/oracle.out| grep sh | awk -F ' ' '{print $2}' | head -1`if [[ $? == 0 ]]; thenecho -e "33[34mInstallNotice >>33[0m 33[32mScript orainstRoot.sh run successed33[0m"`cat /tmp/oracle.out| grep sh | awk -F ' ' '{print $2}' | tail -1`if [[ $? == 0 ]];thenecho -e "33[34mInstallNotice >>33[0m 33[32mScript root.shrun successed33[0m"breakelseecho -e "33[34mInstallNotice >>33[0m 33[31mScript root.shrun faild33[0m"fielseecho -e "33[34mInstallNotice >>33[0m 33[31mScript orainstRoot.sh run faild33[0m"fifidoneecho "#######################Oracle software 安装完成##############################"# install listener && dbcaecho "############################install oracle listener && dbca#######################################"echo "############################set oracle schema sysPassword#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the SYSPASSWORD(e.g:orcl20200202):" S1read -p "Please input the SYSPASSWORD again(e.g:orcl20200202):" S2if [ "${S1}" == "${S2}" ];thenexport SYSPASSWORD=${S1}breakelseecho "You input SYSPASSWORD not same."count=$[${count}+1]fidoneecho "############################set oracle App_user#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the USER_NAME(e.g:orcl):" S1read -p "Please input the USER_NAME again(e.g:orcl):" S2if [ "${S1}" == "${S2}" ];thenexport USER_NAME=${S1}breakelseecho "You input USER_NAME not same."count=$[${count}+1]fidoneecho "############################set oracle app_passwd#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the USER_PASSWD(e.g:orcl2020):" S1read -p "Please input the USER_PASSWD again(e.g:orcl202):" S2if [ "${S1}" == "${S2}" ];thenexport USER_PASSWD=${S1}breakelseecho "You input USER_PASSWD not same."count=$[${count}+1]fidoneecho "############################set app_user tmp_dbf#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the TMP_DBF(e.g:orcl_temp):" S1read -p "Please input the TMP_DBF again(e.g:orcl_temp):" S2if [ "${S1}" == "${S2}" ];thenexport TMP_DBF=${S1}breakelseecho "You input TMP_DBF not same."count=$[${count}+1]fidoneecho "############################set app_user data_dbf#######################################"count=0while [ $count -lt 3 ]doread -p "Please input the DATA_DBF(e.g:orcl_data):" S1read -p "Please input the DATA_DBF again(e.g:orcl_data):" S2if [ "${S1}" == "${S2}" ];thenexport DATA_DBF=${S1}breakelseecho "You input DATA_DBF not same."count=$[${count}+1]fidoneORACLE_SID=`su - oracle -c 'source ~/.bash_profile && echo $ORACLE_SID'`ORACLE_BASE=`su - oracle -c 'source ~/.bash_profile && echo $ORACLE_BASE'`ORACLE_HOME=`su - oracle -c 'source ~/.bash_profile && echo $ORACLE_HOME'`ora_dir=`echo ${ORACLE_BASE}|awk -F '/' '{print $2}'`DB_SHUT=${ORACLE_HOME}/bin/dbshutDB_START=${ORACLE_HOME}/bin/dbstartDATA_DIR=${ORACLE_BASE}/dataBACKUP_DIR=${ORACLE_BASE}/backup[ ! -f $BACKUP_DIR ] && mkdir $BACKUP_DIRCDB_SQL="sqlplus / as sysdba << EOFcreate temporary tablespace $TMP_DBF tempfile '$DATA_DIR/$ORACLE_SID/${TMP_DBF}.dbf' size 64m autoextend on next 64m maxsize unlimited extent management local;create tablespace $DATA_DBF logging datafile '$DATA_DIR/$ORACLE_SID/${DATA_DBF}.dbf' size 64m autoextend on next 64m maxsize unlimited extent management local;create user $USER_NAME identified by $USER_PASSWD default tablespace $DATA_DBF temporary tablespace $TMP_DBF;grant connect,resource to $USER_NAME;grant create view to $USER_NAME;grant create public synonym to $USER_NAME;grant drop public synonym to $USER_NAME;grant unlimited tablespace to $USER_NAME;create or replace directory dir_dump as '$BACKUP_DIR';grant read,write on directory dir_dump to $USER_NAME;ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;alter system set processes=500 scope=spfile;alter system set sessions=555 scope=spfile;alter database archivelog;exitEOF"temp=`ls ${ORACLE_BASE}|grep 'data'`if [ ! -n ${temp} ];thenmkdir ${ORACLE_BASE}/dataexport DATAFILE=${ORACLE_BASE}/dataelseexport DATAFILE=${ORACLE_BASE}/datafitemp=`ls ${ORACLE_BASE}|grep 'area'`if [ ! -n ${temp} ];thenmkdir ${ORACLE_BASE}/flash_recovery_areaexport RECOVERY=${ORACLE_BASE}/flash_recovery_areaelseexport RECOVERY=${ORACLE_BASE}/flash_recovery_areafi#NETCA=`find / -type f -name netca.rsp`NETCA=`find /${ora_dir} -type f -name netca.rsp`sed -i "s!INSTALL_TYPE=""typical""!INSTALL_TYPE=""custom""!g" ${NETCA}MEM=`free -m|grep 'Mem:'|awk '{print $2}'`TOTAL=$[MEM*8/10]###set listener&tnsnamesecho "############################Oracle listener&dbca#######################################"su - oracle << EOFsource ~/.bash_profile${ORACLE_HOME}/bin/netca -silent -responsefile ${NETCA}dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -sysPassword ${SYSPASSWORD} -systemPassword ${SYSPASSWORD} -responseFile NO_VALUE -datafileDestination ${DATAFILE} -redoLogFileSize 1000 -recoveryAreaDestination ${RECOVERY} -storageType FS -characterSet AL32UTF8 -nationalCharacterSet UTF8 -sampleSchema false -memoryPercentage 80 -totalMemory $TOTAL -databaseType OLTP -emConfiguration NONEEOFsed -i "s!${ORACLE_SID}:${ORACLE_HOME}:N!${ORACLE_SID}:${ORACLE_HOME}:Y!g" /etc/oratabAUTO_START_CONFIG=`cat /etc/oratab|grep ${ORACLE_SID} |awk -F ':' '{print $NF}'`AUTO_START_CONFIG_expected='Y'if [ ${AUTO_START_CONFIG} = ${AUTO_START_CONFIG_expected} ];thenecho "AUTO_START_CONFIG successed!"elseecho "AUTO_START_CONFIG failed!" exit 1fi#set oracle to use dbstart & dbshut to control the dbsoftwaresed -i "s/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/g" ${DB_SHUT}sed -i "s/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/g" ${DB_START}#set oracle start&stop sys_serviceecho "############################Oracle sys_service#######################################"su - oracle -c "touch /home/oracle/oracle"cat >/etc/init.d/oracle <<EOF#!/bin/sh# chkconfig: 35 80 10# description: Oracle auto start-stop script.# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME# Oracle database in ORACLE_HOME.LOGFILE=/home/oracle/oracleORACLE_HOME=$ORACLE_HOMEORACLE_OWNER=oracleLOCK_FILE=/var/lock/subsys/oracleif [ ! -f $ORACLE_HOME/bin/dbstart ]thenecho "Oracle startup: cannot start"exitficase "$1" in'start')# Start the Oracle databases:echo "Starting Oracle Databases ... "echo "-------------------------------------------------" >> ${LOGFILE}date +" %T %a %D : Starting Oracle Databases as part of system up." >> ${LOGFILE}echo "-------------------------------------------------" >> ${LOGFILE}su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart" >> ${LOGFILE}echo "Done"# Start the Listener:echo "Starting Oracle Listeners ... "echo "-------------------------------------------------" >> ${LOGFILE}date +" %T %a %D : Starting Oracle Listeners as part of system up." >> ${LOGFILE}echo "-------------------------------------------------" >> ${LOGFILE}su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" >> ${LOGFILE}echo "Done."echo "-------------------------------------------------" >> ${LOGFILE}date +" %T %a %D : Finished." >> ${LOGFILE}echo "-------------------------------------------------" >> ${LOGFILE}touch $LOCK_FILE;;'stop')# Stop the Oracle Listener:echo "Stoping Oracle Listeners ... "echo "-------------------------------------------------" >> ${LOGFILE}date +" %T %a %D : Stoping Oracle Listener as part of system down." >> ${LOGFILE}echo "-------------------------------------------------" >> ${LOGFILE}su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop" >> ${LOGFILE}echo "Done."rm -f $LOCK_FILE# Stop the Oracle Database:echo "Stoping Oracle Databases ... "echo "-------------------------------------------------" >> ${LOGFILE}date +" %T %a %D : Stoping Oracle Databases as part of system down." >> ${LOGFILE}echo "-------------------------------------------------" >> ${LOGFILE}su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut" >> ${LOGFILE}echo "Done."echo ""echo "-------------------------------------------------" >> ${LOGFILE}date +" %T %a %D : Finished." >> ${LOGFILE}echo "-------------------------------------------------" >> ${LOGFILE};;'restart')$0 stop$0 start;;esacEOF#set privilegeschmod +x /etc/init.d/oraclechkconfig oracle on# check oracle serviceservice oracle startif [ $? -ne 0 ];thenaction "oracle service start failed." /bin/falseexit 2fiservice oracle stopif [ $? -ne 0 ];thenaction "oracle service stop failed." /bin/falseexit 3fiservice oracle restartif [ $? -ne 0 ];thenaction "oracle service restart failed." /bin/falseexit 4fi#set create app_user & app_passwdecho "############################Oracle sys_service#######################################"su - oracle -c "${CDB_SQL}"if [ $? -eq 0 ];thenecho -e "e[30 CDB_SQL execute successed & restart the oracle_service e[0m"service oracle restartelseaction "oracle create app_user && app_passwd failed." /bin/falseexit 5fiecho "####################### oracle listener && dbca安装完成 请记录数据库信息##############################"echo "#####oracle用户系统登录密码:#####"echo -e "e[31;47;5m $ORACLE_OS_PWD e[0m"echo "#####数据库实例名:#####"echo -e "e[30;47;5m $ORACLE_SID e[0m"echo "#####数据库install.db.starterdb密码:#####"echo -e "e[31;47;5m $installSysPassword e[0m"echo "#####数据库实例的sys管理用户密码:#####"echo -e "e[30;47;5m $SYSPASSWORD e[0m"echo "#####数据库应用连接用户名:#####"echo -e "e[31;47;5m $USER_NAME e[0m"echo "#####数据库应用连接用户名对应的密码:#####"echo -e "e[30;47;5m $USER_PASSWD e[0m"echo "#####数据库临时表空间名:#####"echo -e "e[31;47;5m $TMP_DBF e[0m"echo "#####数据库数据表空间名:#####"echo -e "e[30;47;5m $DATA_DBF e[0m"
推荐阅读
- 自动挡等红灯,挂D挡踩刹车,你知道变速箱在经历什么吗?
- 网管软件怎么样?如何安装?
- 安装Windows 10 2004原版系统
- 手机怎样给视频添加文字?点击这个按钮,一键自动添加
- C2驾照怎么升C1?
- 世界上最早的自动销售机销售的是什么?
- 简单实用的监控系统安装调试全过程,新手入门基础知识
- 微软|微软Edge Dev浏览器102新功能被点赞:自动导入移动设备密码
- 基于 ESP8266 的家庭自动化
- 淘宝自动回复算回复率吗 淘宝客服回复率怎么算的