问题
I have Oracle running on one machine of the LAN.
I can connect to the DB with sqlplus when I issue:
sqlplus myuser/mypass@localhost:1521/orcl
This works fine.
On another machine from the LAN, I have installed oracle instant client (basic + sdk + sqlplus).
sqlplus myuser/mypass@oracle_server:1521/orcl
SQL*Plus: Release 11.2.0.3.0 Production on Sat Feb 25 09:10:41 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-12543: TNS:destination host unreachable
Enter user-name:
Oracle server is up and running and is reachable on the network but I cannot connect to the database.
回答1:
localhost
is a specific local address, 127.0.0.1
, which is only reachable from the same machine; another machine cannot connect directly to a service registered only against localhost
. oracle_server
will be resolve to (or be if you aren't using a host name) the IP address of an ethernet interface on the machine; on a LAN this is likely to start with 10.
or 192.168.
but could be something else.
Check your Oracle listener configuration is listening on the external address as well as localhost
.
Having said that, if that was the only problem you'd probably see ORA-12541: TNS:no listener
rather than ORA-12543
. This sounds like there may be a firewall running on the Oracle server machine, and if so you need to configure that to permit traffic on port 1521.
Another possibility is that you're using a host name in your connect string and you just can't resolve that to an IP address. Check you can ping oracle_server
; if that says something like cannot resolve oracle_server
then check the name, see if you need to give a fully-qualified name (oracle_server.example.com
), or at a push add it to your local hosts
file. Or, use the raw IP address in the connect string instead of the host name.
来源:https://stackoverflow.com/questions/9442415/cannot-access-oracle-using-sqlplus-from-another-machine-on-the-lan