2

不可解な問題があります。Linux に Oracle 11g をセットアップしましたが、正常に動作していました。次のようなSIDベースの接続文字列を使用して、他のマシンからリモートで接続できました

sqlplus myschema@192.168.184.102:1521:orcl

その後、不可解な理由で機能しなくなりました。私や他の誰かが何を揺らしたのかわかりません。

現在、SERVICE_NAME または TNSNAME ベースの方法を使用してのみリモートで接続できます

sqlplus myschema@192.168.184.102:1521/orcl

sqlplus myschema@ORCL

どちらも機能し、これは問題ありませんが、変更可能な SID 接続パターンに依存するアプリケーションがあります。心優しい魂が、私が欠けているものを理解するのを助けてくれますか?

以下は私の構成です:

リスナー.ORA:

[oracle@dbora112 ~]$ cat  /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = dbora112)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /opt/u01/app/oracle

リスナーのステータス:

[oracle@dbora112 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-MAR-2015 14:50:05

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                04-MAR-2015 14:37:12
Uptime                    0 days 0 hr. 12 min. 52 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/u01/app/oracle/diag/tnslsnr/dbora112/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbora112)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

TNSNAMES.ORA:

[oracle@dbora112 ~]$ cat /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.184.102)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID = orcl)
    )
  )

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.184.102)(PORT = 1521))

SQLNET:

[oracle@dbora112 ~]$ cat /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
# sqlnet.ora Network Configuration File: /opt/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

ADR_BASE = /opt/u01/app/oracle

TNSを使用して問題なく接続できます

[oracle@dbora112 ~]$ sqlplus schema/xxx@ORCL

SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 4 14:54:10 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

サービス名を使用して問題なく接続できます

[oracle@dbora112 ~]$ sqlplus schema/xxx@192.168.184.102/ORCL

SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 4 14:55:52 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

SIDに接続できません

[oracle@dbora112 ~]$ sqlplus schema/xxx@192.168.184.102:orcl

SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 4 14:56:38 2015

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

ERROR:
ORA-12545: Connect failed because target host or object does not exist

データベース インスタンス (SID)

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
orcl
4

2 に答える 2

1

TNS エイリアスで接続でき、接続の説明で SID を使用しているため、SID は機能しています。

しかし、EasyConnect 文字列が正しくありません。SQL*Plus のドキュメントから:

簡単または省略された接続識別子の構文は次のとおりです。

[//]host[:port][/service_name]

Easy Connect で SID を使用することはできません。サービス名のみを使用してください。したがって、次を使用して接続します:

sqlplus schema/xxx@192.168.184.102:orcl

あるいは

sqlplus schema/xxx@192.168.184.102:1521:orcl

... 働いたことはありません。古いスタイルを使用して、JDBC URL でそのフォームを使用できます。

jdbc:oracle:thin:@192.168.184.102:1521:orcl

...しかし、見た目は似ていますが、これは SQL*Plus 接続と同じではありません。

その形式の JDBC 接続が機能するかどうかを確認しようとしている場合、SQL*Plus ではできませんが、TNS エイリアス チェックは、同じホストを使用している限り、期待どおりに設定されていることを確認しています。 、ポートおよび SID。おそらく新しい JDBC 構文を使用する方がよいでしょうが、質問からすると、それを変更することはできないようです。

簡単接続の詳細をお読みください

于 2015-03-04T16:34:03.613 に答える