OracleDBインスタンスの起動方法と停止方法

シェアする

OracleDBインスタンスを起動する時と停止する時は、SQL*Plusを使って行なうと良いでしょう。

OracleDBインスタンスの起動

リスナーの起動

SQL*Plusを使うためには、リスナーが起動している必要があります。

$ lsnrctl status <= リスナーの状態を見る

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-MAR-2018 01:42:52

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraserv)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 2: No such file or directory
$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-MAR-2018 01:43:08

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Starting /oraapp1/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /oraapp1/product/12.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /oraapp1/diag/tnslsnr/oraserv/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraserv.prd.orangetakam.local)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraserv)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 16-MAR-2018 01:43:08
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oraapp1/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /oraapp1/diag/tnslsnr/oraserv/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraserv.prd.orangetakam.local)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services <= まだインスタンスが起動していないため
The command completed successfully

OracleDBインスタンス起動

リスナーの起動は出来ましたので、SQL*Plusを使ってインスタンスを起動します。

$ sqlplus sys as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 16 01:33:25 2018

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

Enter password:xxxx
Connected to an idle instance. <= インスタンスは起動していない

SQL> startup open <= オープンモードで起動する
ORACLE instance started.

Total System Global Area 771751936 bytes
Fixed Size 8797536 bytes
Variable Size 570426016 bytes
Database Buffers 188743680 bytes
Redo Buffers 3784704 bytes
Database mounted. <= DBがマウントした
Database opened. <= DBがオープンした
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-MAR-2018 01:48:36

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraserv)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 16-MAR-2018 01:43:08
Uptime 0 days 0 hr. 5 min. 28 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oraapp1/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /oraapp1/diag/tnslsnr/oraserv/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraserv.prd.orangetakam.local)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=oraserv.prd.orangetakam.local)(PORT=5500))(Security=(my_wallet_directory=/oraapp1/admin/cdb1/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "676e24af1db77934e0536501a8c0deef" has 1 instance(s).
 Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1" has 1 instance(s).
 Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1XDB" has 1 instance(s).
 Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
 Instance "cdb1", status READY, has 1 handler(s) for this service...
The command completed successfully

OracleDBインスタンスの停止

インスタンスの停止です。

OracleDBインスタンス停止

SQL*Plusを使ってインスタンスの停止をします。

$ sqlplus sys as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 16 01:49:46 2018

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

Enter password:xxxx

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> shutdown immediate
Database closed. <= DBがクローズした
Database dismounted. <= DBがディスマウントした
ORACLE instance shut down. <= インスタンスが停止した
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-MAR-2018 01:53:04

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraserv)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 16-MAR-2018 01:43:08
Uptime 0 days 0 hr. 9 min. 56 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oraapp1/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /oraapp1/diag/tnslsnr/oraserv/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraserv.prd.orangetakam.local)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

リスナーの停止

一応、リスナーも停止させます。

$ lsnrctl stop

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-MAR-2018 01:53:20

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraserv)(PORT=1521)))
The command completed successfully
$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-MAR-2018 01:53:30

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraserv)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 2: No such file or directory