In this tutorial, we'll guide you through the step-by-step process of installing IBM Db2 Community Edition on an Amazon EC2 Ubuntu instance. We'll cover everything from setting up the EC2 instance to configuring Db2 and creating your first database.
IBM Db2 Community Edition is a cloud-native database designed to deliver low-latency transactions and high resilience for both structured and unstructured data. As an entry-level edition of the Db2 data server, it's tailored for developers and partners to explore the capabilities of Db2 in a cost-effective manner.
Available for Linux, Windows, AIX, and as a Docker image, Db2 Community Edition offers a comprehensive feature set, including core Db2 functionalities. While it is limited to up to 4 cores and 16 GB RAM, it provides a solid foundation for building and testing applications.
Security is a top priority with Db2 Community Edition, featuring always-on security measures to protect your data. Additionally, the community-driven support model ensures that you have access to helpful resources and assistance from fellow developers.
Prerequisites
- Setup an EC2 instance of type t2.medium
- Ubuntu 22.04 LTS as AMI
- 30 GB of hard disk space
- Open port 22 for SSH and 25000 for Db2
- Create an IBM account for downloading Db2 community edition
Installation Steps
I. Login to your EC2 instance and verify the distribution version.
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
II. Copy the downloaded latest IBM Db2 Linux (x64) version to EC2 instance and extract it.
$ tar -xzvf v11.5.9_linuxx64_server_dec.tar.gz
$ ls
server_dec v11.5.9_linuxx64_server_dec.tar.gz
- Inside the server_dec directory, you can see following list of files.
~/server_dec$ ls
db2
db2_deinstall
db2_install
db2checkCOL.tar.gz
db2checkCOL_readme.txt
db2ckupgrade
db2ls
db2prereqcheck
db2setup
installFixPack
III. From server_dec directory, Run db2prereqcheck command to check the prerequisite requirements for installing Db2.
~/server_dec$ sudo ./db2prereqcheck
==========================================================================
Sun Sep 15 16:37:59 2024
Checking prerequisites for DB2 installation. Version "11.5.9.0". Operating system "Linux"
Validating "kernel level " ...
Required minimum operating system kernel level: "3.10.0".
Actual operating system kernel level: "6.5.0".
Requirement matched.
Validating "Linux distribution " ...
Required minimum "UBUNTU" version: "16.04"
Actual version: "22.04"
Requirement matched.
Validating "Bin user" ...
Requirement matched.
Validating "C++ Library version " ...
Required minimum C++ library: "libstdc++.so.6"
Standard C++ library is located in the following directory: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30".
Actual C++ library: "CXXABI_1.3.1"
Requirement matched.
Validating "32 bit version of "libstdc++.so.6" " ...
Found the 64 bit "/lib/x86_64-linux-gnu/libstdc++.so.6" in the following directory "/lib/x86_64-linux-gnu".
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6".
Validating "libaio.so version " ...
DBT3553I The db2prereqcheck utility successfully loaded the libaio.so.1 file.
Requirement matched.
Validating "libnuma.so version " ...
DBT3610I The db2prereqcheck utility successfully loaded the libnuma.so.1 file.
Requirement matched.
Validating "/lib/i386-linux-gnu/libpam.so*" ...
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/i386-linux-gnu/libpam.so*".
WARNING : Requirement not matched.
Requirement not matched for DB2 database "Server" . Version: "11.5.9.0".
Summary of prerequisites that are not met on the current system:
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/i386-linux-gnu/libpam.so*".
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6".
The output indicates that the requirement checks have failed, and we need to address these issues.
- Enable 32-bit architecture on your instance and install the necessary packages.
- Install 32-bit library file: "/lib/i386-linux-gnu/libpam.so*" packages.
$ sudo dpkg --add-architecture i386
$ sudo apt-get update -y
$ sudo apt-get install libstdc++6:i386 libpam0g:i386 -y
- After installing the required packages, rerun the db2prereqcheck command to ensure all requirements are met.
$ sudo ./db2prereqcheck
==========================================================================
Sun Sep 15 16:40:55 2024
Checking prerequisites for DB2 installation. Version "11.5.9.0". Operating system "Linux"
Validating "kernel level " ...
Required minimum operating system kernel level: "3.10.0".
Actual operating system kernel level: "6.5.0".
Requirement matched.
Validating "Linux distribution " ...
Required minimum "UBUNTU" version: "16.04"
Actual version: "22.04"
Requirement matched.
Validating "Bin user" ...
Requirement matched.
Validating "C++ Library version " ...
Required minimum C++ library: "libstdc++.so.6"
Standard C++ library is located in the following directory: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30".
Actual C++ library: "CXXABI_1.3.1"
Requirement matched.
Validating "32 bit version of "libstdc++.so.6" " ...
Found the 32 bit "/lib/i386-linux-gnu/libstdc++.so.6" in the following directory "/lib/i386-linux-gnu".
Requirement matched.
Validating "libaio.so version " ...
DBT3553I The db2prereqcheck utility successfully loaded the libaio.so.1 file.
Requirement matched.
Validating "libnuma.so version " ...
DBT3610I The db2prereqcheck utility successfully loaded the libnuma.so.1 file.
Requirement matched.
Validating "/lib/i386-linux-gnu/libpam.so*" ...
Requirement matched.
DBT3533I The db2prereqcheck utility has confirmed that all installation prerequisites were met.
IV. Install Db2 using db2_install command as the root user and wait for the installation to complete.
$ sudo ./db2_install
Read the license agreement file in the db2/license directory.
***********************************************************
To accept those terms, enter "yes". Otherwise, enter "no" to cancel the install process. [yes/no]
yes
Default directory for installation of products - /opt/ibm/db2/V11.5
***********************************************************
Install into default directory (/opt/ibm/db2/V11.5) ? [yes/no]
yes
Specify one of the following keywords to install DB2 products.
SERVER
CONSV
CLIENT
RTCL
Enter "help" to redisplay product names.
Enter "quit" to exit.
***********************************************************
SERVER
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no]
no
DB2 installation is being initialized.
- Once the installation is completed, you will see the message below. You can then review the installation log file for post-installation steps.
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2_install.log.3355".
$ cat /tmp/db2_install.log.3355
Post-installation instructions
-------------------------------
Required steps:
Set up a DB2 instance to work with DB2.
Optional steps:
Notification SMTP server has not been specified. Notifications cannot be sent to contacts in your contact list until this is specified. For more information see the DB2 administration documentation.
To validate your installation files, instance, and database functionality, run the Validation Tool, /opt/ibm/db2/V11.5/bin/db2val. For more information, see "db2val" in the DB2 Information Center.
Refer to "What's new" https://www.ibm.com/docs/en/db2/11.5?topic=database-whats-new in the DB2 Information Center to learn about the new functions for DB2 V11.5.
Open First Steps by running "db2fs" using a valid user ID such as the DB2 instance owner's ID. You will need to have DISPLAY set and a supported web browser in the path of this user ID.
Verify that you have access to the DB2 Information Center based on the choices you made during this installation. If you performed a typical or a compact installation, verify that you can access the IBM Web site using the internet. If you performed a custom installation, verify that you can access the DB2 Information Center location specified during the installation.
Ensure that you have the correct license entitlements for DB2 products and features installed on this machine. Each DB2 product or feature comes with a license certificate file (also referred to as a license key) that is distributed on an Activation CD, which also includes instructions for applying the license file. If you purchased a base DB2 product, as well as, separately priced features, you might need to install more than one license certificate. The Activation CD for your product or feature can be downloaded from Passport Advantage if it is not part of the physical media pack you received from IBM. For more information about licensing, search the Information Center (https://www.ibm.com/docs/en/db2/11.5) using terms such as "license compliance", "licensing" or "db2licm".
To use your DB2 database product, you must have a valid license. For information about obtaining and applying DB2 license files, see http://www-01.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.qb.server.doc/doc/c0061199.html.
V. To validate our installation, execute the db2val command and review the log file to ensure everything is functioning correctly. If the validation completes without issues.
$ sudo /opt/ibm/db2/V11.5/bin/db2val
DBI1379I The db2val command is running. This can take several minutes.
DBI1335I Installation file validation for the DB2 copy installed at
/opt/ibm/db2/V11.5 was successful.
DBI1343I The db2val command completed successfully. For details, see
the log file /tmp/db2val-240915_164309.log.
$ cat /tmp/db2val-240915_164309.log
Installation file validation for the DB2 copy installed at "/opt/ibm/db2/V11.5" starts.
Task 1: Validating Installation file sets.
Status 1 : Success
Task 2: Validating embedded runtime path for DB2 executables and libraries.
Status 2 : Success
Task 3: Validating the accessibility to the installation path.
Status 3 : Success
Task 4: Validating the accessibility to the /etc/services file.
Status 4 : Success
DBI1335I Installation file validation for the DB2 copy installed at
/opt/ibm/db2/V11.5 was successful.
Installation file validation for the DB2 copy installed at "/opt/ibm/db2/V11.5" ends.
DBI1343I The db2val command completed successfully. For details, see
the log file /tmp/db2val-240915_164309.log.
Post Installation Steps
I. Create groups and users for DB administrators and fenced users, then assign passwords to the users.
$ sudo groupadd -g 997 db2admin
$ sudo groupadd -g 998 db2fence
$ sudo useradd -u 1003 -g db2admin -m -d /home/db2adm1 db2adm1
$ sudo useradd -u 1004 -g db2fence -m -d /home/db2fen1 db2fen1
II. Create a Db2 instance using the db2icrt command and check the log file for details on database connectivity.
$ sudo /opt/ibm/db2/V11.5/instance/db2icrt -a server -u db2fen1 db2adm1
DBI1446I The db2icrt command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 4
Total estimated time for all tasks to be performed: 309 second(s)
Task #1 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #1 end
Task #2 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #2 end
Task #3 start
Description: Configuring DB2 instances
Estimated time 300 second(s)
Task #3 end
Task #4 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #4 end
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.80519".
DBI1070I Program db2icrt completed successfully.
$ cat /tmp/db2icrt.log.80519
Post-installation instructions
-------------------------------
Required steps:
You can connect to the DB2 instance "db2adm1" using the port number "25001". Record it for future reference.
III. Now start the database instance using the below commands.
$ sudo su - db2adm1
$ db2ls
Install Path Level Fix Pack Special Install Number Install Date Installer UID
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V11.5 11.5.9.0 0 Sun Sep 15 16:42:52 2024 UTC 0
$ . sqllib/userprofile
$ db2start
09/15/2024 19:52:45 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
IV. Now the database instance is started and we can connect to the instance.
$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 11.5.9.0
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 =>
V. Create a test database and connect to the database using the below commands.
db2 => create database sales
DB20000I The CREATE DATABASE command completed successfully.
db2 => connect to sales
Database Connection Information
Database server = DB2/LINUXX8664 11.5.9.0
SQL authorization ID = DB2ADM1
Local database alias = SALES
That's it! Now you're ready to explore and work with the IBM Db2 database. I hope you find this guide helpful and enjoyable!
Top comments (0)