安裝順序
scp ./v9.7fp7_linuxx64_server.tar.gz [email protected]:/tmp/
# 創建需要的目錄
mkdir -p /db2
mkdir /source
# 複製安裝包到映像內
mv /tmp/v9.7fp7_linuxx64_server.tar.gz /source
# 安裝必要的依賴包
yum update -y
yum install -y gcc libaio libstdc++ libstdc++-devel pam perl tar pam.i686 libnsl libnsl.i686 glibc.i686
# OL9
yum install -y glibc.i686 libstdc++.i686
yum install -y https://rpmfind.net/linux/mageia/distrib/cauldron/x86_64/media/core/release/libstdc++5-3.3.6-19.mga9.x86_64.rpm
# OL9 離線安裝準備 rpm
yumdowner gcc glibc libaio libnsl libnsl libstdc++ libstdc++-devel libstdc++-devel pam perl glibc glibc-common glibc-gconv-extra glibc-langpack-en libgcc libgomp libstdc++ pam annobin audit-libs cpp dwz efi-srpm-macros fonts-srpm-macros gcc-c++ gcc-plugin-annobin ghc-srpm-macros glibc-devel glibc-gconv-extra glibc-headers go-srpm-macros kernel-headers kernel-srpm-macros libcap-ng libdatrie libdb libeconf libgcc libmpc libpkgconf libselinux libsepol libthai libxcrypt libxcrypt-devel llvm-libs lua-srpm-macros ocaml-srpm-macros openblas-srpm-macros openssl-libs pcre2 perl-Algorithm-Diff perl-Archive-Tar perl-Archive-Zip perl-Attribute-Handlers perl-AutoLoader perl-AutoSplit perl-B perl-Benchmark perl-CPAN perl-CPAN-Meta perl-CPAN-Meta-Requirements perl-CPAN-Meta-YAML perl-Carp perl-Class-Struct perl-Compress-Bzip2 perl-Compress-Raw-Bzip2 perl-Compress-Raw-Lzma perl-Compress-Raw-Zlib perl-Config-Extensions perl-Config-Perl-V perl-DBM_Filter perl-DB_File perl-Data-Dumper perl-Data-OptList perl-Data-Section perl-Devel-PPPort perl-Devel-Peek perl-Devel-SelfStubber perl-Devel-Size perl-Digest perl-Digest-MD5 perl-Digest-SHA perl-Digest-SHA1 perl-DirHandle perl-Dumpvalue perl-DynaLoader perl-Encode perl-Encode-devel perl-English perl-Env perl-Errno perl-Exporter perl-ExtUtils-CBuilder perl-ExtUtils-Command perl-ExtUtils-Constant perl-ExtUtils-Embed perl-ExtUtils-Install perl-ExtUtils-MM-Utils perl-ExtUtils-MakeMaker perl-ExtUtils-Manifest perl-ExtUtils-Miniperl perl-ExtUtils-ParseXS perl-Fcntl perl-File-Basename perl-File-Compare perl-File-Copy perl-File-DosGlob perl-File-Fetch perl-File-Find perl-File-HomeDir perl-File-Path perl-File-Temp perl-File-Which perl-File-stat perl-FileCache perl-FileHandle perl-Filter perl-Filter-Simple perl-FindBin perl-GDBM_File perl-Getopt-Long perl-Getopt-Std perl-HTTP-Tiny perl-Hash-Util perl-Hash-Util-FieldHash perl-I18N-Collate perl-I18N-LangTags perl-I18N-Langinfo perl-IO perl-IO-Compress perl-IO-Compress-Lzma perl-IO-Socket-IP perl-IO-Socket-SSL perl-IO-Zlib perl-IPC-Cmd perl-IPC-Open3 perl-IPC-SysV perl-IPC-System-Simple perl-Importer perl-JSON-PP perl-Locale-Maketext perl-Locale-Maketext-Simple perl-MIME-Base64 perl-MIME-Charset perl-MRO-Compat perl-Math-BigInt perl-Math-BigInt-FastCalc perl-Math-BigRat perl-Math-Complex perl-Memoize perl-Module-Build perl-Module-CoreList perl-Module-CoreList-tools perl-Module-Load perl-Module-Load-Conditional perl-Module-Loaded perl-Module-Metadata perl-Module-Signature perl-Mozilla-CA perl-NDBM_File perl-NEXT perl-Net perl-Net-Ping perl-Net-SSLeay perl-ODBM_File perl-Object-HashBase perl-Opcode perl-POSIX perl-Package-Generator perl-Params-Check perl-Params-Util perl-PathTools perl-Perl-OSType perl-PerlIO-via-QuotedPrint perl-Pod-Checker perl-Pod-Escapes perl-Pod-Functions perl-Pod-Html perl-Pod-Perldoc perl-Pod-Simple perl-Pod-Usage perl-Safe perl-Scalar-List-Utils perl-Search-Dict perl-SelectSaver perl-SelfLoader perl-Socket perl-Software-License perl-Storable perl-Sub-Exporter perl-Sub-Install perl-Symbol perl-Sys-Hostname perl-Sys-Syslog perl-Term-ANSIColor perl-Term-Cap perl-Term-Complete perl-Term-ReadLine perl-Term-Size-Perl perl-Term-Table perl-Test perl-Test-Harness perl-Test-Simple perl-Text-Abbrev perl-Text-Balanced perl-Text-Diff perl-Text-Glob perl-Text-ParseWords perl-Text-Tabs+Wrap perl-Text-Template perl-Thread perl-Thread-Queue perl-Thread-Semaphore perl-Tie perl-Tie-File perl-Tie-Memoize perl-Tie-RefHash perl-Time perl-Time-HiRes perl-Time-Local perl-Time-Piece perl-URI perl-Unicode-Collate perl-Unicode-Normalize perl-Unicode-UCD perl-User-pwent perl-autodie perl-autouse perl-base perl-bignum perl-blib perl-constant perl-debugger perl-deprecate perl-devel perl-diagnostics perl-doc perl-encoding perl-encoding-warnings perl-experimental perl-fields perl-filetest perl-if perl-inc-latest perl-interpreter perl-less perl-lib perl-libnet perl-libnetcfg perl-libs perl-local-lib perl-locale perl-macros perl-meta-notation perl-mro perl-open perl-overload perl-overloading perl-parent perl-perlfaq perl-ph perl-podlators perl-sigtrap perl-sort perl-srpm-macros perl-subs perl-threads perl-threads-shared perl-utils perl-vars perl-version perl-vmsish pkgconf pkgconf-m4 pkgconf-pkg-config pyproject-srpm-macros python-srpm-macros qt5-srpm-macros redhat-rpm-config rust-srpm-macros sombok systemtap-sdt-devel zip zlib perl-CPAN-DistnameInfo perl-Encode-Locale perl-Term-Size-Any perl-TermReadKey perl-Unicode-LineBreak
yum clean all
## 變更核心參數
echo "fs.file-max = 16384" >> /etc/sysctl.conf
### 關閉Linux地址空間隨機, 解決 DBT3534W
echo "kernel.randomize_va_space = 0" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.d/gcb.conf /etc/sysctl.conf
# 解壓安裝包並安裝 DB2
cd /source
tar -xzf v9.7fp7_linuxx64_server.tar.gz
vi /source/server/db2_install.rsp
- /source/server/db2_install.rsp
** Response File for ESE
** Also creates and starts db2 instance and makes entry in /etc/services
** Configures all required instance-level parameters except SYSMON_GROUP, which must still be set manually
** Additional DB2 work is still required after Commerce instance creation
PROD = ENTERPRISE_SERVER_EDITION
FILE = /opt/ibm/db2/V9.7
LIC_AGREEMENT = ACCEPT ** ACCEPT or DECLINE
INSTALL_TYPE = TYPICAL ** TYPICAL, COMPACT, CUSTOM
INSTALL_TSAMP = NO ** YES or NO. Valid for root install only
INSTANCE = db2inst1
LANG = EN
db2inst1.NAME = db2inst1 ** real name of the instance
db2inst1.GROUP_NAME = db2iadm1 ** char(30) no spaces
db2inst1.HOME_DIRECTORY = /home/db2inst1 ** char(64) no spaces. Valid for root install only
db2inst1.AUTOSTART = YES ** YES or NO
db2inst1.START_DURING_INSTALL = NO ** YES or NO
db2inst1.SVCENAME = db2c_db2inst1 ** BLANK or char(14). Reserved for root install only
db2inst1.PORT_NUMBER = 50000 ** 1024 - 65535, Reserved for root install only
db2inst1.TYPE = ESE ** ESE WSE STANDALONE CLIENT
db2inst1.AUTHENTICATION = SERVER ** CLIENT, SERVER, or SERVER_ENCRYPT
db2inst1.FENCED_USERNAME = db2fenc1 ** char(8) no spaces, no upper case letters
db2inst1.FENCED_GROUP_NAME = db2fadm1 ** char(30) no spaces
db2inst1.FENCED_HOME_DIRECTORY = /home/db2fenc ** char(64) no spaces
db2inst1.DFTDBPATH = /db2 ** any valid path
db2inst1.DFT_MON_BUFPOOL = ON ** ON or OFF
db2inst1.DFT_MON_LOCK = ON ** ON or OFF
db2inst1.DFT_MON_SORT = ON ** ON or OFF
db2inst1.DFT_MON_STMT = ON ** ON or OFF
db2inst1.DFT_MON_TABLE = ON ** ON or OFF
db2inst1.DFT_MON_UOW = ON ** ON or OFF
db2inst1.DFT_MON_TIMESTAMP = ON ** ON or OFF
db2inst1.INSTANCE_MEMORY = AUTOMATIC ** AUTOMATIC or a number in range [0, 1000000] for 32-bit and [0, 68719476736] for 64-bit
db2inst1.HEALTH_MON = OFF ** default is ON; ON or OFF
db2inst1.SHEAPTHRES = 50000 ** 250 - 2097152
db2inst1.SPM_NAME = NULL ** BLANK or char(8)
db2inst1.SYSADM_GROUP = db2iadm1 ** BLANK or char(30)
db2inst1.DB2BIDI = ON ** BLANK, 0, 1, YES, NO, ON, OFF, Y, N, TRUE, FALSE, T or F
db2inst1.DB2_PARALLEL_IO = * ** BLANK, * or 0-4095,0-4095,...
db2inst1.DB2_INLIST_TO_NLJN = YES ** BLANK or YES, NO
db2inst1.DB2_USE_ALTERNATE_PAGE_CLEANING = ON ** BLANK or ON, OFF
db2inst1.DB2_WORKLOAD = WC ** BLANK, SAP
db2inst1.DB2COMM = TCPIP
db2inst1.PASSWORD = datao
db2inst1.FENCED_PASSWORD = datao
DAS_PASSWORD = datao
DAS_USERNAME = dasusr1 ** char(8) no spaces, no upper case letters
DAS_GROUP_NAME = dasadm1 ** char(30) no spaces
## 建議可以在這邊做快照
groupadd -g 700 db2iadm1 &&\
groupadd -g 701 db2fadm1 &&\
groupadd -g 702 dasadm1 &&\
useradd -u 700 -g db2iadm1 -m -d /home/db2inst1 db2inst1 &&\
useradd -u 701 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 &&\
useradd -u 702 -g dasadm1 -m -d /home/dasusr1 dasusr1 &&\
cd /source/server
./db2prereqcheck &&\
./db2setup -r /source/server/db2_install.rsp
# /opt/IBM/db2/V9.7/instance/db2icrt -u db2fenc1 db2inst1
chown db2inst1: /db2
echo "export DB2DIR=/opt/ibm/db2/V9.7" >> /home/db2inst1/.bashrc
echo "export PATH=\$DB2DIR/bin:\$PATH" >> /home/db2inst1/.bashrc
echo "export LD_LIBRARY_PATH=\$DB2DIR/lib:\$LD_LIBRARY_PATH" >> /home/db2inst1/.bashrc
安裝完成訊息
Post Install Recommendations
-----------------------------
Required steps:
You can connect to the DB2 instance "db2inst1" using the port number "50000". Record it for future reference.
In order to start using DB2 you need to logon using a valid user ID such as the DB2 instance owner's ID "db2inst1".
Optional steps:
Some features, such as OS-based authentication, DB2 High Availability, and configuring the DB2 Advanced Copy Services (ACS) directory are available only in root installations. Also, reserving service names for TCP/IP remote connection or DB2 Text Search is available only in root installations. To enable these features and abilities in non-root installations, run the db2rfe script as the root user with a configuration file. See /opt/ibm/db2/V9.7/instance/db2rfe.cfg for an example of the configuration file.
To start using the DB2 instance "root", you must set up the DB2 instance environment by sourcing db2profile (for Bourne or Korn shell) or db2cshrc (for C shell) in the sqllib directory with the command ". $HOME/sqllib/db2profile" or "source $HOME/sqllib/db2cshrc". $HOME represents the home directory of the DB2 instance. You can also open a new login window of the DB2 instance user.
To validate your installation files, instance, and database functionality, run the Validation Tool, /opt/ibm/db2/V9.7/bin/db2val. For more information, see "db2val" in the DB2 Information Center.
Refer to "What's new" http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.wn.doc/doc/c0052035.html in the DB2 Information Center to learn about the new functions for DB2 V9.7.
Open First Steps by running "db2fs" using a valid user ID such as the DB2 instance owner's ID. You will need to have DISPLAY set and a supported web browser in the path of this user ID.
Verify that you have access to the DB2 Information Center based on the choices you made during this installation. If you performed a typical or a compact installation, verify that you can access the IBM Web site using the internet. If you performed a custom installation, verify that you can access the DB2 Information Center location specified during the installation.
You should ensure that you have the correct license entitlements for DB2 products and features installed on this machine. Each DB2 product or feature comes with a license certificate file (also referred to as a license key) that is distributed on an Activation CD, which also includes instructions for applying the license file. If you purchased a base DB2 product, as well as, separately priced features, you might need to install more than one license certificate. The Activation CD for your product or feature can be downloaded from Passport Advantage if it is not part of the physical media pack you received from IBM. For more information on licensing, search the Information Center (http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp) using terms such as "licensing" or "db2licm".
DB2 Setup log file finished at: Mon 01 Jul 2024 02:56:44 PM CST CST
============================================================
匯入 DB2 授權檔
- 匯入 license 必須使用 DB Instance 的帳號
- 授權檔可從檔名區分不同類型
- db2aese_c.lic - DB2 Advanced Enterpriese Server Edition(aese), CPU License type(_c)
- db2ese_c.lic - DB2 Enterpriese Server Edition(ese), CPU License type(_c)
- db2wse_c.lic - DB2 Workgroup Server Edition(wse),CPU License type(_c)
- db2aese_t.lic - DB2 Advanced Enterpriese Server Edition(aese), Trial License type(_t)
- V9.1 與 V9.7 的授權不可互用
# 匯入授權
db2licm -a db2/license/db2aese_c.lic
# 檢視授權資訊
db2licm -l
建立資料庫
mkdir -p /db2/data/swjdb
su - db2inst1
db2start
db2 create db swjdb on /db2/data/swjdb/
db2 connect to swjdb
db2 update dbm cfg using DFTDBPATH /db2/data/swjdb/
db2 disconnect current
建立 daemon
開機時啟動
sudo vi /usr/local/bin/cunstom_startup_script.sh
sudo vi /etc/systemd/system/cunstom_startup.service
sudo chmod +x /usr/local/bin/cunstom_startup_script.sh
sudo systemctl start cunstom_startup_script.service
sudo systemctl enable cunstom_startup.service
- /usr/local/bin/cunstom_startup_script.sh
#!/bin/bash
su - db2inst1 -c db2start
- /etc/systemd/system/cunstom_startup.service
[Unit]
Description=My Startup Service
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/cunstom_startup_script.sh
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
關機時關閉
sudo systemctl enable cunstom_shutdown.service
- /usr/local/bin/cunstom_shutdown_script.sh
#!/bin/bash
su - db2inst1 -c db2stop
- /etc/systemd/system/cunstom_shutdown.service
[Unit]
Description=My Shutdown Service
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/cunstom_shutdown_script.sh
RemainAfterExit=true
[Install]
WantedBy=halt.target reboot.target shutdown.target
防火牆設定
firewall-cmd --permanent --add-port=50000/tcp
錯誤處理
DBI1130E The IBM Tivoli System Automation for Multiplatforms (SA MP)
could not be installed or updated because system prerequisites
were not met. See the log file /tmp/prereqSAM.log.26897 for details.
DBI1130E The IBM Tivoli System Automation for Multiplatforms (SA MP)
could not be installed or updated because system prerequisites
were not met. See the log file /tmp/prereqSAM.log.19808 for details
DBI1130E The IBM Tivoli System Automation for Multiplatforms (SA MP)
could not be installed or updated because system prerequisites
were not met. See the log file /tmp/prereqSAM.log.20636 for details.
DBI1130E The IBM Tivoli System Automation for Multiplatforms (SA MP)
could not be installed or updated because system prerequisites
were not met. See the log file /tmp/prereqSAM.log.26897 for details.
參考資料