美文网首页
Linux root用户安装DB2 V9.7

Linux root用户安装DB2 V9.7

作者: CodingCode | 来源:发表于2022-09-27 02:07 被阅读0次
    1. 切换到root用户
    $ su -
    
    1. 准备安装

    kernel参数调整,否则可能会遇到类似资源的错误:SQL2043N Unable to start a child process or thread.

    参考文档:https://www.ibm.com/docs/kk/db2/9.7?topic=SSEPGG_9.7.0/com.ibm.db2.luw.fresh.doc/com.ibm.db2.luw.qb.server.doc/doc/t0008238.html

    $ ipcs -l
    
       ------ Shared Memory Limits --------
       max number of segments = 4096               // SHMMNI    
       max seg size (kbytes) = 32768               // SHMMAX
       max total shared memory (kbytes) = 8388608  // SHMALL
       min seg size (bytes) = 1
    
       ------ Semaphore Limits --------
       max number of arrays = 1024                 // SEMMNI
       max semaphores per array = 250              // SEMMSL
       max semaphores system wide = 256000         // SEMMNS
       max ops per semop call = 32                 // SEMOPM
       semaphore max value = 32767
    
       ------ Messages: Limits --------
       max queues system wide = 1024               // MSGMNI
       max size of message (bytes) = 65536         // MSGMAX
       default max size of queue (bytes) = 65536   // MSGMNB
    
    $ cat /etc/sysctl.conf
    #Example for a computer with 16GB of RAM:
    kernel.shmmni=4096
    kernel.shmmax=17179869184
    kernel.shmall=8388608
    #kernel.sem=<SEMMSL> <SEMMNS> <SEMOPM> <SEMMNI>
    kernel.sem=250 256000 1024 4096
    kernel.msgmni=16384
    kernel.msgmax=65536
    kernel.msgmnb=65536
    
    $ sudo sysctl -p
    
    

    解包,检测:

    tar -zxvf DB2_XXX.tar.gz
    cd server
    ./db2prereqcheck
    
    1. 执行安装

    有两个命令

    • db2setup : 图形化方式安装
    • db2_install : 命令行方式安装

    下面以命令行方式为例:

    ./db2_install
    Default directory for installation of products - /opt/ibm/db2/V9.7
    
    ***********************************************************
    Do you want to choose a different directory to install [yes/no] ?
    no                ----> 缺省安装目录一般不用改
    
    Specify one of the following keywords to install DB2 products.
    
      CLIENT
      RTCL
      ESE
      CONSV
      WSE
      ...                ----> 这儿的选项根据不同的产品会有不同
    
    DB2 installation is being initialized.
    
     Total number of tasks to be performed: 44
    Total estimated time for all tasks to be performed: 1413
    
    Task #1 start
    Description: Checking license agreement acceptance
    Estimated time 1 second(s)
    Task #1 end
    
    ...
    
    Task #44 start
    Description: Updating global profile registry
    Estimated time 3 second(s)
    Task #44 end
    

    安装fixpack根据需要

    tar -zxvf v9.7fpxx_linuxx64_server.tar.gz
    cd db2fp/server
    ./installFixPack -b /opt/ibm/db2/V9.7/ ...
    ./installFixPack -b /opt/ibm/db2/V9.7/ -f sysreq -f db2lib
    
    1. 安装license

    查看license的状态

    /opt/ibm/db2/V9.7/adm/db2licm -l
    

    如果没有则安装:
    先把license文件拷贝到/opt/ibm/db2/V9.7/license/下面然后执行add

    cp /path/to/db2ese_c.lic /opt/ibm/db2/V9.7/license/db2ese_c.lic
    /opt/ibm/db2/V9.7/adm/db2licm -a /opt/ibm/db2/V9.7/license/db2ese_c.lic
    

    到这儿安装过程就完成了,下面要进行配置。

    1. 创建DB2运行所需要的用户组和用户

    参考文档:
    https://www.ibm.com/docs/en/db2/9.7?topic=requirements-creating-group-user-ids-db2-database-installation

    ----> 创建三个组
    groupadd db2iadm1
    groupadd db2fadm1
    groupadd dasadm1
    
    ----> 创建三个用户
    useradd -g db2iadm1 -m -d /home/db2inst1 db2inst1 # Instance owner
    useradd -g db2fadm1 -m -d /home/db2fenc1 db2fenc1    # Fenced user
    useradd -g dasadm1  -m -d /home/dasusr1 dasusr1      # DB2 administration server user
    
    ----> 修改三个用户密码
    passwd db2inst1
    passwd db2fenc1
    passwd dasusr1
    
    1. 创建DB2实例
    [root@server]#cd /opt/ibm/db2/V9.7/instance
    [root@instance]#./dascrt -u dasusr1
    SQL4406W  The DB2 Administration Server was started successfully.
    DBI1070I  Program dascrt completed successfully.
    
    [root@instance]#./db2icrt -u db2inst1 db2inst1
    DBI1070I  Program db2icrt completed successfully.
    
    1. 启动DB2实例
    [root@instance]# su - dasusr1
    [dasusr1@db2]$ . das/dasprofile
    [dasusr1@db2]$ db2admin start
    [dasusr1@db2]$ exit
    
    [root@instance]# su - db2inst1
    [db2inst1@db2]$ . sqllib/db2profile
    [db2inst1@db2]$ db2start
    [dasusr1@db2]$ exit
    

    关闭和启动

    [root@instance]# su - db2inst1
    [db2inst1@db2]$ . sqllib/db2profile
    [db2inst1@db2]$ db2 force applications all
    [db2inst1@db2]$ db2 terminate
    [db2inst1@db2]$ db2stop
    
    [db2inst1@db2]$ db2start
    

    设置自动启动

    [db2inst1@db2]$ /opt/ibm/db2/V9.7/instance/db2iauto -on db2inst1
    

    这里不确定是否需要root权限,至少命令的执行没有错误报告。

    1. DB2连接配置
    [root@instance]# su - db2inst1
    [db2inst1@db2]$ db2set DB2COMM=TCPIP
    [db2inst1@db2]$ db2 update dbm cfg using SVCENAME 50000
    [db2inst1@db2]$ db2 get dbm cfg |grep SVCENAME
    TCP/IP Service name                          (SVCENAME) = 50000
    SSL service name                         (SSL_SVCENAME) =
    [db2inst1@db2]$ db2stop
    [db2inst1@db2]$ db2start
    
    1. 创建并连接数据库
    [root@instance]# su - db2inst1
    [db2inst1@ db2]$ db2 create database testdb
    DB20000I The CREATE DATABASE command completed successfully.
    
    [db2inst1@db2]$ db2 connect to testdb
    
       Database Connection Information
    
     Database server        = DB2/LINUXXXX 9.7.0
     SQL authorization ID   = DB2INST1
     Local database alias   = TESTDB
    
    [db2inst1@db2]$ db2 create table mytab(a int)
    [db2inst1@db2]$ db2 insert into mytab values(10)
    

    相关文章

      网友评论

          本文标题:Linux root用户安装DB2 V9.7

          本文链接:https://www.haomeiwen.com/subject/dcqfartx.html