yoshiislandblog.net
元営業の駆け出しアラサーSEが、休日にMACと戯れた際の殴り書きメモ。日々勉強。日々進歩。

この記事は3年以上前に書かれた記事で内容が古い可能性があります

「あれ、DB落ちてんじゃん」という時にやること(データベースの起動とリスナーの起動)

2020-10-09

「あれ、DB落ちてんじゃん」という時にやること

目次

  • データベースの起動
  • リスナーの起動

    データベースの起動

    「conn sys as sysdba」でログインしてから「STARTUP」
    (停止は「SHUTDOWN」)

    
    $ sqlplus /nolog
    
    SQL*Plus: Release 12.2.0.1.0 Production on Thu Oct 8 16:26:04 2020
    
    Copyright (c) 1982, 2016, Oracle.  All rights reserved.
    
    SQL>
    SQL> conn sys as sysdba
    Enter password:
    Connected to an idle instance.
    SQL>
    SQL> STARTUP
    ORACLE instance started.
    
    Total System Global Area 2516582400 bytes
    Fixed Size		    8623832 bytes
    Variable Size		  671090984 bytes
    Database Buffers	 1828716544 bytes
    Redo Buffers		    8151040 bytes
    Database mounted.
    Database opened.
    SQL>
    SQL>
    
    

    リスナーの起動

    リスナーの死活は「tnsping」で確認できる
    死んでいれば「TNS-12541: TNS:no listener」が返ってくる

    $ tnsping localhost
    
    TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 08-OCT-2020 16:34:56
    
    Copyright (c) 1997, 2016, Oracle.  All rights reserved.
    
    Used parameter files:
    
    Used HOSTNAME adapter to resolve the alias
    Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
    TNS-12541: TNS:no listener
    $
    

    リスナー起動には、「lsnrctl」で「start」
    (停止は「stop」)

    $ lsnrctl
    
    LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 08-OCT-2020 16:35:24
    
    Copyright (c) 1991, 2016, Oracle.  All rights reserved.
    
    Welcome to LSNRCTL, type "help" for information.
    
    LSNRCTL> start
    Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...
    
    TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
    Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    Start Date                08-OCT-2020 16:35:32
    Uptime                    0 days 0 hr. 0 min. 0 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    The listener supports no services
    The command completed successfully
    LSNRCTL>
    LSNRCTL> exit
    
    

    起動すると「tnsping」で「OK」が返ってくる

    $ tnsping localhost
    
    TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 08-OCT-2020 16:35:53
    
    Copyright (c) 1997, 2016, Oracle.  All rights reserved.
    
    Used parameter files:
    
    Used HOSTNAME adapter to resolve the alias
    Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
    OK (0 msec)
    $
    

    以上。