Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue using ibm_db in lambda layer #616

Closed
mrn3 opened this issue Mar 10, 2020 · 11 comments
Closed

Issue using ibm_db in lambda layer #616

mrn3 opened this issue Mar 10, 2020 · 11 comments

Comments

@mrn3
Copy link

mrn3 commented Mar 10, 2020

Has anyone successfully gotten ibm_db working in a lambda layer?

Because it needs node-gyp and c bindings, I ended up creating my own node 10 runtime (using https://github.com/lambci/node-custom-lambda as a base). I add all the stuff I need (make gcc gcc-c++ kernel-devel openssl-devel bzip2-devel), and also do npm install --unsafe-perm ibm_db. I put the ibm_db stuff all in the nodejs folder, and my layer seems to look good. I also make sure to copy the license file to the license directory properly. When I run a lambda that uses the layer, I get "{ [Error: [IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968]" no matter what I do. I use the same license file and run this locally, and it works fine, so I am perplexed.

I am thinking it has to do something with the license file or environment variables so that lambda doesn't know to use the license file that is in the lambda layer.

Any guidance would be appreciated.

@bimalkjha
Copy link
Member

@mrn3 There might be problem with your license file version or some other installation of db2 exist in your system which is getting used at run-time. The error says, either license file is not found at correct location or license file is of incorrect version of Db2.

Please confirm the version of ibm_db and db2connect license. The license file should have name like db2con*.lic and it should be of version Db2 11.1. You should use ibm_db@2.6.4. License file should be copied under ibm_db/installer/clidriver/license directory.

Also, we would request to share the output of db2level command from your ibm_db directory. You can cd to ibm_db/installer/clidriver/bin directory and execute below command after updating the connection string to make sure license file is getting picked up and ibm_db is able to connect to the db2 server.

./db2cli validate -database "sample:hostname.com:60000" -user dbuser -passwd dbpass -connect

Please share the output of above command too. Thanks.

@mrn3
Copy link
Author

mrn3 commented Mar 12, 2020

Thanks so much for your response.

Yes, I have a license file and it is at:

/opt/nodejs/node_modules/ibm_db/installer/clidriver/license/db2consv_ee.lic

It has:

ProductVersion=11.1

I am using ibm_db@2.6.4.

When I am in my docker container, I run this:

bash-4.2# ./db2cli validate -database "ArkonaQ:proxy.privatelink.internal:10041" -user 'DTATTUN' -passwd '<some_password>' -connect

===============================================================================
Client information for the current copy:

Client Package Type : IBM Data Server Driver For ODBC and CLI
Client Version (level/bit): DB2 v11.1.4.5 (special_39510/64-bit)
Client Platform : Linux/X8664
Install/Instance Path : ..
DB2DSDRIVER_CFG_PATH value:
db2dsdriver.cfg Path : ../cfg/db2dsdriver.cfg
DB2CLIINIPATH value :
db2cli.ini Path : ../cfg/db2cli.ini
db2diag.log Path : db2diag.log

===============================================================================
db2dsdriver.cfg schema validation for the entire file:

Note: The validation utility could not find the configuration file
db2dsdriver.cfg. The file is searched at "../cfg/db2dsdriver.cfg".

===============================================================================
db2cli.ini validation for database "ArkonaQ:proxy.privatelink.internal:10041":

Note: The validation utility could not find the configuration file db2cli.ini.
The file is searched at "../cfg/db2cli.ini".

===============================================================================
db2dsdriver.cfg validation for database "ArkonaQ:proxy.privatelink.internal:10041":

Note: The validation utility could not find the configuration file
db2dsdriver.cfg. The file is searched at "../cfg/db2dsdriver.cfg".

===============================================================================
Connection attempt for database "ArkonaQ:proxy.privatelink.internal:10041":

[SUCCESS]

===============================================================================
The validation is completed.

I am not sure how to run it in lambda - may need to work on that.

@bimalkjha
Copy link
Member

@mrn3 Please update the connection string in the "db2cli validate" command in file /opt/nodejs/node_modules/ibm_db/installer/testODBCConnection.sh in lambda and execute it using ./testODBCConnection.sh command. It should generate some 1.* trace files. Please zip all the generated files along with db2consv_ee.lic file and email it to bjha@rocketsoftware.com for investigation. Thanks.

@bimalkjha
Copy link
Member

You can also delete the /opt/nodejs/node_modules/ibm_db/installer/clidriver/cfgcache/conlic.bin file and try the db2cli validate command again. If conlic.bin is not empty then the new license file will not be effective before a week. So, lets delete the conlic.bin and verify connection. Thanks.

@mrn3
Copy link
Author

mrn3 commented Mar 12, 2020

Thanks so much @bimalkjha. So I did remove the conlic.bin file and I seem to still get the error, so this isn't a result of caching the wrong license file. I will email you those generated trace files and the license file. It may be a bit of a challenge to read those 1.* files in lambda, but I will try.

@bimalkjha
Copy link
Member

@mrn3 After looking into the trace files, found below logs in 1.fmt file:

9627	data DB2 Common OSSe OSSHFile::open cei (3.1.3.2.2.30)
	pid 22 tid 140608212731776 sec 5 nsec 587858000 probe 30
	bytes 80

	Data1 	(PD_TYPE_DEFAULT,72) Hexdump:
	2F6F 7074 2F6E 6F64 656A 732F 6E6F 6465    /opt/nodejs/node
	5F6D 6F64 756C 6573 2F69 626D 5F64 622F    _modules/ibm_db/
	696E 7374 616C 6C65 722F 636C 6964 7269    installer/clidri
	7665 722F 6C69 6365 6E73 652F 6E6F 6465    ver/license/node
	6C6F 636B 2E64 6232                        lock.db2
9649	errtrans DB2 Common OSSe OSSHFile::open cei (13.1.3.2.2.100)
	pid 22 tid 140608212731776 sec 5 nsec 587902000 probe 100
	Error Translation
	Original Error OSERRNO = 30
	     New Error ECF = 0x9000001D = -1879048163 = ECF_FILE_READ_ONLY_FS

It looks the userid using which this node program is running do not have write permission for clidriver/license or clidriver/db2dump directories. Could you please check and correct the permission of these directories and try? Thanks.

@ibmdb ibmdb deleted a comment from mrn3 Mar 13, 2020
@mrn3
Copy link
Author

mrn3 commented Mar 13, 2020

Okay thank you so much. This actually makes a lot of sense because a lambda really only can reliably write to the /tmp directory. Is there a way I can configure this so it will write what it needs to there instead of in the clidriver directories? If so, how would I do that?

@mrn3
Copy link
Author

mrn3 commented Mar 13, 2020

I figure I could do a more manual install where I copy the clidriver directory on /tmp and then have an environment variable point to it as part of the lambda startup, but ideally I would just be able to configure the write directory in The IBM driver instead.

@mrn3
Copy link
Author

mrn3 commented Mar 13, 2020

I got it to work in lambda! Thank you so much for your help! I put the ODBC driver and license file in the /tmp folder (at run time I do that) so I can write to it. I also had to set PATH and LD_LIBRARY_PATH to point at that /tmp directory in my lambda, and run ldconfig at runtime as well.

If you have any other ideas (writing somewhere other than license or db2dump folder, or maybe just disable the caching of the license since I am losing that cache every time lambda restarts anyway), it would be very appreciated. Take care!

@bimalkjha
Copy link
Member

@mrn3 Unfortunately this is the only way that you are using. License file must be under clidriver/license directory and it requires write permission on license and db2dump directories.
Since its working for you now, I am closing the issue. Thanks.

@mrn3
Copy link
Author

mrn3 commented Mar 13, 2020

Okay great thanks @bimaljha - it is working well for me, and thanks for confirming that there isn't another way to accomplish it. Again, I appreciate all the help. Take care!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants