Amazon Python 2.7 Lambda: DPI-1047: 64-bit Oracle Client library cannot be loaded: “libclntsh.so”

折月煮酒 提交于 2019-12-24 07:28:24

问题


This article was the closest to what I experienced: Connecting to Oracle RDS using AWS Lambda using Python. However, after following all of the steps, I am unable to get a successful result.

Steps on ami-aa5ebdd2 in us-west-2:

sudo yum -y install gcc
mkdir oracle_connect
source oracle_connect/bin/activate
virtualenv oracle_connect
pip install cx_Oracle
wget https://github.com/bumpx/oracle-instantclient/raw/master/instantclient-basic-linux.x64-12.2.0.1.0.zip
mv instantclient_12_2/* oracle_connect/lib/
cd oracle_connect
vi test.py # insert python code here
cp /lib64/libaio.so.1.0.1 lib
ln -s ./lib/libclntsh.so.12.1 ./lib/libclntsh.so
ln -s ./lib/libaio.so.1.0.1 ./lib/libaio.so.1
ln -s ./lib/libaio.so.1.0.1 ./libaio.so.1.0.1
ln -s ./lib/libaio.so.1.0.1 ./libaio.so.1.0.1
cd lib/python2.7/site-packages/
zip -r ~/oracle_connect.zip * .*
cd ~/oracle_connect/lib64/python2.7/site-packages/
zip -r ~/oracle_connect.zip * .*
cd ~/oracle_connect
zip --symlinks -r9 ~/oracle_connect.zip lib/*
zip ~/oracle_connect.zip test.py

The test code is just a cx_Oracle.connect(connection_string) within a lambda handler.

Any advice? I tried to give as much detail as possible. When I try to run this locally, it won't work until I setup: export LD_LIBRARY_PATH=/home/ec2-user/oracle_connect/lib

So I setup the environmental variable on the lambda as: LD_LIBRARY_PATH: /var/task/lib


回答1:


So I finally got it working. I re-downloaded the instantclient-basic-linux.x64-12.2.0.1.0.zip from Oracle: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html. I copied the files into the ~/oracle_connect/lib folder. I changed my symlinks to /var/task/lib/(filename) instead of the relative path, and removed the lambda environment variables. Everything works now.



来源:https://stackoverflow.com/questions/48330428/amazon-python-2-7-lambda-dpi-1047-64-bit-oracle-client-library-cannot-be-loade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!