2 Replies Latest reply: Jul 26, 2010 7:30 AM by 694362 RSS

    tns confusion

    694362
      hello,

      i have 11.2 installed i can log into my database
      when i run lsnrctl status it tells me my database is running and it can see it
      if i try and connect from an external ip i cant

      if i run tnsping for my ip i get TNS-03505: Failed to resolve name
      but if i do it as localhost ip i get success

      if i run nestat -a |grep 1521 i get

      unix 2 [ ACC ] STREAM LISTENING 4280 /var/tmp/.oracle/sEXTPROC1521


      i appreciate this proably is more of a network problem than an oracel problem but
      a) have i got the right things listenning?
      b) where does oracle get the ip from?
      c) why would my public ip and my localhost address not resolve to the same thing

      thanks
      ALex
        • 1. Re: tns confusion
          EdStevens
          set321go wrote:
          hello,

          i have 11.2 installed i can log into my database
          when i run lsnrctl status it tells me my database is running and it can see it
          if i try and connect from an external ip i cant

          if i run tnsping for my ip i get TNS-03505: Failed to resolve name
          but if i do it as localhost ip i get success

          if i run nestat -a |grep 1521 i get

          unix 2 [ ACC ] STREAM LISTENING 4280 /var/tmp/.oracle/sEXTPROC1521


          i appreciate this proably is more of a network problem than an oracel problem but
          a) have i got the right things listenning?
          b) where does oracle get the ip from?
          c) why would my public ip and my localhost address not resolve to the same thing

          thanks
          ALex
          A couple of important points.

          First, the listener is a server side only process. It's entire purpose in life is to receive requests for connections to databases and set up those connections. Once the connection is established, the listener is out of the picture. It creates the connection. It doesn't sustain the connection. One listener, with the default name of LISTENER, running from one oracle home, listening on a single port, will serve multiple database instances of multiple versions running from multiple homes. It is an unnecessary complexity to try to have multiple listeners or to name the listener as if it belongs to a particular database. That would be like the telephone company building a separate switchboard for each customer.

          Second, the tnsnames.ora file is a client side issue. It's purpose is for address resolution - the tns equivalent of the 'hosts' file further down the network stack. The only reason it exists on a host machine is because that machine can also run client processes.

          Assume you have the following in your tnsnames.ora:
          larry =
            (DESCRIPTION =
              (ADDRESS_LIST =
                (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
              )
              (CONNECT_DATA =
                (SERVICE_NAME = curley)
              )
            )
          Now, when you issue a connect, say like this:
          $> sqlplus scott/tiger@larry
          tns will look in your tnsnames.ora for an entry called 'larry'. Next, tns sends a request to (PORT = 1521) on (HOST = myhost) using (PROTOCOL = TCP), asking for a connection to (SERVICE_NAME = curley).

          Where is (HOST = myhost) on the network? When the request gets passed from tns to the next layer in the network stack, the name 'myhost' will get resolved to an IP address, either via a local 'hosts' file, via DNS, or possibly other less used mechanisms. You can also hard-code the ip address (HOST = 123.456.789.101) in the tnsnames.ora.

          Next, the request arrives at port 1521 on myhost. Hopefully, there is a listener on myhost configured to listen on port 1521, and that listener knows about SERVICE_NAME = curley. If so, you'll be connected.



          What can go wrong?

          First, there may not be an entry for 'larry' in your tnsnames. In that case you get "ORA-12154: TNS:could not resolve the connect identifier specified" No need to go looking for a problem on the host, with the listener, etc. If you can't place a telephone call because you don't know the number (can't find your telephone directory (tnsnames.ora) or can't find the party you are looking for listed in it (no entry for larry)) you don't look for problems at the telephone switchboard.

          Maybe the entry for larry was found, but myhost couldn't be resolved to an IP address (say there was no entry for myhost in the local hosts file). This will result in "ORA-12545: Connect failed because target host or object does not exist"

          Maybe there was an entry for myserver in the local hosts file, but it specified a bad IP address. This will result in "ORA-12545: Connect failed because target host or object does not exist"

          Maybe the IP was good, but there is no listener running: "ORA-12541: TNS:no listener"

          Maybe the IP was good, there is a listener at myhost, but it is listening on a different port. "ORA-12560: TNS:protocol adapter error"

          Maybe the IP was good, there is a listener at myhost, it is listening on the specified port, but doesn't know about SERVICE_NAME = curley. "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor"


          =====================================
          • 2. Re: tns confusion
            694362
            Thanks that was very informative sort of info that takes an age of trawling through official documents to summerise :)

            As i suspected oracle was behaving itself and it had the wrong information because i hadnt set up the right information. My /etc/sysconfig/network file was configured to localhost and there was no entry in my /etc/hosts file for my IP address and my hostname was set to localhost. Oracle was just using what i had failed to properly configure.

            thanks for the information, helpful in the understanding of the behemoth that is oracle :D

            Alex