Yea yea, I’m on a DB2 blog kick tonight. I’ve been a fan of DB2 for a long time and it’s about time I posted some of this!

What’s the goal?


  • install DB2 (rootless)
  • configure it
  • configure fault monitors
  • setup autostart

That’s it!

What do I need?

This particular script assumes CentOS 7. To test it out, you can create a quick CentOS 7 VM, or spin up a droplet on DigitalOcean if you wish.

Note: make sure you have your host properly defined in /etc/hosts

Oh, and you should probably download DB2 Express-C while you’re at it.

Just get on with it!


Ok, so a few points:

  • The script is a combination of @angoca‘s work on getting DB2 into Docker (, and some of my own additions (like enabling the fault monitor).
  • The script must be run as root (which it will validate in lines 3-7)
  • The script will validate that you defined your hostname in /etc/hosts (lines 9-14)
  • This will be a rootless install, and the instance owner will be db2inst1
  • For testing, I like to make myself an instance owner (probably not best practice, but in the context of a development environment I’m fine with it) (line 23)
  • Lines 25-40 ensure needed packages are installed
  • Line 46 actually installs DB2
  • Lines 49-52 make some tweaks to the configuration (e.g. port, OS authentication, etc.)
  • Line 57 configures DB2 with our tweaks, and also enables TCP communication to the database
  • Lines 60-84 configure auto-start and the fault monitors
  • Lines 88-94 do some cleanup, then prompt to reboot

What do I do next?

With DB2 installed, all of my database user setup, database creation, table creation, etc. are all automated. Maybe in another post I’ll explain that.

Oh, and if you are using zsh, see my post on getting db2profile to work with zsh at

Are you a DBA and did I do something wrong? Let me know! I’ll get it fixed so I don’t direct someone the wrong way