DB2 on Docker always reinitializes the instance

611 views Asked by At

I'm trying to run DB2 on Docker, but it always initializes the instance on every restart. I don't think this should be the case, as it always takes 5+ minutes.

I'm creating a dedicated volume for the container, as mounting the local drive was not possible due to permissions. I'm on macOS Ventura 13.0.1.

docker volume create db2 
docker run --platform linux/amd64 -h db2server --name db2server --detach --rm --privileged=true -p50000:50000 --env-file env-list.txt -v db2:/database ibmcom/db2:11.5.8.0

With this ENVs

LICENSE=accept
DB2INSTANCE=fapsrv
DB2INST1_PASSWORD=fapsrv
DBNAME=fapsrv
BLU=true
ENABLE_ORACLE_COMPATIBILITY=false
SAMPLEDB=false
HADR_ENABLED=false
ARCHIVE_LOGS=false

Which produces this logs. This looks kinda ok.

(*) Previous setup has not been detected. Creating the users...
(*) Creating users ...
(*) Creating instance ...
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.237".
DBI1446I  The db2icrt command is running.


DBI1070I  Program db2icrt completed successfully.


(*) Fixing /etc/services file for DB2 ...
12/07/2022 14:44:42     0   0   SQL1032N  No start database manager command was issued.
SQL1032N  No start database manager command was issued.  SQLSTATE=57019
(*) Cataloging existing databases
ls: cannot access '/database/data/fapsrv/NODE0000': No such file or directory
(*) Applying Db2 license ...

LIC1402I  License added successfully.


LIC1426I  This product is now licensed for use as outlined in your License Agreement.  USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V11.5/license/en_US.iso88591"
(*) Saving the checksum of the current nodelock file ...
(*) Updating DBM CFG parameters ...
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
No Cgroup memory limit detected, instance memory will follow automatic tuning
(*) Enabling analytical workloads for fapsrv ...
(*) Remounting /database with suid...
(*) Nothing appears in the Db2 directory. will skip update/upgrade.
(*) Code level is the same. No update/upgrade needed.

DB2 State : Operable
DB2 has not been started
Starting DB2...

12/07/2022 14:46:40     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
(*) User chose to create fapsrv database
(*) Creating database fapsrv ...
DB20000I  The CREATE DATABASE command completed successfully.
DB20000I  The ACTIVATE DATABASE command completed successfully.
(*) Log archiving will not be configured as ARCHIVE_LOGS has been set to false.
(*) Applying autoconfiguration for instance ...

   Database Connection Information

 Database server        = DB2/LINUXX8664 11.5.8.0
 SQL authorization ID   = FAPSRV
 Local database alias   = FAPSRV

DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W  One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, the database
must be shutdown and reactivated before the configuration parameter changes
become effective.
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
DB20000I  The SQL command completed successfully.
12/07/2022 14:49:42     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.
12/07/2022 14:49:46     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
(*) Skipping TEXT_SEARCH setup for database fapsrv because TEXT_SEARCH is not configured for the instance ...
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
(*) All databases are now active.
(*) Setup has completed.

When I reissue the run command, the setup starts again, although there are some files already available.

(*) Restoring global registry file ...
(*) Previous setup has not been detected. Creating the users...
(*) Creating users ...
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
(*) Preparing the environment before updating the instance ...
(*) Fixing /etc/services file for DB2 ...
(*) Fixing db2nodes file configuration ...
(*) Creating instance ...
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)
...
1

There are 1 answers

8
data_henrik On

Using run indeed reinitializes Db2. When you are done working on the Db2 instance, use the Docker stop or pause commands, then the start or unpause commands to resume work.