Oracle Self-boot configuration and startup script 12c test via Linux

Source: Internet
Author: User

Reference: http://www.jb51.net/article/32214.htm

1. Some basic parameters of Oracle
[Email protected] ~]$ echo $ORACLE _sid
Adela
[Email protected] ~]$ echo $ORACLE _home
/u01/app/oracle/product/12.1.0/db_1
[Email protected] ~]$ echo $ORACLE _base
/u01/app/oracle

2. Modify the/etc/oratab so that Oracle can self-boot
[Email protected] ~]$ Vim/etc/oratab
Add a row
# $ORACLE _sid: $ORACLE _home:<n| Y>:
Adela:/u01/app/oracle/product/12.1.0/db_1:y

3. Create a file under/etc/init.d/Oracle
[Email protected] ~]# touch/etc/init.d/oracle
[Email protected] ~]# chmod 755/etc/init.d/oracle
[Email protected] ~]# vim/etc/init.d/oracle
Add the following script

#!/bin/sh# chkconfig: 35 80 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/db_1ora_owner=oracleif [ ! -f  $ORA _home/bin/ dbstart ]thenecho  "Oracle startup: cannot start" exitficase  "$"  in ' start ') #  Start the Oracle databases:echo  "starting oracle databases ... " echo  "-------------------------------------------------"  >> /var/log/oracledate + "  %t %a %d : starting oracle databases as part of  system up. "  >> /var/log/oracleecho  "-------------------------------------------------"  >>  /var/log/oraclesu -  $ORA _owner -c  "$ORA _home/bin/dbstart"  >>/var/log/ oracleecho  "Done" # start the listener:echo  "starting oracle listeners  ...  "echo "-------------------------------------------------" >> /var/log/oracledate  + " %t %a %d : starting oracle listeners as part of  system up. "  >> /var/log/oracleecho  "-------------------------------------------------"  >>  /var/log/oraclesu -  $ORA _owner -c  "$ORA _home/bin/lsnrctl start"  >>/ var/log/oracleecho  "Done." echo  "-------------------------------------------------"  >> /var/log/oracledate + "  %t %a %d : finished. "  >> /var/log/oracleecho  "-------------------------------------------------"  >> /var/log /oracletouch /var/lock/subsys/oracle;; ' Stop ') # stop the oracle listener:echo  "STOPING&NBSP;ORACLE&NBSP;LISTENERS&NBSP;   "echo "-------------------------------------------------" >> /var/log/oracledate  + " %T %a %D : Stoping Oracle Listener as part of  System down. "  >> /var/log/oracleecho  "-------------------------------------------------"  >>  /var/log/oraclesu -  $ORA _owner -c  "$ORA _home/bin/lsnrctl stop"  >>/ var/log/oracleecho  "Done." rm -f /var/lock/subsys/oracle# stop the oracle database:echo  "Stoping  oracle databases ...  "echo "-------------------------------------------------" > > /var/log/oracledate + " %t %a %d : stoping oracle databases as part of system  down. "  >> /var/log/oracleecho  "-------------------------------------------------"  >>  /var/log/oraclesu -  $ORA _owner -c  "$ORA _home/bin/dbshut"  >>/var/log/ oracleecho  "Done." echo  "" echo  "-------------------------------------------------"  >> /var/log/ oracledate + " %t %a %d : finished."  >> /var/log/oracleecho  "-------------------------------------------------"  >>  /var/log/oracle;; ' Restart ') $0 stop$0 start;; Esac


4. Add a service
[Email protected] ~]# chkconfig--level Oracle on

5. Need to stop the database before shutting down or restarting the machine, do the following
[[email protected] ~]# ln-s/etc/init.d/oracle/etc/rc0.d/k01oracle//shutdown
[[email protected] ~]# ln-s/etc/init.d/oracle/etc/rc6.d/k01oracle//restart

6. Test whether the command is valid
[[Email protected] ~]# service Oracle start//Start Oracle

Starting Oracle Databases ...
Done
Starting Oracle Listeners ...
Done.

[[Email protected] ~]# service Oracle Stop//Turn off Oracle

Stoping Oracle Listeners ...
Done.
Stoping Oracle Databases ...
Done.

# Service Oracle Restart//Restart Oracle
[[Email protected] ~]# service Oracle Restart
Stoping Oracle Listeners ...
Done.
Stoping Oracle Databases ...
Done.

Starting Oracle Databases ...
Done
Starting Oracle Listeners ...
Done.

7. Restart Linux

[email protected] ~]# reboot


8. After reboot, go to Oracle user, enter Sqlplus

[Email protected] desktop]$ Sqlplus/as SYSDBA

Sql*plus:release 12.1.0.1.0 Production on Sat 18 23:16:17 2015

Copyright (c) 1982, Oracle. All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0-64bit Production
With the partitioning, OLAP, Advanced Analytics and Real application testing options


Sql> set linesize 300;
Sql> set pagesize 30;
Sql> select Sysdate from dual;

Sysdate
---------
18-jul-15


The database starts normally!

This article is from the "Adela" blog, make sure to keep this source http://adelazhu.blog.51cto.com/9455045/1675970

Oracle Self-boot configuration and startup script 12c test via Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.