DB2 Linux環境安裝

wanlt_software發表於2024-12-03

注:以下所述內容均以db2 for linux v9.7 x64 enterprise edition為標準

1 先決條件
作業系統版本 Linux 支援的最低階別作業系統包括:
Red Hat Enterprise Linux (RHEL) 5 更新 2.0.4
SUSE Linux Enterprise Server (SLES) 10 Service Pack 2
SUSE Linux Enterprise Server (SLES) 11
Ubuntu 8.0.4.1

程式包要求 Libaio
compat-libstdc++(包含 libstdc++.so.5)
libstdc++(libstdc++.so.6)
pdksh 或 ksh93
rsh-server
xinetd
openssh
openssh-server
nfs-utils
安全選項 SELINUX保持關閉

2 修改核心引數(以60%系統容量)
/etc/sysctl.conf kernel.shmmni=4096
kernel.shmmax=329853488332
kernel.shmall=80530636
kernel.sem=250 256000 32 4096
kernel.msgmni=32768
kernel.msgmax=65536
kernel.msgmnb=65536

  1. 匯出原db2 database引數以參考
    db2inst3@/home/db2inst3>db2cfexp ./ods5cfg.templ template
    db2inst3@/home/db2inst3>cat ods5cfg.templ

4建立使用者
groupadd -g 1000 db2iadm1
groupadd -g 1001 db2fadm1
useradd -u 1000 -g db2iadm1 -d /home/db2inst1 -m db2inst1
useradd -u 1001 -g db2fadm1 -d /home/db2fenc1 -m db2fenc1
echo '1q2w3e' |passwd --stdin db2inst1
echo '1q2w3e' |passwd --stdin db2fenc1

5建立目錄和掛載資訊
mkdir /database
mkdir /db2log
mkdir /db2arch
mkdir /backup
chown db2inst1:db2iadm1 /database
chown db2inst1:db2iadm1 /db2log
chown db2inst1:db2iadm1 /db2arch
chown db2inst1:db2iadm1 /backup

6此次在全新環境和跨平臺安裝,不採用響應式和嚮導安裝,使用db2_install安裝產品元件
檢視原安裝目錄
db2inst1@/opt/IBM/db2/V9.5>db2level
DB21085I Instance "db2inst3" uses "64" bits and DB2 code release "SQL09057"
with level identifier "06080107".
Informational tokens are "DB2 v9.5.0.7", "s101129", "IP23136", and Fix Pack
"7".
Product is installed at "/opt/IBM/db2/V9.5".
使用ROOT使用者執行
cd /tmp
tar -xvf db2_97_ese.linux64_x86_64bit.tar
cd ese
./db2_install
WARNING:
The 32 bit library file libstdc++.so.6 is not found on the system.
32-bit applications may be affected.

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.

ESE
CLIENT
RTCL

Enter "help" to redisplay product names.

Enter "quit" to exit.


help

Specify one of the following keywords to install DB2 products.

ESE
CLIENT
RTCL

Enter "help" to redisplay product names.

Enter "quit" to exit.


ese
WARNING:
The 32 bit library file libstdc++.so.6 is not found on the system.
32-bit applications may be affected.
DB2 installation is being initialized.

Total number of tasks to be performed: 47
Total estimated time for all tasks to be performed: 2019

Task #1 start
Description: Checking license agreement acceptance
Estimated time 1 second(s)
Task #1 end

Task #2 start
Description: Base Client Support for installation with root privileges
Estimated time 3 second(s)
Task #2 end

Task #3 start
Description: Product Messages - English
Estimated time 12 second(s)
Task #3 end

Task #4 start
Description: Base client support
Estimated time 176 second(s)
Task #4 end

Task #5 start
Description: Java Runtime Support
Estimated time 109 second(s)
Task #5 end

Task #6 start
Description: Java Help (HTML) - English
Estimated time 7 second(s)
Task #6 end

Task #7 start
Description: Base server support for installation with root privileges
Estimated time 7 second(s)
Task #7 end

Task #8 start
Description: Integrated Flash Copy Support
Estimated time 53 second(s)
Task #8 end

Task #9 start
Description: Global Secure ToolKit
Estimated time 29 second(s)
Task #9 end

Task #10 start
Description: Java support
Estimated time 11 second(s)
Task #10 end

Task #11 start
Description: SQL procedures
Estimated time 3 second(s)
Task #11 end

Task #12 start
Description: ICU Utilities
Estimated time 46 second(s)
Task #12 end

Task #13 start
Description: Java Common files
Estimated time 20 second(s)
Task #13 end

Task #14 start
Description: Base server support
Estimated time 230 second(s)
Task #14 end

Task #15 start
Description: IBM Software Development Kit (SDK) for Java(TM)
Estimated time 34 second(s)
Task #15 end

Task #16 start
Description: Control Center Help (HTML) - English
Estimated time 13 second(s)
Task #16 end

Task #17 start
Description: Connect support
Estimated time 3 second(s)
Task #17 end

Task #18 start
Description: Communication support - TCP/IP
Estimated time 3 second(s)
Task #18 end

Task #19 start
Description: Parallel Extension
Estimated time 3 second(s)
Task #19 end

Task #20 start
Description: EnterpriseDB code
Estimated time 3 second(s)
Task #20 end

Task #21 start
Description: Replication tools
Estimated time 19 second(s)
Task #21 end

Task #22 start
Description: Relational wrappers common
Estimated time 3 second(s)
Task #22 end

Task #23 start
Description: Control Center
Estimated time 41 second(s)
Task #23 end

Task #24 start
Description: Command Line Processor Plus
Estimated time 3 second(s)
Task #24 end

Task #25 start
Description: DB2 data source support
Estimated time 6 second(s)
Task #25 end

Task #26 start
Description: DB2 LDAP support
Estimated time 4 second(s)
Task #26 end

Task #27 start
Description: DB2 Instance Setup wizard
Estimated time 8 second(s)
Task #27 end

Task #28 start
Description: Spatial Extender client
Estimated time 3 second(s)
Task #28 end

Task #29 start
Description: Base application development tools
Estimated time 33 second(s)
Task #29 end

Task #30 start
Description: DB2 Update Service
Estimated time 4 second(s)
Task #30 end

Task #31 start
Description: First Steps
Estimated time 3 second(s)
Task #31 end

Task #32 start
Description: Product Signature for DB2 Enterprise Server Edition
Estimated time 5 second(s)
Task #32 end

Task #33 start
Description: Sample database source
Estimated time 4 second(s)
Task #33 end

Task #34 start
Description: DB2 Text Search
Estimated time 198 second(s)
Task #34 end

Task #35 start
Description: Informix data source support
Estimated time 4 second(s)
Task #35 end

Task #36 start
Description: Setting DB2 library path
Estimated time 180 second(s)
Task #36 end

Task #37 start
Description: Installing or updating SA MP
Estimated time 40 second(s)
Task #37 end

Task #38 start
Description: Executing control tasks
Estimated time 20 second(s)
Task #38 end

Task #39 start
Description: Updating global registry
Estimated time 20 second(s)
Task #39 end

Task #40 start
Description: Installing IBM Tivoli Monitoring for Databases
Estimated time 600 second(s)
Task #40 end

Task #41 start
Description: Starting DB2 Fault Monitor
Estimated time 10 second(s)
Task #41 end

Task #42 start
Description: Updating the db2ls link
Estimated time 1 second(s)
Task #42 end

Task #43 start
Description: Registering DB2 licenses
Estimated time 5 second(s)
Task #43 end

Task #44 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #44 end

Task #45 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #45 end

Task #46 start
Description: Registering DB2 Update Service
Estimated time 30 second(s)
Task #46 end

Task #47 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #47 end

A minor error occurred while installing "DB2 Enterprise Server Edition " on
this computer. Some features may not function correctly.

For more information see the DB2 installation log at
"/tmp/db2_install.log.87815".

注:此warning經查日誌資訊僅影響HADR主動回切功能,不影響企業版使用

7 修改系統引數
echo ‘127.0.1.111 ods5’ >> /etc/hosts
echo ‘db2inst1 50000/tcp’ >> /etc/services
echo ‘
db2list1 soft nofile 65536
db2inst1 hard nofile 65536
db2inst1 soft nproc 65536
db2inst1 hard nproc 65536
‘ >> /etc/security/limits.conf

8 建立例項
cd /opt/ibm/db2/V9.7/instance
./db2icrt -u db2fenc1 db2inst1

9 修改db2建立資料庫預設路徑為/database
db2 get dbm cfg | grep -i DFTDBPATH
Default database path (DFTDBPATH) = /home/db2inst1
db2 update dbm cfg using DFTDBPATH /database
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
db2 => create database dbtest
DB20000I The CREATE DATABASE command completed successfully.
[root@ods5 database]# ll
total 20
drwxrwxr-x. 3 db2inst1 db2iadm1 4096 Mar 13 17:41 db2inst1

10建立示例庫
su – db2inst1
db2sampl
db2 create database dbtest

11 修改db2日誌位置
db2 update db cfg for dbtest using NEWLOGPATH /db2log
db2 get db cfg for dbtest | grep LOGPATH
Changed path to log files (NEWLOGPATH) = /db2log/NODE0000/
Overflow log path (OVERFLOWLOGPATH) =
Mirror log path (MIRRORLOGPATH) =

[db2inst1@ods5 database]$ db2 update db cfg for dbtest using LOGARCHMETH1 disk:/db2arch
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst1@ods5 database]$ db2 get db cfg for dbtest | grep LOGARCH
First log archive method (LOGARCHMETH1) = DISK:/db2arch/
Options for logarchmeth1 (LOGARCHOPT1) =
Second log archive method (LOGARCHMETH2) = OFF
Options for logarchmeth2 (LOGARCHOPT2) =

12修改db2其他設定
db2set DB2_PARALLEL_IO=*
db2set DB2_SKIPINSERTED=YES
db2set DB2_USE_ALTERNATE_PAGE_CLEANING=YES
db2set DB2_EVALUNCOMMITTED=YES
db2set DB2_ANTIJOIN=EXTEND
db2set DB2_SKIPDELETED=YES
db2set DB2CODEPAGE=1208

13 修改日誌模式
[db2inst1@ods5 database]$ db2 update db cfg for dbtest using LOGRETAIN RECOVERY
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.

14 重啟資料庫並備份,資料庫到正常模式
[db2inst1@ods5 database]$ db2stop
03/13/2018 18:18:01 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
[db2inst1@ods5 database]$ db2start
03/13/2018 18:18:05 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
[db2inst1@ods5 database]$ db2 connect to dbtest
SQL1116N A connection to or activation of database "DBTEST" cannot be made
because of BACKUP PENDING. SQLSTATE=57019
[db2inst1@ods5 database]$ db2 backup db dbtest to /backup

Backup successful. The timestamp for this backup image is : 20180313182254

[db2inst1@ods5 database]$ db2 connect to dbtest

Database Connection Information

Database server = DB2/LINUXX8664 9.7.0
SQL authorization ID = DB2INST1
Local database alias = DBTEST

[db2inst1@ods5 database]$ db2 terminate
DB20000I The TERMINATE command completed successfully.

相關文章