0

so im trying to push a python api with cx_oracle dependency which also need oracle instant client,but i couldnt found an tutorial to deploy instant client on pcf,is anybody ever do this before or have any example what should be done? appreciate it

Update:

This is the inside of my .profile

LD_LIBRARY_PATH=/home/vcap/app/oracle/instantclient:${LD_LIBRARY_PATH:-}
export OCI_LIB_DIR=/home/vcap/app/oracle/instantclient
export OCI_INC_DIR=/home/vcap/app/oracle/instantclient/sdk/include
export PYTHONPATH=/home/vcap/app/vendor:$PYTHONPATH
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
  • 1
    Just use the zip installer and not a package manager. Extract the files to a subfolder under your application, like `oracle/`. Install `cx-Oracle` like normal with pip. Generate requirements.txt. Add a `.profile` file to the root of your application, in it put `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/vcap/app/oracle/lib` (or path where you installed Oracle client libraries). Then push your app. The `.profile` file will adjust library search path so Oracle client libraries can be found, it runs before your app starts. Let me know if you get stuck somewhere. – Daniel Mikusa Jul 11 '20 at 18:11
  • thanks for replying, i'm a lil confused, about the instant oracle , so i should extract it inside the project folder right? and about the .profile extension file, what is the file name? and should i add it to requirement? @DanielMikusa – Beavis Luckyano Jul 15 '20 at 08:31
  • Yes, extract the Oracle Instant client to a sub folder under your project. I like to call mine `oracle/` but you can name it whatever you want. `.profile` is the exact name that you need to use for the file. It's not an extension. If you're on Windows, make sure Windows isn't adding a hidden extension. The file name needs to be excactly `.profile` and needs to be in the root of your project folder, where you run `cf push`. – Daniel Mikusa Jul 16 '20 at 03:58
  • @DanielMikusa thanks for the tips, i already try to push it and it succeed but i see this at my app log cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "/home/vcap/app/oracle/instantclient/libclntsh.so: file too short" – Beavis Luckyano Jul 22 '20 at 08:03
  • It doesn't seem to like the Oracle instant client libraries that you uploaded. Make sure you downloaded the 64-bit Linux instant client & extracted that to your app under the `oracle/` directory. – Daniel Mikusa Jul 22 '20 at 14:06
  • but it is @DanielMikusa i download it from here,the zip : [link](https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html) and i extract it inside the directory, i use windows os tho, is there any other possibility? – Beavis Luckyano Jul 23 '20 at 01:12
  • OK, what is in your `.profile` file? It seems like if LD_LIBRARY_PATH isn't set right you can have that issue. It also seems like it need `libaio.so`, but that should be available out of the box. – Daniel Mikusa Jul 23 '20 at 14:10
  • @DanielMikusa so i updated my answer with my .profile, and yes the file 'libclntsh.so' is exist but i didnt find any file named 'libaio.so' – Beavis Luckyano Jul 24 '20 at 01:40
  • @DanielMikusa i did it thanks daniel turns out i havent add export to my file. Is there any way to manually do pip install in pivotal? because i have scikit-surprise library that need a numpy installed first before it could be installed, and the include it in requirements.txt didn't work – Beavis Luckyano Jul 24 '20 at 05:04
  • No, not during staging. The python buildpack will install whatever is in your requirements.txt file. I'm not sure why that's failing without more info, kind of sounds like a different issue/question. – Daniel Mikusa Jul 25 '20 at 14:13

1 Answers1

0
  1. Use the zip installer of the Oracle Instant Client and not a package manager.
  2. Extract the files to a subfolder under your application, like oracle/.
  3. Install cx-Oracle like normal with pip.
  4. Generate requirements.txt.
  5. Add a file with the exact name of .profile to the root of your application, in it put export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/vcap/app/oracle/lib (where /home/vcap/app is the path to your application files and oracle/lib is the path to the lib directory beneath the folder where you extracted files in step #2).
  6. Then push your app.

The .profile file will run before your actual application starts and it will adjust the library search path so that the Oracle client libraries can be found.

If you get the error:

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "/home/vcap/app/oracle/instantclient/libclntsh.so: file too short"

Double check your .profile script and make sure that you have the correct LD_LIBRARY_PATH setting.

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28