Oracle 服務自啟動

來源:互聯網
上載者:User

1. 修改/etc/oratab檔案
db1:/home/Oracle/product/11.2.0/db_1:Y
$ORACLE_SID:$ORACLE_HOME:Y
2. 修改開機檔案$ORACLE_HOME/bin/dbstart
修改ORACLE_HOME_LISTNER=$1 為ORACLE_HOME_LISTNER=/home/oracle/product/11.2.0/db_1
3.修改關閉檔案$ORACLE_HOME/bin/dbshut
修改ORACLE_HOME_LISTNER=$1 為ORACLE_HOME_LISTNER=/home/oracle/product/11.2.0/db_1
4. 在/etc/init.d下建立指令碼
vi /etc/init.d/oracle11
 #!/bin/bash
            # chkconfig: 345 88 14
            # description: Startup Script. for oracle Databases
            # /etc/rc.d/init.d/oradbstart
            export ORACLE_BASE=/home/oracle
            export ORACLE_HOME=/home/oracle/product/11.2.0/db_1
            export ORACLE_SID=dbl
            export PATH=$PATH:$ORACLE_HOME/bin
            case "$1" in
              start)
                echo "-----startup oracle-----" >> /var/log/oracle11log
                su oracle -c $ORACLE_HOME/bin/dbstart
                touch /var/lock/subsys/oracle11
                echo "-----startup oracle successful-----" >> /var/log/oracle11log
                echo "OK"
                ;;
 
             stop)
                echo "-----shutdwn oracle-----" >> /var/log/oracle11log
                su oracle -c $ORACLE_HOME/bin/dbshut
                rm -f /var/lock/subsys/oracle11
                echo "-----shutdown oracle successful-----" >> /var/log/oracle11log
                echo "OK"
                ;;
 
               *)
              echo "Usage: 'basename $0' start|stop"
              exit 1
              esac
              exit 0
儲存退出。
5. 授於許可權
  chown oracle:oinstall oracle11
  chmod 774 oracle11
6. 添加服務
  chkconfig --add oracle11
  chkconfig oracle11 on
   chkconfig --list | grep oracle11
7.嘗試用服務方式關閉,啟動
[root@rman ~]# service oracle11 stop
Processing Database instance "db1": log file /home/oracle/product/11.2.0/db_1/shutdown.log
OK
[root@rman ~]# ps -elf | grep ora_
0 S root      4814  4543  0  78   0 - 15307 pipe_w 17:33 pts/1    00:00:00 grep ora_
[root@rman ~]# service oracle11 start
Processing Database instance "db1": log file /home/oracle/product/11.2.0/db_1/startup.log
OK
[root@rman ~]# ps -elf | grep ora_
0 S oracle    4959     1  0  75   0 - 193270 665975 17:33 ?       00:00:00 ora_pmon_db1
0 S oracle    4963     1  0  58   - - 193106 -     17:33 ?        00:00:00 ora_vktm_db1
0 S oracle    4969     1  0  78   0 - 193106 -     17:33 ?        00:00:00 ora_gen0_db1
0 S oracle    4973     1  0  78   0 - 193106 -     17:33 ?        00:00:00 ora_diag_db1
0 S oracle    4977     1  0  75   0 - 193106 -     17:33 ?        00:00:00 ora_dbrm_db1
0 S oracle    4981     1  0  78   0 - 193106 -     17:33 ?        00:00:00 ora_psp0_db1
0 S oracle    4985     1  0  78   0 - 193234 -     17:33 ?        00:00:00 ora_dia0_db1
0 S oracle    4989     1  0  78   0 - 193106 -     17:33 ?        00:00:00 ora_mman_db1
0 S oracle    4993     1  0  75   0 - 194081 -     17:33 ?        00:00:00 ora_dbw0_db1
0 S oracle    4997     1  0  75   0 - 196994 -     17:33 ?        00:00:00 ora_lgwr_db1
0 S oracle    5001     1  0  76   0 - 193106 -     17:33 ?        00:00:00 ora_ckpt_db1
0 S oracle    5005     1  0  75   0 - 193106 -     17:33 ?        00:00:00 ora_smon_db1
0 S oracle    5009     1  0  78   0 - 193106 -     17:33 ?        00:00:00 ora_reco_db1
0 S oracle    5013     1  2  75   0 - 193796 -     17:33 ?        00:00:00 ora_mmon_db1
0 S oracle    5017     1  0  75   0 - 193106 -     17:33 ?        00:00:00 ora_mmnl_db1
0 S oracle    5021     1  0  78   0 - 193276 912653 17:33 ?       00:00:00 ora_d000_db1
0 S oracle    5025     1  0  78   0 - 193114 903991 17:33 ?       00:00:00 ora_s000_db1
0 S oracle    5043     1  0  78   0 - 193106 -     17:33 ?        00:00:00 ora_qmnc_db1
0 S root      5161  4543  0  78   0 - 15308 pipe_w 17:33 pts/1    00:00:00 grep ora_
8.重啟動測試。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.