Oracle 12cR2 Installation On CentOS-7

來源:互聯網
上載者:User

標籤:case   home   echo   multi   rdbms   pat   .com   setting   finish   

安裝oracle-database-server-12cR2-preinstall

wget http://public-yum.oracle.com/public-yum-ol7.repo -O /etc/yum.repos.d/public-yum-ol7.repowget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracleyum clean allyum -y updateyum -y groupinstall 'X Window System'yum -y install oracle-database-server-12cR2-preinstall

建立Oracle安裝目錄

mkdir -p /u01/app/oracle/product/12.2.0.1/db_1chown -R oracle:oinstall /u01chmod -R 775 /u01

建立oracle環境變數設定檔

mkdir /home/oracle/scriptscat > /home/oracle/scripts/setEnv.sh <<EOF# Oracle Settingsexport TMP=/tmpexport TMPDIR=\$TMPexport ORACLE_HOSTNAME=ol7-122.localdomainexport ORACLE_UNQNAME=cdb1export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=\$ORACLE_BASE/product/12.2.0.1/db_1export ORACLE_SID=cdb1export PATH=/usr/sbin:/usr/local/bin:\$PATHexport PATH=\$ORACLE_HOME/bin:\$PATHexport LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/libexport CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlibEOFecho ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile

建立Oracle啟動指令碼,放在 /home/oracle/scripts/dbora.sh

#!/bin/bash. /home/oracle/scripts/setEnv.shexport ORAENV_ASK=NO. oraenvexport ORAENV_ASK=YESstartup_log=/home/oracle/scripts/startup.logshutdown_log=/home/oracle/scripts/shutdown.logfunction oracle_start(){    # Start the Oracle databases:    echo "-------------------------------------------------"    date +" %T %a %D : Starting Oracle Databases as part of system up."    echo "-------------------------------------------------"    ${ORACLE_HOME}/bin/sqlplus /nolog << EOF    conn / as sysdba    startup    alter pluggable database all open;    exitEOF    echo "Done."    # Start the Listener:    echo "-------------------------------------------------"    date +" %T %a %D : Starting Oracle Listeners as part of system up."    echo "-------------------------------------------------"    ${ORACLE_HOME}/bin/lsnrctl start     echo "Done."     echo "-------------------------------------------------"     date +" %T %a %D : Finished."    echo "-------------------------------------------------"}function oracle_stop(){    # Stop the Oracle Listener:    echo "-------------------------------------------------"    date +" %T %a %D : Stoping Oracle Listener as part of system down."     echo "-------------------------------------------------"    ${ORACLE_HOME}/bin/lsnrctl stop     echo "Done."       # Stop the Oracle Database:    echo "-------------------------------------------------"     date +" %T %a %D : Stoping Oracle Databases as part of system down."     echo "-------------------------------------------------"    ${ORACLE_HOME}/bin/sqlplus /nolog << EOF    conn / as sysdba    alter pluggable database all close immediate;    shutdown immediate    exitEOF    echo "Done."     echo ""    echo "-------------------------------------------------"    date +" %T %a %D : Finished."    echo "-------------------------------------------------"         }case "$1" instart)    echo "Starting Oracle Databases ... "    oracle_start >> $startup_log    echo "Oracle Started Successfully."    ;;stop)    echo "Stoping Oracle Databases ... "    oracle_stop >> $shutdown_log    echo "Oracle Stopped."    ;;restart)    echo "Restarting Oracle Databases ... "    oracle_stop >> $shutdown_log    oracle_start >> $startup_log    echo " Oracle Restarted."    ;;status)    ${ORACLE_HOME}/bin/lsnrctl status    ;;*)    echo "Usage: $(basename $0) {start|strop|restart|status}"    exit 1esacexit 0

調整指令檔許可權:

chown -R oracle.oinstall /home/oracle/scriptschmod u+x /home/oracle/scripts/*.sh

編寫 systemd.service 服務指令碼,在 /etc/systemd/system/oracle.service

[Unit]Description=Oracle ServiceAfter=network.targetAfter=syslog.target[Service]User=oracleGroup=dbaType=oneshotExecStart=/home/oracle/scripts/dbora.sh startExecReload=/home/oracle/scripts/dbora.sh restartExecStop=/home/oracle/scripts/dbora.sh stopRemainAfterExit=yes[Install]WantedBy=multi-user.target

root使用者執行:systemctl enable oracle.service
完成後即可啟動Oracle Universal Installations (OUI)

Oracle 12cR2 Installation On CentOS-7

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.