oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
264 stars 75 forks source link

Cannot load library libclntsh.so on docker container #151

Closed sagnol closed 3 years ago

sagnol commented 3 years ago
  1. What version of ODPI-C are you using (see dpi.h)? ODPI-C 4.1.0 and github.com/godror/godror v0.22.0

  2. What OS (and version) is your application on? Docker(Mac, CentOS7)

  3. What compiler (and version) did you use? golang 15.5 (CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s' -o main ./cmd/runner/main.go)

  4. What is your version of the Oracle Client (e.g. Instant Client)? How was it installed? Where it is installed? 19.3 see below

    
    FROM alpine:latest
    ENV LD_LIBRARY_PATH=/lib
    RUN wget https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \
    unzip instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \
    cp -r instantclient_19_3/* /lib && \
    rm -rf instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \
    apk add --no-cache libaio libnsl libc6-compat
5. What is your Oracle Database version? 19.0.0.0.ru-2020-10.rur-2020-10.r1

6. What is the `PATH` environment variable (on Windows) or `LD_LIBRARY_PATH` (on Linux) set to? 
LD_LIBRARY_PATH=/lib
DPI_DEBUG_LEVEL=92

7. What environment variables did you set?  How *exactly* did you set them? `ENV LD_LIBRARY_PATH=/lib` and

FROM alpine:latest

ENV LD_LIBRARY_PATH=/lib RUN wget https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \ unzip instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \ cp -r instantclient_19_3/* /lib && \ rm -rf instantclient-basic-linux.x64-19.3.0.0.0dbru.zip && \ apk add --no-cache libaio libnsl libc6-compat

COPY --from=builder /usr/src/app/devtools/ln_lib.sh /root/script.sh RUN chmod +x /root/script.sh RUN /root/script.sh

this is script.sh

!/bin/sh

https://github.com/Shrinidhikulkarni7/OracleClient_Alpine

cd /lib

Linking ld-linux-x86-64.so.2 to the lib/ location (Update accordingly)

ln -s /lib64/* /lib

ln -s libnsl.so.2 /usr/lib/libnsl.so.1 ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2


8. What problem or error(s) you are seeing?
Nothing. no errors. DPI_DEBUG_LEVEL=92

ODPI [00011] 2020-12-16 07:13:43.060: fn start dpiContext_createWithParams ODPI [00011] 2020-12-16 07:13:43.060: Context Parameters: ODPI [00011] 2020-12-16 07:13:43.060: Oracle Client Lib Dir: /lib ODPI [00011] 2020-12-16 07:13:43.060: Environment Variables: ODPI [00011] 2020-12-16 07:13:43.060: LD_LIBRARY_PATH => "/lib" ODPI [00011] 2020-12-16 07:13:43.060: load in parameter directory ODPI [00011] 2020-12-16 07:13:43.060: load in dir /lib ODPI [00011] 2020-12-16 07:13:43.060: load with name /lib/libclntsh.so ... stopped

After build dockerfile,
container on my mac is ok (like below DPI_DEBUG_LEVEL=100) , but container on my EC2 or any server (centos7) cannot load libclntsh.so files and print no logs, no errors.

ODPI [00015] 2020-12-16 06:43:13.188: fn start dpiContext_createWithParams ODPI [00015] 2020-12-16 06:43:13.188: Context Parameters: ODPI [00015] 2020-12-16 06:43:13.188: Oracle Client Lib Dir: /lib ODPI [00015] 2020-12-16 06:43:13.188: Environment Variables: ODPI [00015] 2020-12-16 06:43:13.188: LD_LIBRARY_PATH => "/lib" ODPI [00015] 2020-12-16 06:43:13.188: load in parameter directory ODPI [00015] 2020-12-16 06:43:13.188: load in dir /lib ODPI [00015] 2020-12-16 06:43:13.188: allocated 18 bytes at 0x1268f20 (allocate name buffer) ODPI [00015] 2020-12-16 06:43:13.188: load with name /lib/libclntsh.so ODPI [00015] 2020-12-16 06:43:13.200: load by OS successful .... some logs...

cjbj commented 3 years ago

If you use Alpine, you're on your own! See my previous comments at https://stackoverflow.com/a/53291026/4799035