Deploying IBM Db2 Warehouse SMP on Amazon Web Services using Elastic Container Service (ECS)
Amazon Elastic Container Service (ECS) is a highly scalable container management service that you can use to orchestrate the deployment of a Db2® Warehouse Docker container that is running on an EC2 instance.
Before you begin
- Create an IAM role, such as ecsInstanceRole.
- Create a key pair, such as db2whkeys.
Ensure that you meet the prerequisites described in Getting container images.
Procedure
-
Create a cluster by performing the following steps:
- Log in to the AWS Management Console.
- Search for Elastic Container Service.
- On the Amazon ECS page, click Clusters.
- Click Create Cluster.
- Select the EC2 Linux® + Networking template.
- Configure the cluster by completing the template. Specify at least the following information:
- A cluster name, such as smp-db2warehouse-cluster.
- The instance type. For Db2 Warehouse, you can use any of the memory optimized EC2 instances, such as r4.16xlarge.
- The number of instances. Specify 1 as the value, which corresponds to a single node for SMP.
- For EBS storage, a 100 GB data volume.
- The key value pair that you created earlier, such as db2whkeys.
- The IAM role that you created earlier, such as ecsInstanceRole.
- Click Create. The cluster is created and the EC2 instance is launched.
-
Log in to Docker using your API key:
whereecho <apikey> | docker login -u iamapikey --password-stdin icr.io<apikey>is the API key that you created as a prerequisite in Getting container images.When you log in, a ~/.dockercfg or ~/.docker/config.json file is created. This file contains authentication information, which includes an entry that looks similar to this one:{ "auths": { "https://index.docker.io/v1/": { "auth": "zq212MzEXAMPLE7o6T25Dk0i" } } } -
Enable the container agent to authenticate with the Docker repository by performing the
following substeps. For more information, see the private registry authentication information in the
Amazon Elastic Container Service documentation.
- Log in to the instance.
- Add the following entries to the /etc/ecs/ecs.config
file:
Replace theECS_ENGINE_AUTH_TYPE=dockercfg ECS_ENGINE_AUTH_DATA={"https://index.docker.io/v1/":{"auth":"auth_value","email":"email_address"}}auth_valueplaceholder with the value that follows the auth parameter in the auths entry of the ~/.docker/config.json or that was created in Step 2. For example:ECS_ENGINE_AUTH_TYPE=dockercfg ECS_ENGINE_AUTH_DATA={"https://index.docker.io/v1/":{"auth":"zq212MzEXAMPLE7o6T25Dk0i","email":"username@example.com"}} - Issue the following commands in the order shown
here:
docker inspect ecs-agent | grep ECS_DATADIR ecs stop ecs start
-
Create a task definition in the cluster:
- On the Amazon ECS page, click Task Definitions.
- Click Create new Task Definition and complete the template. Specify information for at least the Task Definition Field field, such as smp-db2warehouse-task.
- Click Add container and provide container information, as follows:
- In the Container name field, enter Db2wh.
- In the Image field, enter the following tag:
icr.io/obs/hdm/db2wh_ee:v11.5.7.0-cn5-db2wh-linux - In the Memory Limits (MiB) section, for the Soft limit, specify the maximum limit for your AMI instance.
- In the Port mappings section, add entries for the ports that are listed in the "Network prerequisites" section in IBM Db2 Warehouse prerequisites for Linux and x86 hardware.
- In the Security section, select the Privileged check box.
- In the Security section, enter Root in the User field.
- Click Add. The task definition is created.
-
Add data volumes for Db2 Warehouse:
- In the EC2 Dashboard, click ELASTIC BLOCK STORE > Volumes.
- Create EBS volumes. Make sure that the volumes and the EC2 instance are in the same availability zone.
- From the Actions menu, click Attach volume.
- Attach each volume to the EC2 instance that was launched when you created the cluster. To attach a volume, enter the instance name in the Instance field and click Attach.
-
Mount the EBS volumes on the instance:
- Log in to the instance.
- Mount the EBS volumes by modifying the following sample script for your environment and running
the script. The sample script is based on having three volumes that are named
/dev/sdg, /dev/sdf, and /dev/sdh.
# create mount point directory mkdir /mnt/clusterfs mkdir /mnt/clusterfs1 mkdir /mnt/clusterfs2 # create ext4 filesystem on new volume mkfs -t ext4 /dev/sdh mkfs -t ext4 /dev/sdg mkfs -t ext4 /dev/sdf # add an entry to fstab to mount volume during boot echo "/dev/sdh /mnt/clusterfs ext4 defaults,nofail 0 2" >> /etc/fstab echo "/dev/sdg /mnt/clusterfs1 ext4 defaults,nofail 0 2" >> /etc/fstab echo "/dev/sdf /mnt/clusterfs2 ext4 defaults,nofail 0 2" >> /etc/fstab # mount the volume on current boot mount -a - Confirm that the volumes are mounted by issuing the following
command:
df -Th | grep clusterfs - Revise the task definition to add the volumes that you created:
- On the Amazon ECS page, click Task Definitions.
- Select the task definition that you want to revise and click Create new revision.
- Click Add volume.
- For each volume, enter information in the Name and Source path fields and click Add.
- On the task definition page, click the Db2wh container link.
- In the STORAGE AND LOGGING section, add mount points. If you have only one data volume, create two mount points by using /mnt/bludata0 for the first container path and /mnt/blumeta0 for the second container path. If you have additional volumes, create one mount point for each volume by using /mnt/storage/volume for the container path. For example, if you have three volumes that are called clusterfs, clusterfs1, and clusterfs2, you would specify /mnt/storage/clusterfs1 for the container path for the mount point for the second volume and mnt/storage/clusterfs2 for the container path for the mount point for the third volume.
- Click Update and then Create. The revision is created.
-
Run the task:
- On the Amazon ECS page, click Clusters.
- On the Tasks tab, click Run new Task.
- From the Task Definition list, select the revised task definition and then click Run the task. Db2 Warehouse is deployed.