DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: ORA-12154: TNS:could not resolve service name

  1. #1
    Join Date
    Jul 2003
    Posts
    3

    Question ORA-12154: TNS:could not resolve service name

    Hi all, I am your typical newbie to all of this so please be gentle. I have done a google search on this and have tried all the solutions I could find with no luck. I just installed oracle 9i on RedHat Linux 9. I thought I had everything set up correctly but at the prompt when I type "sqlplus scott/tiger" I get this error message:

    ERROR:
    ORA-12154: TNS:could not resolve service name

    My tnsnames.ora and sqlnet.ora are both in $ORACLE_HOME/network/admin

    Here is my tnsnames.ora file:

    O9IDB.LOCALDOMAIN =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = O9IDB.testingthisdb.com)
    )
    )

    INST1_HTTP.LOCALDOMAIN =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = SHARED)
    (SERVICE_NAME = MODOSE)
    (PRESENTATION = http://HRService)
    )
    )

    EXTPROC_CONNECTION_DATA.LOCALDOMAIN =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    )
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    )
    )


    And here is my sqlnet.ora file:

    NAMES.DEFAULT_DOMAIN = localdomain

    NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)

    I'm not doing any remote connection to it or have it connected to any domain. Its all on my local computer. My GID is O9IDB.testingthisdb.com and my SID is O9IDB

    Any help from you gurus will be greatly appreciated.

  2. #2
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Have you set the

    Code:
      export ORACLE_SID=O9IDB
    in your environment. Then make sure that your listeners are up and functioning using

    Code:
     lsnrctl status
      
     if down then:
      
        lsnrctl start
    for connecting as follows
    Code:
      sqlplus scott/tiger@O9IDB.LOCALDOMAIN
    Hope this is the problem

    -Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  3. #3
    Join Date
    Jul 2003
    Posts
    3
    Thanks Sam. I thought I had set the SID in my environment but I was wrong. I did that and now I can connect and I get a SQL prompt. When I type that lsnrctl status or lsnrctl start, I get this:

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
    TNS-12541: TNS:no listener
    TNS-12560: TNS: protocol adapter error
    TNS-00511: No listener
    Linux Error: 2: No such file or directory
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
    TNS-12545: Connect failed because target host or object does not exist
    TNS-12560: TNS: protocol adapter error
    TNS-00515: Connect failed because target host or object does not exist

    This is what I have in my listener.ora file:
    # LISTENER.ORA Network Configuration File: /u01/app/oracle/product/9.2.0.1.0/network/admin/listener.ora
    # Generated by Oracle configuration tools.

    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    )
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
    )
    )

    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = /u01/app/oracle/product/9.2.0.1.0)
    (PROGRAM = extproc)
    )
    (SID_DESC =
    (GLOBAL_DBNAME = O9IDB.testingthisdb.com)
    (ORACLE_HOME = /u01/app/oracle/product/9.2.0.1.0)
    (SID_NAME = O9IDB)
    )
    )



    And this is what my bash_profile is set to:

    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
    # User specific environment and startup programs
    export JAVA_HOME=/usr/local/java
    export BASH_ENV=$HOME/.bashrc
    # !!! Set the following environment variable only for Red Hat 9 !!!
    export LD_ASSUME_KERNEL=2.4.1
    # Oracle Environment
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=/u01/app/oracle/product/9.2.0.1.0
    export ORACLE_SID=O9IDB
    export ORACLE_TERM=xterm
    export NLS_LANG=AMERICAN;
    export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/network/lib
    export LD_LIBRARY_PATH
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export CLASSPATH=$CLASSPATH:$ORACLE_HOME/jdbc/lib/classes12.zip:$ORACLE_HOME/jdbc/lib/nls_charset12.zip
    # Set shell search paths
    export PATH=$PATH:$ORACLE_HOME/bin:/usr/local/jre1.3.1_08/bin:/usr/local/bin:$HOME/bin
    unset USERNAME


    I tried tnsping and get TNS-12545: Connect failed because target host or object does not exist. Do you have any idea what it might be. I read somewhere that sqlnet.ora should not be in the same directory as listener.ora and tnsnames.ora. I find it very hard to believe but is that true.

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Can you ping localhost.localdomain ?

  5. #5
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    Hi,

    Try giving the IP ADDRESS instead of the hostname

    Srini

  6. #6
    Join Date
    Jan 2002
    Location
    Netherlands
    Posts
    1,587
    try putting in ip address of your host in the tnsnames.ora files and listener...

    It apparently can't find the host, so make sure that the server is
    --up
    -- ping'able
    --tnsping..Since here you get the error...
    -- no SA activity took place like rename the machine,etc...
    -- use net8/servives utility to test the connection, comparing the *.ora files isn't really that advisable.
    Tarry Singh
    I'm a JOLE(JavaOracleLinuxEnthusiast)
    TarryBlogging
    --- Everything was meant to be---

  7. #7
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Looks like your OS is linux. If my assumption is correct, check under $ORACLE_HOME/bin whether you have the files "tnslsnr" and "tnslsnr0". If tnslsnr doesn't exist, then create a symlink to tnslsnr0. If this was not the case, then try creating the listener using the "netca" utility and that will help.

    -Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  8. #8
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Folks,

    We are missing on one thing to answer to all your questions. He couldn't start the listener. So as a result, you cannot do a tnsping.
    The best route to these is
    0. Make sure that tnslsnr file exist in your $ORACLE_HOME/bin
    1. configure the listener.ora and tnsnames.ora file using the Network Configuration Assistant (netca).
    2. Then try restarting the listener.
    3. Then make sure that the network is up, by pinging.
    4. Then try the tnsping
    5. Then try connecting.

    -Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  9. #9
    Join Date
    Jul 2003
    Posts
    3
    You are right Sam, I am running RedHat 9. "tnslsnr" and "tnslsnr0" both do exist in the $ORACLE_HOME/bin directory. ping localhost works. ping 127.0.0.1 works.

    I just got her breathing. In the listener.ora file, I changed the host from HOST = localhost.localdomain to HOST = 127.0.0.1 and now the listener starts!

    All your input helped me start looking in the right areas. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width