简体   繁体   中英

Environment Variables / oracledb on Elastic Beanstalk

We are trying to install the node module oracledb on an Amazon Elastic Beanstalk instance.

We can get oracledb working fine locally, and we have gotten to the point where the Beanstalk instance installs instantclient via the rpms. What we are stuck on now is that npm install expects to either use LD_LIBRARY_PATH or for instantclient to be in /opt/oracle/instantclient . Currently, the rpms install it to /usr/lib/oracle/12.1/client64

It seems that there are two possible solutions:

  1. Get the rpm to install the instantclient to /opt/oracle/instantclient or move it / link it after the fact
  2. Set the LD_LIBRARY_PATH environment variable so that npm install knows to use instantclient from /usr/lib/oracle/12.1/client64

We don't know how to do either of these things properly in a Beanstalk configuration, though.

I can't find any information on when a Beanstalk instance actually runs npm install and we are not telling it to do so explicitly, but it is running.

Changing environment variables through environment properties as the documentation suggests here does not work . Seemingly these are only set when the server actually runs as in

LD_LIBRARY_PATH=x node app.js

They are not used for npm install .

How can we update our elastic beanstalk configuration to either put the instantclient where we want it or set LD_LIBRARY_PATH during npm install?

When installing node-oracledb v1 on Linux, the install looks for Oracle libraries in this order:

  1. Using install-time environment variables $OCI_LIB_DIR and $OCI_INC_DIR
  2. In the highest version Instant Client RPMs installed
  3. In $ORACLE_HOME
  4. In /opt/oracle/instantclient

See https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#linuxadv

You can see the logic that does this in https://github.com/oracle/node-oracledb/blob/master/binding.gyp

So the premise for the question is incorrect and you shouldn't need to change Instant Client. With Instant Client RPMs you should not need to set environment variables when running 'npm install oracledb', and you do not need to set LD_LIBRARY_PATH at runtime. The link above has the details.

The question is, what is failing for your install?

Update: With node-oracledb v2 you do need to set ORACLE_HOME (only for full Oracle installations) or use LD_LIBRARY_PATH or use ldconfig, as explained in the installation manual

Option 1: Install oracledb under /opt/oracle/instantclient/

You can try to change the instalation folder of a rpm package using the --prefix option

rpm --prefix=/opt/oracle/instantclient/ <oracledb_pack_name>.rpm

It works only if the package is relocatable. You can check this with:

rpm -ql <oracledb_pack_name>.rpm

Option 2: Change LD_LIBRARY_PATH

As described in customize-containers-format-commands

You can use the commands key to execute commands on the EC2 instance. The commands are processed in alphabetical order by name, and they run before the application and web server are set up and the application version file is extracted.

You could try exporting the LD_LIBRARY_PATH in the configuration file commands: section. This should export the env variable for npm. Something like:

commands:
    export-ld-lib:
        command: export LD_LIB_PATH=//usr/lib/oracle/12.1/client64

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM