The leading edge of scripting languages and Oracle Database brought to you by the Data Access Development team

How I Enable Autostarting of Oracle Database for Demonstrations and Development

Christopher Jones
Senior Principal Product Manager

Here are the steps I have been using to enable autostarting of Oracle Database Enterprise Edition 10g, 11g or 12c during boot time of Oracle Linux 5 and 6. I also use these steps with Oracle Linux 7. These steps are useful for the kinds of demonstration and development setups that I typically need.

These steps are not needed for Oracle XE, since its install will prompt whether to autostart the DB and will configure the system automatically.

Create a new service script

Create a file /etc/init.d/dbora using dbora

Set permissions on the script

# chmod 750 /etc/init.d/dbora

Tell Linux to autostart/stop the service

On Oracle Linux 5 and 6 run:

# chkconfig --add dbora
# chkconfig dbora on

On Oracle Linux 7 run:

# systemctl enable dbora

Edit /etc/oratab

In /etc/oratab, change the autostart field from N to Y for any databases that you want autostarted.

Starting / Stopping the DB

The DB will start and stop at machine boot and shutdown.

Or it can be manually controlled with:

# service dbora start


# service dbora stop

On Oracle Linux 7, use 'systemctl start dbora' and 'systemctl stop dbora'.

Starting Oracle Database 12c Multitenant PDBs

To also start all pluggable databases when the container database starts, run this in SQL*Plus as SYSDBA:

create or replace trigger sys.after_startup
   after startup on database
   execute immediate 'alter pluggable database all open';
end after_startup;

If you want to read more, check the official documentation about auto starting here.

Join the discussion

Comments ( 14 )
  • Rameswara topuri Friday, July 7, 2017
    good one
  • Ravi Joshi Monday, October 30, 2017
    Is it possible for you to update and in essence guide people on how to use systemd in stead of system SVR4's init.d directory?
  • Chris Jones Monday, October 30, 2017
    The instructions are still viable on Oracle Linux 7 and usable for test & development. If you have specific updates to be more 'officially' systemd-like, please post them here.
  • Thomas Monday, January 1, 2018
    just to confirm - dbora supposed to me empty? well, at least on my RedHat it doesn't work...

    # ls -la
    total 52
    drwxr-xr-x. 2 root root 141 Jan 1 22:59 .
    drwxr-xr-x. 10 root root 127 Jan 1 14:12 ..
    -rwxr-xr-x. 1 root root 318 Nov 3 15:18 choose_repo
    -rwxr-x---. 1 root root 0 Jan 1 22:59 dbora
    -rw-r--r--. 1 root root 17500 May 3 2017 functions
    -rwxr-xr-x. 1 root root 4334 May 3 2017 netconsole
    -rwxr-xr-x. 1 root root 7293 May 3 2017 network
    -rw-r--r--. 1 root root 1160 Sep 29 08:00 README
    -rwxr-xr-x. 1 root root 1868 Nov 3 15:18 rh-cloud-firstboot
    -rwxr-xr-x. 1 root root 2443 Oct 31 09:28 rhnsd
    [root@ip-172-31-39-17 init.d]# chkconfig -add dbora
    -add: unknown option
    [root@ip-172-31-39-17 init.d]# chkconfig --add dbora
    error reading information on service dbora: Invalid argument
    [root@ip-172-31-39-17 init.d]# chkconfig dbora on
    error reading information on service dbora: Invalid argument
  • Christopher Jones Monday, January 8, 2018
    dbora is not empty. The link in the post is correctly showing me the file contents.

    If you are using Oracle Linux 7, run 'systemctl enable dbora' to enable the service.
  • Patrick Tuesday, June 5, 2018

    I'm currently running Redhat 7.3 I try to used systemctl enable dbora but I got this message.

    dbora.service is not a native service, redirecting to /sbin/chkconfig.
    Executing /sbin/chkconfig dbora on

    any idea why systemctl doesn't work?

  • Christopher Jones Wednesday, June 6, 2018
    For OL7 niceness someone would need to create a /etc/systemd/system/dbora.service file with proper systemd syntax. Maybe something like https://community.oracle.com/thread/2520738
  • Gerrit Haase Tuesday, November 20, 2018

    useful stuff.
    However, what about individual listener names, this solution supports only defult listener names?

  • Christopher Jones Tuesday, November 20, 2018
    Feel free to hack the script in whatever way works for you.
  • Roger Friday, February 15, 2019
    Your script has a hard-coded ORACLE_HOME in it. What if I have multiple ORACLE_HOMEs for different databases - do I need to copy the section several times for each db?

    It doesn't appear to read read /etc/oratab - how does the Y/N setting in that affect whether the database is started or not?
  • Roger Ford Friday, February 15, 2019
    Ah, I think I see. You can specify any ORACLE_HOME, and the dbstart from that home will start all the databases, reading their ORACLE_HOME and startup settings from /etc/oratab. Are there any limitations? Can an 11g dbstart successfully start an 18c database, for example?
  • Christopher Jones Friday, February 15, 2019
    The script has a focus for my purposes. You can extend it at will.

    My current script sets ORACLE_HOME like:

    # Note:
    # Change the awk pattern to match a DB of the ORACLE_HOME to be used
    # Change the autostart entry of /etc/oratab to Y for any DB you want started; this is required by dbstart
    ORACLE_HOME=$(awk -F: '/^orcl:/ {print $2}' /etc/oratab )

    This means I don't have to update the path each time I change the location (or version) of the Oracle software.
  • Alvaro Saturday, October 24, 2020
    When I put in prompt the command "sudo /etc/init.d/dbora" it says ": invalid option" and I only copied the content of the file "dbora" and change the address of $ORACLE_HOME.
  • Christopher Jones Monday, October 26, 2020
    I'm not familiar with that error. Try doing some debugging (probably with echo commands) and see what is failing.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.