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:
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:
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
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:
- 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.