Tuesday, June 28, 2022

dbstart & dbshut Automatic startup & Shutdown Databases

dbstart & dbshut Automatic startup & Shutdown Databases:


1. We have to run these sb start and dbshut as oracle owner only 
2. Before using these command, need to set /etc/oratab with autorestart as "Y"


$ORACLE_HOME/bin/dbstart $ORACLE_HOME
$ORACLE_HOME/bin/dbshut $ORACLE_HOME

1. Verify the environment details:

[root@oraclelab1 ~]# ps -ef|grep smon
oracle    3576     1  0 Jun27 ?        00:00:00 ora_smon_CDBDB
oracle    4124     1  0 Jun27 ?        00:00:00 ora_smon_DEVDB
root     14722 14441  0 11:06 pts/0    00:00:00 grep --color=auto smon
[root@oraclelab1 ~]#

[root@oraclelab1 ~]# cat /etc/oratab
#
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
DEVDB:/u01/app/oracle/product/19.0.0.0/dbhome_1:Y
CDBDB:/u01/app/oracle/product/19.0.0.0/dbhome_1:Y
[root@oraclelab1 ~]#

[oracle@oraclelab1 ~]$ cd $ORACLE_HOME/bin/
[oracle@oraclelab1 bin]$ ll dbstart
-rwxr-x---. 1 oracle oinstall 15737 Jan  1  2000 dbstart

[oracle@oraclelab1 bin]$ ll dbshut
-rwxr-x---. 1 oracle oinstall 8142 Jan  1  2000 dbshut
[oracle@oraclelab1 bin]$

2. Shutdown Database using dbshut:

[oracle@oraclelab1 bin]$ $ORACLE_HOME/bin/dbshut $ORACLE_HOME
Processing Database instance "DEVDB": log file /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/shutdown.log
Processing Database instance "CDBDB": log file /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/shutdown.log
[oracle@oraclelab1 bin]$ ps -ef|grep smon
oracle   15390 14917  0 11:11 pts/0    00:00:00 grep --color=auto smon
[oracle@oraclelab1 bin]$ 

[root@oraclelab1 ~]# tail -f /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/shutdown.log

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 28 11:10:58 2022
Version 19.3.0.0.0

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

SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

Database instance "CDBDB" shut down.

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 28 11:10:58 2022
Version 19.3.0.0.0

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

SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Database instance "DEVDB" shut down.

3. Start Database using dbstart:

[oracle@oraclelab1 bin]$ ps -ef|grep smon
oracle   15390 14917  0 11:11 pts/0    00:00:00 grep --color=auto smon
[oracle@oraclelab1 bin]$ $ORACLE_HOME/bin/dbstart $ORACLE_HOME
Processing Database instance "DEVDB": log file /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/startup.log
Processing Database instance "CDBDB": log file /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/startup.log
[oracle@oraclelab1 bin]$ ps -ef|grep smon
oracle   15569     1  0 11:12 ?        00:00:00 ora_smon_DEVDB
oracle   15913     1  0 11:12 ?        00:00:00 ora_smon_CDBDB
oracle   16284 14917  0 11:12 pts/0    00:00:00 grep --color=auto smon
[oracle@oraclelab1 bin]$

[root@oraclelab1 ~]# tail -f /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/startup.log
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/dbstart: Starting up database "DEVDB"
Tue Jun 28 11:12:19 IST 2022
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 28 11:12:19 2022
Version 19.3.0.0.0

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

SQL> Connected to an idle instance.
SQL> ORACLE instance started.

Total System Global Area 2147481656 bytes
Fixed Size                  8898616 bytes
Variable Size             486539264 bytes
Database Buffers         1644167168 bytes
Redo Buffers                7876608 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/dbstart: Database instance "DEVDB" warm started.

/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/dbstart: Starting up database "CDBDB"
Tue Jun 28 11:12:30 IST 2022
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 28 11:12:30 2022
Version 19.3.0.0.0

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

SQL> Connected to an idle instance.
SQL> ORACLE instance started.

Total System Global Area 3707763808 bytes
Fixed Size                  9141344 bytes
Variable Size             855638016 bytes
Database Buffers         2835349504 bytes
Redo Buffers                7634944 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/dbstart: Database instance "CDBDB" warm started.


4. If we set auto-restart as "N" in /etc/oratab then these dbstart and dbshut script will not work:

[oracle@oraclelab1 bin]$ cat /etc/oratab
#
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
DEVDB:/u01/app/oracle/product/19.0.0.0/dbhome_1:N
CDBDB:/u01/app/oracle/product/19.0.0.0/dbhome_1:N
[oracle@oraclelab1 bin]$

[oracle@oraclelab1 bin]$ $ORACLE_HOME/bin/dbshut $ORACLE_HOME
[oracle@oraclelab1 bin]$ $ORACLE_HOME/bin/dbstart $ORACLE_HOME

5. If we try start with root user or other than oracle owner then it will throw an error message:

[root@oraclelab1 ~]# $ORACLE_HOME/bin/dbshut $ORACLE_HOME
Processing Database instance "DEVDB": log file /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/shutdown.log
Processing Database instance "CDBDB": log file /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/shutdown.log
[root@oraclelab1 ~]#

[root@oraclelab1 ~]# tail -f /u01/app/oracle/product/19.0.0.0/dbhome_1/rdbms/log/shutdown.log

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 28 11:14:44 2022
Version 19.3.0.0.0

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

SQL> ERROR:
ORA-01017: invalid username/password; logon denied


SQL> ORA-01012: not logged on
SQL> Database instance "DEVDB" shut down.

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 28 11:14:46 2022
Version 19.3.0.0.0

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

SQL> ERROR:
ORA-01017: invalid username/password; logon denied


SQL> ORA-01012: not logged on
SQL> Database instance "CDBDB" shut down.

Regards,
Mallik

No comments:

Post a Comment

Automation Script | Archivelog Generation Hourly Monitoring

1. List out all the running databases and pic one database where we want to monitore the archive log generation from last 1 month. [oracle@o...