Db2

 View Only
  • 1.  DB2 CREATE DATABASE WITH PAGESIZE

    Posted Wed March 18, 2020 02:35 PM
    Hi ,

    Is there any provision to create database with pagesize with db2 docker image . I am using in my deployment and running it as a pod . So i would like my deployment to create database with the pagesize option .

    CREATE DATABASE TESTDB COLLATE USING SYSTEM PAGESIZE 32768


    ------------------------------
    YATHENDRA PRASAD
    ------------------------------

    #Db2


  • 2.  RE: DB2 CREATE DATABASE WITH PAGESIZE

    Posted Sat March 21, 2020 11:23 PM
    @YATHENDRA PRASAD
    Hello. I have no problem creating a 32KB page size database with docker images.

    [root@db2 db2]# docker run -itd --name mydb2 --privileged=true -p 50005:50005 -e LICENSE=accept -e DB2INST1_PASSWORD=db2inst1 ibmcom/db2
    18e8d22b5b5a291de45fd798ca9e4b3a8d485c5da76d4b5e721546032c52a92e
    [root@db2 db2]# docker images
    REPOSITORY                                     TAG                 IMAGE ID            CREATED             SIZE
    docker.io/ibmcom/informix-developer-database   latest              690e3d99d746        4 months ago        920 MB
    docker.io/rakudo-star                          latest              91fe3ad6db91        7 months ago        369 MB
    docker.io/ibmcom/db2                           latest              66a976f94954        8 months ago        2.96 GB
    [root@db2 db2]# docker exec -ti mydb2 bash -c "su - db2inst1"
    Last login: Sun Mar 22 03:15:46 UTC 2020 on console
    [db2inst1@18e8d22b5b5a ~]$ db2level
    DB21085I  This instance or install (instance name, where applicable:
    "db2inst1") uses "64" bits and DB2 code release "SQL11050" with level
    identifier "0601010F".
    Informational tokens are "DB2 v11.5.0.0", "s1906101300", "DYN1906101300AMD64",
    and Fix Pack "0".
    Product is installed at "/opt/ibm/db2/V11.5".
    
    [db2inst1@18e8d22b5b5a ~]$ db2 list db directory
    SQL1031N  The database directory cannot be found on the indicated file system.
    SQLSTATE=58031
    [db2inst1@18e8d22b5b5a ~]$ db2pd -
    
    Database Member 0 -- Active -- Up 0 days 00:00:01 -- Date 2020-03-22-03.16.00.690065
    
    [db2inst1@18e8d22b5b5a ~]$ db2 "create database testdb collate using system pagesize 32768"
    DB20000I  The CREATE DATABASE command completed successfully.
    [db2inst1@18e8d22b5b5a ~]$ db2 list db directory
    
     System Database Directory
    
     Number of entries in the directory = 1
    
    Database 1 entry:
    
     Database alias                       = TESTDB
     Database name                        = TESTDB
     Local database directory             = /database/data
     Database release level               = 15.00
     Comment                              =
     Directory entry type                 = Indirect
     Catalog database partition number    = 0
     Alternate server hostname            =
     Alternate server port number         =
    
    [db2inst1@18e8d22b5b5a ~]$ db2 get db cfg for testdb | grep -i page
     Database code page                                      = 1208
     Database page size                                      = 32768
     Multi-page file allocation enabled                      = YES
     Changed pages threshold                (CHNGPGS_THRESH) = 80
     Number of asynchronous page cleaners   (NUM_IOCLEANERS) = AUTOMATIC(4)
     Default prefetch size (pages)         (DFT_PREFETCH_SZ) = AUTOMATIC
     Track modified pages                         (TRACKMOD) = NO
     Default tablespace extentsize (pages)   (DFT_EXTENT_SZ) = 32
     Target for oldest page in LBP       (PAGE_AGE_TRGT_MCR) = 240
     Log pages during index build            (LOGINDEXBUILD) = OFF​


    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 3.  RE: DB2 CREATE DATABASE WITH PAGESIZE

    Posted Wed March 25, 2020 02:51 AM
    Hi @SangGyu Jeong ,

    Thanks for the reply . Yes we would be able to create the database once the container is up and running. We had requirement to create database with pagesize option on the fly . So this the approach i followed. I did copy the db2_common_functions from the location "/var/db2_setup/include/db2_common_functions" and add modified the create database method in the script to adpot the page size change . Created an new dockerfile and extented the db2 docker image to copy the modified db2_common_functions . Here is the snippet for the docker file

    FROM ibmcom/db2:11.5.0.0a

    USER root

    COPY db2_common_functions /var/db2_setup/include/db2_common_functions

    create_db()
    {
    dbname=$1
    echo "(*) Creating database $dbname ... "
    if su - ${DB2INSTANCE?} -c "db2 create db ${dbname?} collate using system pagesize 32768"; then
    su - ${DB2INSTANCE?} -c "db2 activate db ${dbname?}"
    fi
    }

    ​Thanks

    ------------------------------
    YATHENDRA PRASAD
    ------------------------------



  • 4.  RE: DB2 CREATE DATABASE WITH PAGESIZE

    IBM Champion
    Posted Thu March 26, 2020 03:45 AM
    Hi, you can get a problem when migrating to v-next of db2 docker image. you should considere not to create a database via ibm scripts using the environment variable but instead use your own script to create a database.

    in your new docker file you should at first create the directory /var/custom and place your create sripts there. the entrypoint script will do all its stuff and as a last step execute the scripts in that folder in alphabetic order. be aware that these scripts get executed as root, all db2 command will have to be execute as in your example with su - ${DB2INSTANCE?} -c "db2 xxxxxx"

    example for a docker file:

    FROM ibmcom/db2:11.5.0.0a
    RUN mkdir -p /var/custom
    COPY custom/* /var/custom/
    RUN chmod a+x /var/custom/*.sh


    ------------------------------
    Markus Fraune
    ------------------------------



  • 5.  RE: DB2 CREATE DATABASE WITH PAGESIZE

    Posted Thu March 26, 2020 07:12 AM
    Hi @Markus Fraune ,

    Thanks for your suggestion and made the changes according . It works !! .

    i have a query but slightly off the topic but related to applying Licensing on the DB2 Community Edition . I did tried to add the license manually logging on to db2 container . These are the steps i followed and below is the o/p i notice .


    1) Copied license file to home directory of instance
    2) Login as db2 instance owner
    3) Executed the below command to add new license

    db2licm -a <license filename>



    After applying licensing i do see its shows both the Developer-C license and also Db2 standard edition ,license . Is this the right approach of applying the license ??




    ------------------------------
    YATHENDRA PRASAD
    ------------------------------



  • 6.  RE: DB2 CREATE DATABASE WITH PAGESIZE

    IBM Champion
    Posted Thu March 26, 2020 07:40 AM
    Hi,

    you should remove the old license with db2licm -r. Best would be to include your license in your own db2 image. 2 Options here
    1) Copy your license file to the folder 

    /var/db2_setup/include
    e.g.:
    COPY db2stand.lic /var/db2_setup/include/.
    and with run/create of the container set the env variable to your license filename.
    example: docker run -v LICENSE_NAME=db2stand.lic .... myowndb2/db2:11.5
    2) Copy your license to /tmp/ and create a license registration script and place it in /var/custom (script should remove dev-c and add your own from /tmp/) - same location as your create database script

     



    ------------------------------
    Markus Fraune
    ------------------------------