Get the App
SLTechnology News&Howtos  ›  Database  › 

Environment configuration of oracle-set Power on (Linux) to automatically start Oracle shutdown and automatically close Oracle

Shulou Source: shulou.com Published: 2022-06-01 08:57:48 10月04日 Update

Set power on (Linux) to automatically start Oracle shutdown and automatically shut down Oracle

1. Switch to the root user and make sure that the startup file and the closed file exist.

[oracle@oracle3 bin] $pwd

/ u01/oracle/product/10.2.0/db_1/bin

[oracle@oracle3 bin] $ls dbstart

Dbstart-the script that sqlplus calls when it executes startup

[oracle@oracle3 bin] $ls dbshut

Dbshut-the script that sqlplus calls when it executes shutdown

2. Modify oratab file

[oracle@oracle3 etc] $vim / etc/oratab

ORCL:/u01/oracle/product/10.2.0/db_1:Y-change N to Y

3. Test the correctness of startup files and closed files

/ u01/oracle/product/10.2.0/db_1/bin

[oracle@oracle3 bin] $export ORACLE_SID=ORCL

[oracle@oracle3 bin] $dbshut

[oracle@oracle3 bin] $sqlplus / nolog

SQL*Plus: Release 10.2.0.1.0-Production on Thu Jun 5 16:23:12 2014

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

SQL > conn / as sysdba

Connected to an idle instance. The database is closed

Note: conn / as sysdba = conn sys/orcl as sysdba

SQL > conn sys/orcl as sysdba

Connected to an idle instance. Connecting to an idle routine indicates that the database is not started

SQL > conn sys/orcl@ORCL as sysdba

ERROR:

ORA-12514: TNS:listener does not currently know of service requested in connect

Descriptor

Warning: You are no longer connected to ORACLE. Because the database is closed, it cannot be accessed by listeners, and can only be connected as sysdba.

No matter what you do, you must connect and log in to verify the operating system's password file with the identity of sysdba.

[oracle@oracle3 bin] $dbstart-- Test startup files are available

Failed to auto-start Oracle Net Listene using / ade/vikrkuma_new/oracle/bin/tnslsnr

Processing Database instance "ORCL": log file / u01/oracle/product/10.2.0/db_1/startup.log

[oracle@oracle3 bin] $sqlplus / nolog

SQL*Plus: Release 10.2.0.1.0-Production on Thu Jun 5 16:30:35 2014

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

SQL > conn / as sysdba

Connected. --

4. Write a shell script

[root@oracle3 ~] # cd / etc/rc.d/init.d

[root@oracle3 init.d] # touch start_shut

[root@oracle3 init.d] # vi start_shut

-

#! / bin/sh

OPT_=$1

Case "$OPT_" in

Start)

/ bin/echo "$0: (start)"

#

# your service startup command goes here

#

Su-oracle-c "/ u01/oracle/product/10.2.0/db_1/bin/lsnrctl start"

Su-oracle-c "/ u01/oracle/product/10.2.0/db_1/bin/dbstart"

# NOTE:Must exit with zero unless error is server

Chmod 1777 / tmp

Chown sys:sys / tmp

Exit 0

Stop)

/ bin/echo "$: (stop)"

#

# your service shutdown command goes here.

#

Su-oralce-c "/ u01/oracle/product/10.2.0/db_1/bin/dbshut"

Su-oracle-c "/ u01/oracle/product/10.2.0/db_1/bin/lsnrctl stop"

# Note: Must exit with zero unless error is server

Exit 0

*) / bin/echo''

/ bin/echo "Usage: $0 [start | stop]"

/ bin/echo "Invalid argument = = >\" ${OPT_}\ ""

/ bin/echo''

Exit 0

Esac

5. Modify permissions

[root@oracle3 init.d] # chmod 755 start_shut

6. Link the file to the startup area and the closed area

[root@oracle3 init.d] # cd / etc/rc5.d

[root@oracle3 rc5.d] # ln-s / etc/rc.d/init.d/start_shut S99start_shut

[root@oracle3 rc5.d] # cd / etc/rc0.d

[root@oracle3 rc0.d] # ln-s / etc/rc.d/init.d/start_shut K01start_shut

7. Test:

Init 6

Tags: File data database script test zone time identity operating system password permissions correctness user listener idle system link switch login monitor Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker Huawei Apple Xiaomi