状況
リスナーは動的設定とする。
以下、調査結果。
1:DBインスタンスも起動されていない状態でリスナーを起動したらどうなるか
結果
[oracle@localhost]$ lsnrctl services LISTENER_1 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 03-DEC-2014 01:51:13 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1524))) The listener supports no services The command completed successfully
DBインスタンスを起動していなくてもリスナーは起動できる。
ただ、サービス名は登録されない模様(って当たり前か)
2:インスタンスを起動したらどうか
#インスタンスの起動 [oracle@localhost ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 3 02:00:20 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. idle> connect / as sysdba Connected to an idle instance. idle> startup nomount ORACLE instance started. Total System Global Area 1085640704 bytes Fixed Size 2212536 bytes Variable Size 838864200 bytes Database Buffers 234881024 bytes Redo Buffers 9682944 bytes
さて、結果は
[oracle@localhost]$ lsnrctl services LISTENER_1 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 03-DEC-2014 02:01:24 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1524))) Services Summary... Service "SALES" has 1 instance(s). Instance "sales", status BLOCKED, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER The command completed successfully
お、サービス名が登録されている。インスタンスの起動により、
初期かパラメータに書かれてあるサービス名が動的に登録されているのが見て取れる。
status : BLOCKED
これは接続不可能であることを示している。
DBインスタンスを起動した時点ではまだリスナーを通して接続はできないみたい
(まあローカルからの接続でさえDBがオープンしないと一般ユーザでは接続できないので当然といえば当然なのかも。。。)
3:DBをマウントしたらどうか
#マウントする SQL> alter database mount; Database altered.
さて結果は。。。
[oracle@localhost]$ lsnrctl services LISTENER_1 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 03-DEC-2014 02:11:02 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1524))) Services Summary... Service "SALES" has 1 instance(s). Instance "sales", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER
おお、READYになった。ということはリスナー経由で接続可能なのか?
[oracle@localhost]$ sqlplus system@sales SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 3 02:15:24 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter password: ERROR: ORA-01033: ORACLE initialization or shutdown in progress Process ID: 0 Session ID: 0 Serial number: 0
やはりDBがオープンしていないから失敗した。となるとマウントした状態でREADYになっても嬉しくないような。。。
4:DBをオープンしたらどうか
ってこれは大丈夫だと思うが確認の意味を込めて。
SQL> alter database open; Database altered.
リスナーの状態はというと
[oracle@localhost]$ lsnrctl services LISTENER_1 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 03-DEC-2014 02:19:43 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1524))) Services Summary... Service "SALES" has 1 instance(s). Instance "sales", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:1 refused:0 state:ready LOCAL SERVER
お。さっきと比べるとestablishedが0から1になっている。
リスナー経由で無事に接続できた。
[oracle@localhost]$ sqlplus system@sales SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 3 02:22:27 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
establishedにはリスナーが接続を確立した累計が表示されているらしい。
なるほど。これは例えば複数サービス名登録しておくとサービス名ごとの累計接続数を確認できるということか。
とまあこんなところで。
結論は、
DBがオープンしてないとリスナー経由でのDB接続はできないという
至極当たり前な挙動でした。