Skip to content

Migrate db2 developer edition to new server

Here is a guide I wrote for my work, I just post it here so that I can refer to it even after I leave.

Install the same DB2 version as in DEV environment (v11.1.2.2)

IBM does not support old version of DB2 developer edition, and when new version is released, old version support is dropped and you’re not able to install them any more.

As a workaround, we need to migrate the existing DB2, which runs as a container, to new server to get the same version.

Here is the steps to migrate the container:

on existing DB2 server:

docker export db2server -o db2server.tar                             ## run this command to export db2server container
docker inspect db2server |jq '.[]|.HostConfig.Binds'                 ## run this command to check what folder is mounted on container

then, copy db2server.tar and the folder from 2nd command (usually /home/centos/.config/ibm-db2-hkex/DB2/db2fs or /home/centos/.config/ibm-db2-developerc/DB2/db2fs) to new server

on new server, run these commands:

sudo yum install -y docker  ## to install docker

sudo systemctl enable docker ## config docker to start at boot

sudo groupadd docker     ## create docker group, to grant current user permission to run docker

sudo usermod -aG docker $USER   ## add current user to docker group

logout and log back in, try ‘docker info’ to make sure your account has permission to start docker containers

docker import db2server.tar   ## import container

docker images   ## list docker images. copy the image ID for use with below command

docker tag IMAGE_ID  db2server:11.1.2.2  ## give this docker image a tag, will be referenced later.

create a file called ‘.env_list’, with the following content:

LICENSE=accept
DB2INSTANCE=db2inst1
DB2INST1_PASSWORD=myadmin
BLU=false
ENABLE_ORACLE_COMPATIBILITY=false
UPDATEAVAIL=NO
TO_CREATE_SAMPLEDB=false
REPODB=false
IS_OSXFS=true
PERSISTENT_HOME=true
STORAGE_DIR=/database
SETUPDIR=/var/db2_setup
HADR_SHARED_DIR=/hadr
LICENSE_NAME=db2dec.lic
DBPORT=50000
TSPORT=55000
HADR_ENABLED=false
ETCD_ENDPOINT=
ETCD_USERNAME=
ETCD_PASSWORD=

create a file called run_db2_container.sh, with the following content:

Note the argument to ‘-v’, make sure the folder is where you put the content copied from the old server.

docker run \
--name db2server --restart=always \
--detach \
--privileged=true \
-p 50000:50000 -p 55000:55000 \
--env-file .env_list \
-v /home/centos/.config/ibm-db2-hkex/DB2/db2fs:/db2fs \
db2server:11.1.2.2 \
/var/db2_setup/lib/entrypoint.sh

then, run below command to start the container:

bash run_db2_container.sh

then, run below command to make sure container started:

docker ps

update db2nodes.cfg file with new container hostname, with below commands:

docker exec -it db2server bash   ## login to container

hostname    ## run this within container, to get its hostname

edit file /home/db2inst1/sqllib/db2nodes.cfg, replace old hostname string with new one.

exit  ## logout from container

restart container and verify DB2 is working:

docker stop db2server   ## run this from host machine, to stop the container

docker start db2server ## start container

docker exec -it db2server bash   ## login to container

su - db2inst1   ## switch to db2 admin account

db2 connect to sample   ## try connect to a sample database, to verify db2 is working

exit;exit   ## exit twice to logout from container
Avatar

专业Linux/Unix/Windows系统管理员,开源技术爱好者。对操作系统底层技术,TCP/IP协议栈以及信息系统安全有强烈兴趣。电脑技术之外,则喜欢书法,古典诗词,数码摄影和背包行。

Sidebar