Init.d
Oracle Linux 7:使用 init.d 自動啟動 Oracle
我嘗試在我的 Oracle Linux 7.3 機器上通過 init.d 使 Oracle 12.1.0.2.0 從系統啟動。
我遵循了這個例子:https ://oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux
這是我啟動數據庫的腳本:
#!/bin/sh # chkconfig: 345 99 10 # description: Oracle auto start-stop script. # # Set ORA_HOME to be equivalent to the $ORACLE_HOME # from which you wish to execute dbstart and dbshut; # # Set ORA_OWNER to the user id of the owner of the # Oracle database in ORA_HOME. ORA_HOME=/u01/app/oracle/product/12.1.0.2/db_1 ORA_OWNER=oracle case "$1" in 'start') # Start the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values # Remove "&" if you don't want startup as a background process. su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" & su $ORA_OWNER -c $ORA_HOME/bin/dbstart & touch /var/lock/subsys/dbora ;; 'stop') # Stop the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values su $ORA_OWNER -c $ORA_HOME/bin/dbshut su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" rm -f /var/lock/subsys/dbora ;; esac
開始時沒有任何反應。
/etc/rc0.d
我在和中創建了軟連結/etc/rc3.d
:ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora chkconfig --level 2345 dbora on
chkconfig
列出dbora.sh
withrunlevel 2345
on從一個簡短的腳本手動開始就可以了,如下所示:
#!/bin/sh $ORACLE_HOME/bin/lsnrctl start $ORACLE_HOME/bin/dbstart
我錯過了什麼?
感謝 wurtel,我找到了解決方案。為了讓 Oracle DB 在機器上執行,我必須使用 systemd。這是它的指南: https ://oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux#oracle-11gr2-update
按照 Oracle 11gR2+ 部分(最後一個)了解如何創建 startup.sh 和 shutdown.sh。然後按照本教程設置單元文件: https ://oracle-base.com/articles/linux/linux-services-systemd#creating-linux-services
奇蹟般有效 :)