Ad Widget

Collapse

Zabbix can not resolve TNS identifier

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ITguru
    Junior Member
    • Jan 2017
    • 10

    #1

    Zabbix can not resolve TNS identifier

    Hi guys

    I need your help. I am trying to monitor an Oracle database.
    My Zabbix (3.0.7) is running on Ubuntu 14.04.

    Thats what I already did:
    - I installed "unixODBC" and the "Oracle Instant Client" on my server.
    - I configured /etc/odbc.ini (Driver is defined in this file therefore I have odbcinst.ini)
    - I created tnsnames.ora and sqlnet.ora

    With this configuration I can succesfully isql to my database.

    But when I create a trigger in zabbix the following error message appears:
    Cannot connect to ODBC DSN:[SQL_ERROR]:[08004][12154][[unixODBC][Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified
    ]|

    I did a lot of research and tried every suggestion I found on zabbix forum or elsewhere. I read that in most cases SELinux causes this behaviour, but on my Ubuntu there ist no SELinux.

    Can anyone help me out? Any suggestion is welcome.

    Thanks alot
  • ITguru
    Junior Member
    • Jan 2017
    • 10

    #2
    no hints on that topic?
    I hope you can help me.

    Comment

    • GPegel
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2015
      • 113

      #3
      I have a working config in 3 different environments. What is important is that you use the same name in your item key as you use in your odbc.ini file.

      For example, a part of my odbc.ini looks like this:

      Code:
      [TEST_DATABASE]
      Driver=OracleODBC-12.1
      ServerName=//servername:port/instance_name
      UserID=zabbix
      Password=zabbix
      Now my item key in Zabbix looks like this:

      Code:
      db.odbc.select[whatever_name,TEST_DATABASE]

      Comment

      • ITguru
        Junior Member
        • Jan 2017
        • 10

        #4
        Hi

        thanks for your reply.
        I use the same name my item key as defined in my odbc.ini

        This is my odbc.ini:
        Code:
        [DB_Prod]
        Driver= /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
        ServerName= test.server.com
        Port= 1521
        UserID= user
        Password= pass
        And this is my item:
        Code:
        db.odbc.select[gms-app-alarm,DB_Prod]
        Did you set any additional environment variables for zabbix?
        I only set the system env vars (ORACLE_HOME, LD_LIBRARY_PATH..)

        Comment

        • GPegel
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2015
          • 113

          #5
          I have set these 3 environment variables:

          Code:
          LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib:/usr/lib64:
          TNS_ADMIN=/usr/lib/oracle/12.1/client64/network/admin
          ORACLE_HOME=/usr/lib/oracle/12.1/client64
          I've also create a file in /etc/sysconfig/zabbix-server with these lines:

          Code:
          ORACLE_HOME=/usr/lib/oracle/12.1/client64
          LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib:/usr/lib64
          TNS_ADMIN=/usr/lib/oracle/12.1/client64/network/admin
          PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/oracle/12.1/client64/lib
           
          export ORACLE_HOME
          export LD_LIBRARY_PATH
          export TNS_ADMIN
          export PATH
          After creating the file, restart Zabbix Server.

          ps. I'm running my Zabbix Server on CentOS 7, not on Ubuntu.
          Last edited by GPegel; 10-01-2017, 14:16. Reason: added extra info

          Comment

          • ITguru
            Junior Member
            • Jan 2017
            • 10

            #6
            I think this might be the problem
            I added the variables in my
            Code:
            /etc/default/zabbix-server
            file, too. But after restart of zabbix the variables are still not set.

            Code:
            anf@SBSRVZABBIX01:/$ sudo strings /proc/28496/environ
            PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
            TERM=linux
            UPSTART_JOB=zabbix-server
            UPSTART_INSTANCE=
            I have no idea, why zabbix does not set the vars

            Comment

            • GPegel
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Dec 2015
              • 113

              #7
              Okay, weird.

              By the way, I'm looking at your odbc.ini file and I'm wondering where your instance name is.

              I'm not an Oracle DBA expert but I guess you have to add an instance name to connect to the right database. Correct me if I'm wrong.

              Comment

              • ITguru
                Junior Member
                • Jan 2017
                • 10

                #8
                I set the instance in my tnsnames.ora:

                Code:
                test.server.com =
                  (DESCRIPTION=
                    (ADDRESS=(PROTOCOL=TCP)(HOST=db.server.lan)(PORT=1521))
                    (CONNECT_DATA=(SERVICE_NAME=proddb.server.com))
                    (ENABLE=BROKEN)
                  )

                Comment

                • GPegel
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Dec 2015
                  • 113

                  #9
                  Yes me too but I also set it in odbc.ini

                  Comment

                  • ITguru
                    Junior Member
                    • Jan 2017
                    • 10

                    #10
                    thats strange. When I add it at odbci ini i can not connect with isql anymore

                    Comment

                    • GPegel
                      Senior Member
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Dec 2015
                      • 113

                      #11
                      Are you really 100 percent sure your instance name is correctly spelled? Maybe a typo?

                      Or is your DNS on your server correct? Maybe you could try to change the servername to IP address in your odbc.ini file.

                      Maybe an idea to write your odbc.ini exactly the same as I did and particular the "ServerName=//..."

                      Comment

                      • ITguru
                        Junior Member
                        • Jan 2017
                        • 10

                        #12
                        Can you post your tnsnames.ora for me to verify?

                        Thanks a lot

                        Comment

                        • SirMax
                          Junior Member
                          • Jul 2012
                          • 14

                          #13
                          My /etc/default/zabbix stopped working.
                          you can see errors in journalctl

                          best way on new systems is to use systemd units
                          change file
                          /lib/systemd/system/zabbix-[proxy/server].service

                          add in [service] lines
                          Environment="ORACLE_HOME=/usr/lib/oracle/12.1/client64"
                          Environment="LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64"
                          Environment="TNS_ADMIN=$ORACLE_HOME/network/admin"
                          Environment="TNS_ADMIN=/usr/lib/oracle/12.1/client64/network/admin"

                          Comment

                          • soumyacharya
                            Junior Member
                            • Apr 2019
                            • 1

                            #14
                            I am afacing the same issue. i am able to connect to oracle database using isql but in zabbix front end it is replying tns: could not receive the correct identifier provided. I have disabled selinux policy and also updated the env variables in /etc/sysconfig/zabbix-server

                            Comment

                            Working...