Db2 Express C Db2 Install
I have attempted to install db2 Express-C 10.1 on OSX Mavericks, but I get the error listed here: db2 setup for Mac
Download Db2 Express-C, a fully licensed product available at no-charge for the community. It does not have any time restrictions. Use this data server for application development and deployment. Dec 10, 2016 How to Download and Install IBM DB2 Express-C on Windows Sir Jun Sagarino. Unsubscribe from Sir Jun Sagarino? Cancel Unsubscribe. Subscribe Subscribed Unsubscribe 4.
2 Answers
Here are the steps I did to install db2 express C on Mac OSX Mavericks.
Db2 Express C Installation
Note: I did all the commands logged into my own user; when I needed to run as a different user, I used sudo.
Steps:
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
Double click the downloaded file to untar and unzip it.
Modify system parameters with this command:
sudo vi /etc/sysctl.conf
and populate with this information:
reboot computer # with great sadness I added that instruction.
Begin the install process with these commands:
cd ~/Downloads/expc ; sudo ./db2_install
Accept the default path of '/opt/IBM/db2/V10.1'
Wait about three minutes for the script to run.
Note that a successful run ends in 'The execution completed successfully.'
create db2inst1 user using mac gui (System Preferences -> Users & Groups). Use Standard (Non-Admin) privileges.
Create the instance with these commands:
cd /opt/IBM/db2/V10.1/instance ; sudo ./db2icrt -u db2inst1 db2inst1
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
fiLog into new terminal window to get new settings from .bash_profile.Exit old windows to avoid confusion.
Initialize the sample database using this command:
db2sampl
Start the database using this command:
sudo -u db2inst1 db2start
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:
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.
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
Set that db2 should use tcp/ip using this command:
sudo -u db2inst1 db2set DB2COMM=TCPIP
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:
If you determine improvements to these instructions please post a comment. I will get notified and make the change.
Michael PotterMichael PotterExcellent 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.
Db2 Express C Installation Guide Windows
2) The errors were due to a locking issue that was somehow introduced:
2016-08-02-16.43.26.649406-300 I8390E1394 LEVEL: ErrorPID : 19747 TID : 4515377152 PROC : db2syscINSTANCE: db2inst1 NODE : 000EDUID : 1 EDUNAME: db2syscFUNCTION: DB2 Common, Generic Registry, GenRegFile::Lock, probe:50MESSAGE : ECF=0x900001DA=-1879047718=ECF_GENREG_UNABLE_TO_OPEN_LOCK_FILE Unable to open the lock fileCALLED : DB2 Common, OSSe, OSSHFile::openRETCODE : 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:
Db2 Express C Install Centos
-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. :)