[ZBX-17437] Cannot connect to ODBC DSN: [SQL_ERROR]:[08004][12154][[unixODBC][Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified Created: 2020 Mar 11  Updated: 2024 Jun 21  Resolved: 2020 Mar 13

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 4.0.17
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: lijian Assignee: Zabbix Support Team
Resolution: Won't fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos 7.5
Oracle Client 11g
unixodbc 2.3.1


Attachments: PNG File image-2020-03-11-12-34-57-414.png     PNG File image-2020-03-11-12-51-14-489.png    

 Description   

i already installed unixodbc, oracleclient successfully.

i can use isql and oracle client to query database.(both root & zabbix user)

then i go to zabbix web to fix an item for oracledb.

and item throwed a problem like this:

 

i searched some result for this problem , and i solved it , use:
**

echo "/usr/lib/oracle/11.2/client64/lib" > /etc/ld.so.conf.d/oracle-client-11.2.conf
sudo ldconfig
# check if path is listed
sudo ldconfig -v

but after, item came out this problem:

Cannot connect to ODBC DSN: [SQL_ERROR]:[08004][12154][[unixODBC][Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified

 

my zabbix installed by src source(make & makeinstall)

this is my installed url :

/opt/zabbix/zabbix

[root@localhost zabbix]# ls
bin  etc  lib  sbin  scripts  share
[root@localhost zabbix]# 

because i did't find the file: /etc/sysconfig/zabbix-server

*so i created this file and writed this in file:*

-rwxr-xr-x    1 root root   146 3月  11 11:43 zabbix-server
drwxr-xr-x.   6 root root  4096 3月  11 11:43 .
[root@localhost sysconfig]# more zabbix-server
ORACLE_HOME=/usr/lib/oracle/11.2/client64
LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/admin
[root@localhost sysconfig]# 

*but it still did't work, and i writed this into this file:*

cd /etc/rc.d/init.d/
vi zabbix_server

# Source function library.
. /etc/init.d/functions# Variables
# Edit these to match your system settings        # Zabbix-Directory
        BASEDIR=/opt/zabbix/zabbix        # Binary File
        BINARY_NAME=zabbix_server        # Full Binary File Call
        FULLPATH=$BASEDIR/sbin/$BINARY_NAME        # PID file
        PIDFILE=/tmp/$BINARY_NAME.pid        # Establish args
        ERROR=0
        STOPPING=0

#### here i writed ####
ORACLE_HOME=/usr/lib/oracle/11.2/client64
LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/admin
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin

...

wq!

and i use this to see zabbix pid, it still can't find oracle env:

 

so , can u tell me how to add oracle env for zabbix?  thank u!!!!

 

 



 Comments   
Comment by lijian [ 2020 Mar 11 ]

and my zabbix version is 4.0.15

Comment by lijian [ 2020 Mar 13 ]

is anybody here??  plz reply ,  thx!!!

Comment by lijian [ 2020 Mar 13 ]

finally i solved this problem

vi /etc/init.d/zabbix_server

export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
export TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/admin
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin

then zabbix find the oracle env

[root@localhost tmp]# ls -lart|grep *.pid
-rw-rw-r--   1 zabbix zabbix         5 3月  13 11:20 zabbix_server.pid
[root@localhost tmp]# more *.pid
61235
[root@localhost tmp]# strings -a /proc/61235/environ
LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/admin
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/oracle/11.2/client64/bin:/bin
PWD=/
LANG=zh_CN.UTF-8
SHLVL=1
ORACLE_HOME=/usr/lib/oracle/11.2/client64
_=/opt/zabbix/zabbix/sbin/zabbix_server
Comment by mingking [ 2024 Jun 21 ]

I added systemctl services on the system, there is no service according to the service to configure.

vi /usr/lib/systemd/system/zabbix_server.service
[Unit]
Description=zabbix_server - monitor server
After=network.target remote-fs.target nss-lookup.target syslog.target

[Service]
Environment=CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf
Environment=ORACLE_HOME=/usr/lib/oracle/11.2/client64
Environment=TNS_ADMIN=$ORACLE_HOME/network/admin
Environment=LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH
Environment=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/lib:$HOME/bin
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/log/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0

[Install]
WantedBy=multi-user.target

After configuring the zabbix-server startup environment, the problem persists.

so I tried a number of methods, re-installed oracle driver version 21.3.0.0.0, you can connect to the database through ODBC normal. The web page did not report this error. It may be that the zabbix 6.0 release does not support Oracle 11.2 very well.

wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-basic-21.3.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-devel-21.3.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-odbc-21.3.0.0.0-1.x86_64.rpm

yum localinstall oracle-instantclient-*

Generated at Fri Jul 18 08:13:42 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.