How do I install db2 Express-C 10.1 on OSX Mavericks

一世执手 提交于 2019-12-17 10:44:39

问题


I have attempted to install db2 Express-C 10.1 on OSX Mavericks, but I get the error listed here: db2 setup for Mac


回答1:


Here are the steps I did to install db2 express C on Mac OSX Mavericks.

Note: I did all the commands logged into my own user; when I needed to run as a different user, I used sudo.

Steps:

  1. Download DB2 express C from here: https://www14.software.ibm.com/webapp/iwm/web/reg/download.do?source=swg-db2expressc&S_PKG=dlmacosx&S_TACT=100KG31W&lang=en_US&cp=UTF-8&dlmethod=http

  2. Double click the downloaded file to untar and unzip it.

  3. Modify system parameters with this command:

    sudo vi /etc/sysctl.conf

    and populate with this information:

    kern.sysv.shmmax=1073741824
    kern.sysv.shmmin=1
    kern.sysv.shmmni=4096
    kern.sysv.shmseg=32
    kern.sysv.shmall=1179648
    kern.maxfilesperproc=65536
    kern.maxfiles=65536
    
  4. reboot computer # with great sadness I added that instruction.

  5. Begin the install process with these commands:
    cd ~/Downloads/expc ; sudo ./db2_install

  6. Accept the default path of '/opt/IBM/db2/V10.1'

  7. Wait about three minutes for the script to run.

  8. Note that a successful run ends in 'The execution completed successfully.'

  9. create db2inst1 user using mac gui (System Preferences -> Users & Groups). Use Standard (Non-Admin) privileges.

  10. Create the instance with these commands:
    cd /opt/IBM/db2/V10.1/instance ; sudo ./db2icrt -u db2inst1 db2inst1

  11. Modify your profile with this command:

    vim ~/.bash_profile
    and add these lines (probably at the end of the file):
    PATH=$PATH:/opt/IBM/db2/V10.1/bin
    if [[ -f ~db2inst1/sqllib/db2profile ]]
    then
    source ~db2inst1/sqllib/db2profile
    fi

  12. Log into new terminal window to get new settings from .bash_profile. Exit old windows to avoid confusion.

  13. Initialize the sample database using this command:
    db2sampl

  14. Start the database using this command:
    sudo -u db2inst1 db2start

  15. Test the sample database using these commands:
    db2 connect to SAMPLE
    db2 list tables

If you need to connect to this database from a remote machine, or want to connect to this database using Java where the connection requires a host and port number, then follow the instructions to enable remove connections. You can defer running these instructions until you actually need to connect in this fashion. Without running these instructions you can connect using db2 command line, after running these instructions you will be able to connect with any number of tools that require a host and port number.

Steps to Enable Remote Connections:

  1. Update db2 to allow remote services using these commands:

    cd ~db2inst1

    sudo -u db2inst1 db2 update dbm cfg using svcename db2c_db2inst1

    The cd is necessary because the command needs to write to the current directory.

  2. Add the service port using this command:

    sudo vim /etc/services

    and add this line as the last line in the file. The actual position is not important.

    db2c_db2inst1 50000/tcp

  3. Set that db2 should use tcp/ip using this command:

    sudo -u db2inst1 db2set DB2COMM=TCPIP

  4. Stop and start the database with these commands:

    sudo -u db2inst1 db2stop force

    sudo -u db2inst1 db2start

    Note the force on the stop command. That will drop any existing connections. If you want to be kind to the users who are connected, do not use force and just keep retrying the command after asking the users to disconnect. I included the force in the default instructions because it is likely that anyone following these instructions is the only user on the database.

References:

  • http://programmingzen.com/2009/01/20/installing-db2-on-mac-os-x/
  • https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014927797

If you determine improvements to these instructions please post a comment. I will get notified and make the change.




回答2:


Excellent instructions Leons! FYI for those who ran into DB2 errors when following his step-by-step and his updated guide for El Capitan, this may help.

1) I got the following errors when running the above steps 13 & 14 as db2inst1 (I was not able to run step 13 with my Mac userid, it likely gave some other error regarding userId/password, can't remember):

db2inst1$ db2sampl

Starting the DB2 instance... Creating database "SAMPLE"... Attempt to create the database "SAMPLE" failed. SQL1032N No start database manager command was issued. SQLSTATE=57019

'db2sampl' processing complete.

db2inst1$ db2start

SQL1652N File I/O error occurred.

2) The errors were due to a locking issue that was somehow introduced:

2016-08-02-16.43.26.649406-300 I8390E1394 LEVEL: Error PID : 19747 TID : 4515377152 PROC : db2sysc INSTANCE: db2inst1 NODE : 000 EDUID : 1 EDUNAME: db2sysc FUNCTION: DB2 Common, Generic Registry, GenRegFile::Lock, probe:50 MESSAGE : ECF=0x900001DA=-1879047718=ECF_GENREG_UNABLE_TO_OPEN_LOCK_FILE Unable to open the lock file CALLED : DB2 Common, OSSe, OSSHFile::open RETCODE : ECF=0x90000001=-1879048191=ECF_ACCESS_DENIED Access denied

3) Turns out in my ~db2inst1/sqllib there were 2 files that were somehow created under my Mac userid instead of db2inst1, and they were preventing db2inst1 from obtaining the registry lock:

-rw-r--r-- 1 myMacUserId staff 0 29 Jul 15:58 .global.reg.lock
-rw-r--r-- 1 myMacUserId staff 90 29 Jul 15:58 global.reg

4) Once I deleted these 2 files, DB2 was able to start successfully and create the SAMPLE database. :)



来源:https://stackoverflow.com/questions/23341171/how-do-i-install-db2-express-c-10-1-on-osx-mavericks

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