Oracle Connection via ODBC

Hello Everyone I have installed Oracle instantclient 12.1 basic and oracle instantclient odbc 12.1 on my CentOS

then I configured odbc.ini, odbcinst.ini, env variables and tnsnames.ora file which is :

VPLS =
  (DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS =
          (COMMUNITY = tcp.world)
          (PROTOCOL = TCP)
          (Host = 192.168.0.103)
          (Port = 1521)
        )
    )
    (CONNECT_DATA = (SID = ORA92)
    )
  )

and I also can connect from isql

but my asterisk can’t log cdr there and when I reload res_odbc.so :

[oracle_cdr]
        enabled => yes
        dsn => oracle_cdr
        share_connections => no
        limit => 5
        username => billing
        password => b
        pre-connect => yes

asterisk is run by root account

odbc.ini :

[oracle_cdr]
Description = myoracledb database
Driver = ORA92
DSN = oracle_cdr
ServerName = TEST
Trace = yes
TraceFile = /tmp/odbc_oracle.log
Database = 192.168.0.103:1521/pss55$
UserID = billing
Password = fff
Port = 1521

odbcinst.ini :

[ORA92]
Description     = Oracle ODBC driver for Oracle 12c
Driver          = /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
FileUsage       = 1
Driver Logging  = 7

and ENV vars are :

export LD_LIBRARY_PATH=:/usr/lib/oracle/12.1/client64/lib

export ORACLE_HOME=/usr/lib/oracle/12.1/client64

export TWO_TASK=192.168.0.103:1521/pss55$

export TNS_ADMIN=/etc/oracle

Can anyone help me ? :))

thanks

Have you tried using isql outside asterisk to connect to your database?

isql -v oracle_cdr billing b

yes its working that way
when I run asterisk from service asterisk start it can’t connect to db
but when I run it by safe_asterisk it can’t connect to oracle and puts there cdrs

both is run by root :
root 6062 0.0 0.0 106112 680 ? S Jun21 0:00 /bin/sh /usr/sbin/safe_asterisk
root 6064 0.2 1.2 2789520 50120 ? Sl Jun21 1:53 /usr/sbin/asterisk -f -vvvg -c

Can you provide us with the error you are getting when asterisk tries to connect to your database?

It should show up in the full log if you have it enabled.

[Jun 22 22:40:54] NOTICE[10637]: res_odbc.c:792 load_odbc_config: Adding ENV var: ORACLE_HOME=/usr/lib/oracle/12.1/client64
[Jun 22 22:40:54] NOTICE[10637]: res_odbc.c:792 load_odbc_config: Adding ENV var: LD_LIBRARY_PATH=:$ORACLE_HOME/lib
[Jun 22 22:40:54] NOTICE[10637]: res_odbc.c:792 load_odbc_config: Adding ENV var: TWO_TASK=192.168.0.103:1521/pss55$
[Jun 22 22:40:54] NOTICE[10637]: res_odbc.c:1527 odbc_obj_connect: Connecting oracle_cdr
[Jun 22 22:40:54] WARNING[10637]: res_odbc.c:1552 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=12154 [unixODBC][Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified

[Jun 22 22:40:54] WARNING[10637]: res_odbc.c:1267 _ast_odbc_request_obj2: Failed to connect to oracle_cdr
[Jun 22 22:40:54] NOTICE[10637]: res_odbc.c:919 load_odbc_config: Registered ODBC class 'oracle_cdr' dsn->[oracle_cdr]

I’m not an oracle guy but googling that error leads me to pages talking about your tnsnames.ora file not being correct.

I’d suggest revisiting it and maybe doing some searches of your own.

if it isn’t correct how safe_asterisk can connect to db ?

Your earlier post said neither safe_asterisk or starting asterisk via service asterisk start (which I believe runs safe_asterisk) are able to connect.