LoginSignup
2
2

More than 5 years have passed since last update.

DB2DBA: 応答ファイルでDB2のインストールを自動化する

Last updated at Posted at 2018-03-25

GUIのセットアップウィザードによるインストールはdeveloperWorks等で説明されているので、今回は応答ファイルを利用したインストールを解説してみます。応答ファイルにDB2インストール時の設定項目や導入コンポーネントをあらかじめ指定しておくことで、GUIによるユーザーの操作なしにインストールを行うことが出来ます。

なお、類似の非対話的なインストール手段としてdb2_installコマンドが提供されていましたが、これはDB2 10.1より非推奨の機能となっています。

注意

インストーラの入手方法やSAMPLEデータベースの作成方法などは各所で解説されているので省略します。

検証環境

  • DB2 11.1 Developer-C Edition
    • Express-Cでも手順は同様
  • VirtualBox 5.2.3
  • Vagrant 2.0.3
  • Ubuntu Linux 16.04.4 64-bit (ubuntu/xenial64)
PS C:\Users\svc34> vagrant box list
ubuntu/xenial64 (virtualbox, 20180316.0.0)

インストール手順

事前準備

前提条件の検査

インストーラに含まれるdb2prereqcheckにより、DB2が必要とするライブラリの有無を事前にチェックすることが出来ます。

vagrant@ubuntu-xenial:/tmp/server_dec$ ./db2prereqcheck -v 11.1.3.3

==========================================================================

Checking prerequisites for DB2 installation. Version "11.1.3.3". Operating system "Linux"

Validating "Linux distribution " ...
   Required minimum "UBUNTU" version: "14.04"
   Actual version: "16.04"
   Requirement matched.

Validating "kernel level " ...
   Required minimum operating system kernel level: "2.6.16".
   Actual operating system kernel level: "4.4.0".
   Requirement matched.
ERROR:
   The 'strings' utility that is used to detect prerequisite libraries
   is not present on this system.  Please use your package or software
   manager to install the GNU Binary Utilities.

Validating "C++ Library version " ...
   Required minimum C++ library: "libstdc++.so.6"
   Standard C++ library is located in the following directory: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21".
DBT3512W  The db2prereqcheck utility failed to determine the currently-installed version of the C++
standard library, libstdc++.
   Requirement matched.

Validating "libaio.so version " ...
DBT3552E  The db2prereqcheck utility failed to open the libaio.so.1 file. Command output: "libaio.so.1: cannot open shared object file: No such file or directory".
DBT3520E  The db2prereqcheck utility could not find the library file libaio.so.1.
   ERROR : Requirement not matched.

Validating "libnuma.so version " ...
DBT3610I  The db2prereqcheck utility successfully loaded the libnuma.so.1 file.
   Requirement matched.

Validating "/lib/i386-linux-gnu/libpam.so*" ...
   DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/i386-linux-gnu/libpam.so*".
   WARNING : Requirement not matched.
Requirement not matched for DB2 database "Server" . Version: "11.1.3.3".
Summary of prerequisites that are not met on the current system:
   DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/i386-linux-gnu/libpam.so*".


DBT3520E  The db2prereqcheck utility could not find the library file libaio.so.1.

いくつかのライブラリが不足しており、一部は32-bitバージョンを要求されています。

ライブラリのインストール

以下の手順でUbuntuに32-bitバージョンのライブラリを導入します。

sudo dpkg --add-architecture i386
sudo apt-get update 
sudo apt-get install binutils libaio1 libstdc++6:i386 libpam0g:i386

再検査

vagrant@ubuntu-xenial:/tmp/server_dec$ ./db2prereqcheck -v 11.1.3.3

==========================================================================

Checking prerequisites for DB2 installation. Version "11.1.3.3". Operating system "Linux"

Validating "Linux distribution " ...
   Required minimum "UBUNTU" version: "14.04"
   Actual version: "16.04"
   Requirement matched.

Validating "kernel level " ...
   Required minimum operating system kernel level: "2.6.16".
   Actual operating system kernel level: "4.4.0".
   Requirement matched.

Validating "C++ Library version " ...
   Required minimum C++ library: "libstdc++.so.6"
   Standard C++ library is located in the following directory: "/usr/lib/x86_64-linux-gnu/libstdc++.
so.6.0.21".
   Actual C++ library: "CXXABI_1.3.1"
   Requirement matched.


Validating "32 bit version of "libstdc++.so.6" " ...
   Found the 32 bit "/usr/lib/i386-linux-gnu/libstdc++.so.6" in the following directory "/usr/lib/i3
86-linux-gnu".
   Requirement matched.

Validating "libaio.so version " ...
DBT3553I  The db2prereqcheck utility successfully loaded the libaio.so.1 file.
   Requirement matched.

Validating "libnuma.so version " ...
DBT3610I  The db2prereqcheck utility successfully loaded the libnuma.so.1 file.
   Requirement matched.

Validating "/lib/i386-linux-gnu/libpam.so*" ...
   Requirement matched.
DBT3533I  The db2prereqcheck utility has confirmed that all installation prerequisites were met.

OK.

インストール

応答ファイルの作成

インストーラにサンプルが含まれているので、これをベースに応答ファイルを作成します。

vagrant@ubuntu-xenial:/tmp$ cp server_dec/db2/linuxamd64/samples/db2server.rsp ./
vagrant@ubuntu-xenial:/tmp$ chmod u+w db2server.rsp
vagrant@ubuntu-xenial:/tmp$ vi db2server.rsp

サンプリには多くの設定項目がありますが、デフォルト構成でインストールするために最低限編集が必要なものは以下の3つのみです。言語パックを導入する場合はLANG = JPを指定してください。その他細かい設定が必要な場合は、参考資料の欄にマニュアルのリンクを載せているので参考にしてください。

  • Before
LIC_AGREEMENT             = DECLINE         ** ACCEPT or DECLINE
DB2_INST.PASSWORD         = Replace with your password ** Valid for root installation only
*DB2_INST.FENCED_PASSWORD =                 ** char(8)
  • After
LIC_AGREEMENT             = ACCEPT          ** ACCEPT or DECLINE
DB2_INST.PASSWORD         = password        ** Valid for root installation only
DB2_INST.FENCED_PASSWORD  = password        ** char(8)

セットアップウィザードでのDB2インストール時に、そこでの設定を応答ファイルとして出力してテンプレートとして利用することもできます。

インストールの実行

作成した応答ファイルを指定してdb2setupを実行します。

vagrant@ubuntu-xenial:/tmp/server_dec$ sudo ./db2setup -r /tmp/db2server.rsp
DBI1191I  db2setup is installing and configuring DB2 according to the
      response file provided. Please wait.


The execution completed with warnings.

For more information see the DB2 installation log at "/tmp/db2setup.6008.log".

警告が出ていますが、デフォルトの構成ではUbuntuでサポートされないTSAMPコンポーネントをインストールしようとして失敗したためのようです。INSTALL_TYPECOMPACTもしくはCUSTOMにすれば、必要なコンポーネントのみインストール出来ます。また、DB2 Express-CであればTSAMPを含まないためこの警告は発生しません。

WARNING: DBI20105E  An error occurred while installing the following file set:
"TSAMP". Because these files were not successfully installed, functionality
that depends on these files might not work as expected.

これで応答ファイルによるDB2のインストールは完了です。デフォルトインスタンスのdb2inst1が作成されています。

db2inst1@ubuntu-xenial:~$ db2 attach to db2inst1

   Instance Attachment Information

 Instance server        = DB2/LINUXX8664 11.1.3.3
 Authorization ID       = DB2INST1
 Local instance alias   = DB2INST1

参考資料

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2