Skip to content
Home » Oracle Database » How to Restart Oracle Database

How to Restart Oracle Database

In this post, we'll talked about how to restart a database in a efficient way, which includes:

  1. Restart a Single-Instance DB
  2. Restart a RAC DB

Restart a Single-instance Database

There're 2 ways to restart a single-instance database.

Shutdown and Startup

Normally, we take two steps to restart a running database, which are shutdown and startup.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
...
Database mounted.
Database opened.

dbstart

We can also use Oracle utility dbstart to restart the database in only one command without using dbshut. But first, you have to make sure that you enable it to do so.

[oracle@test ~]$ vi /etc/oratab
...
ORCL:/u01/app/oracle/product/12.1.0/dbhome_1:Y

You have to set the database to Y to allow dbstart to do shutdown and startup. Before we start it, we check the database startup time.

First of all, we format the date time of current session.

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Session altered.

Then we perform the query.

SQL> select startup_time from v$instance;

STARTUP_TIME
-------------------
2019-09-20 21:56:52

Perform a Restart

[oracle@test ~]$ dbstart
...

Check Startup Time After Restart

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> select startup_time from v$instance;

STARTUP_TIME
-------------------
2019-09-20 22:09:03

That is to say, if the database is stop, dbstart will start it. If the database is running, dbstart will stop it first then a startup follows automatically.

I guess maybe you also want to know how to deploy auto startup script at system boot on Linux.

Restart a RAC Database

For a RAC database, there's no explicit restart command for us to use. We usually do it in two steps:

[oracle@test ~]$ srvctl stop database -d testcdb
[oracle@test ~]$ srvctl start database -d testcdb

Then check the status.

[oracle@test ~]$ srvctl status database -d testcdb

If you do mind this matter, you can do the following consecutive command to remove the execution gap between stop and start without waiting.

[oracle@test ~]$ srvctl stop database -d testcdb; srvctl start database -d testcdb; srvctl status database -d testcdb

Leave a Reply

Your email address will not be published. Required fields are marked *