ibmdb / ruby-ibmdb

Rails Adapter/Ruby driver for IBM DB2 and IBM Informix
43 stars 49 forks source link

Clarification on installation steps #129

Closed jfahrenkrug closed 2 years ago

jfahrenkrug commented 2 years ago

Could you provide some clarification on what's needed to use this gem successfully? My main question is this: On a Unix system, do I need to install a DB2 client prior to installing the gem, or can the gem operate without doing that? It seems like the gem tries to download its own client and unzips it during installation.

To be more specific, this is what I'm currently doing:

  1. I install a DB2 client by running ./db2_client/client/disk1/db2setup -r db2_client/db2dev.rsp
  2. I then set the DB2 environment vars like this:
    ENV IBM_DB_INCLUDE=/home/db2inst1/sqllib/include
    ENV IBM_DB_LIB=/home/db2inst1/sqllib/lib
    ENV IBM_DB_HOME=/home/db2inst1/sqllib
    ENV PATH="${PATH}:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/misc"
    ENV DB2INSTANCE=db2inst1
    ENV DB2DIR=/opt/IBM/db2/V9.1
  3. I register some nodes and databases like this:
    db2 catalog tcpip node testdb remote testdb.example.com server 50001
    db2 catalog db testdb as testdb at node testdb
  4. Then I run bundle install for my Rails app to install the ibm_db gem.
  5. I connect to the registered node in my database.yml file like this:
    production:
    adapter: ibm_db
    database: testdb
    schema: someschema
    username: test
    password: test
    pool: 5
    timeout: 5000
    encoding: utf-8

My question is: Are steps 1-3 necessary? Could I connect to the DB2 instance on testdb.example.com directly from the Gem? If so, how?

Thank you!

praveen-db2 commented 2 years ago

@jfahrenkrug for your question, On a Unix system, do I need to install a DB2 client prior to installing the gem, or can the gem operate without doing that? It seems like the gem tries to download its own client and unzips it during installation.

Ans: You no need to install DB2 client prior to installing the gem. When you install GEM it auto downloads DB2 client.

jfahrenkrug commented 2 years ago

@praveen-db2 Thank you so much, that's very good to know! How would I handle the database.yml configuration without installing the client separately first? After installing the client, I currently run these catalog commands:

db2 catalog tcpip node testdb remote testdb.example.com server 50001
db2 catalog db testdb as testdb at node testdb

What do I need to put into database.yml if all I do is install the gem and I don't run any db2 catalog commands?

Thanks!

praveen-db2 commented 2 years ago

@jfahrenkrug database.yml should have below info, I had just pasted sample, You need to put your actual values.


default: &default
  adapter: ibm_db
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: xxxxxxxxx
  password: yyyyyyyyy
  #schema: db2inst1
  host: zzzzzzzzzzz
  port: 99999
  #account: my_account
  #app_user: my_app_user
  #application: my_application
  #workstation: my_workstation
  #security: SSL
  #timeout: 10
  #authentication: SERVER
  #parameterized: false

development:
  <<: *default
  database: abcdef

test:
  <<: *default
  database: abcdef

production:
  <<: *default
  database: newapp_production
  username: newapp
  password: <%= ENV['NEWAPP_DATABASE_PASSWORD'] %>
jfahrenkrug commented 2 years ago

@praveen-db2 Thank you very much!

praveen-db2 commented 2 years ago

@jfahrenkrug can we close this if its clarified your doubts ?

jfahrenkrug commented 2 years ago

@praveen-db2 Yes, it can be closed, thank you. However, it might be good to add this to the README for others who might have the same question.

praveen-db2 commented 2 years ago

@jfahrenkrug sure will take care in coming release. Thanks