DB2 10.1のインストール

久しぶりに仮想環境でDB2をインストールしてみました。
OSはvagrantでささっと作ってしまいます。
OS作成作業が何かと面倒でしたが、vagrantで本当に楽にできてしまいます。

作業はMac OSX 10.8
VirtualBoxとはインストール済み、
vagranthttp://www.vagrantup.com/からdmgでインストール、
あとはコマンドラインでバシバシ打つのみ。



vagrantcentosを拾ってくるw

 $ vagrant box add centos64x64db2 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
 Downloading or copying the box...
 Extracting box...te: 458k/s, Estimated time remaining: --:--:--)
 Successfully added box 'centos64x64db2' with provider 'virtualbox'!

Vagrantfileファイルを作る

 $ mkdir centos64x64db2
 
 $ cd centos64x64db2
 
 $ vagrant init centos64x64db2
 A `Vagrantfile` has been placed in this directory. You are now
 ready to `vagrant up` your first virtual environment! Please read
 the comments in the Vagrantfile as well as documentation on
 `vagrantup.com` for more information on using Vagrant.
 
 
 $ ll
 total 16
 drwxr-xr-x   3 staff   102  6  4 18:29 .
 drwxr-xr-x+ 44 staff  1496  6  4 18:29 ..
 -rw-r--r--   1 staff  4359  6  4 18:29 Vagrantfile

Vagrantfile設定を変更

 $ vi Vagrantfile 
 
   config.vm.box = "centos64x64db2"
 
   config.vm.hostname = "centos64x64db2"
 
   config.vm.network :private_network, ip: "192.168.56.70"
 
   config.vm.provider :virtualbox do |vb|
     vb.name = "centos64x64db2"
     vb.gui = true
     vb.customize ["modifyvm", :id, "--memory", "1024"]
   end

centosを立ち上げる

 $ vagrant up
 Bringing machine 'default' up with 'virtualbox' provider...
 [default] Importing base box 'centos64x64db2'...
 [default] Matching MAC address for NAT networking...
 [default] Setting the name of the VM...
 [default] Clearing any previously set forwarded ports...
 [default] Creating shared folders metadata...
 [default] Clearing any previously set network interfaces...
 [default] Preparing network interfaces based on configuration...
 [default] Forwarding ports...
 [default] -- 22 => 2222 (adapter 1)
 [default] Running any VM customizations...
 [default] Booting VM...
 [default] Waiting for VM to boot. This can take a few minutes.
 [default] VM booted and ready for use!
 [default] Setting hostname...
 [default] Configuring and enabling network interfaces...
 [default] Mounting shared folders...
 [default] -- /vagrant

SSHでログイン

 $ vagrant ssh
 Welcome to your Vagrant-built virtual machine.

DB2をダウンロード&インストールの旅

 $ su -
 # cd /usr/local/src
 
 # mkdir db2
 
 # cd /usr/local/src/db2

DB2はexpress-c10.1 liteってやつを選んでます

ダウンロードは
http://www-06.ibm.com/software/jp/data/db2/express-c/
からログインして、
DB2 Express-C for Linux x86-64を選んで
「You can also download the files using http. 」で
ダウンロードURLを見つけましょう。
多分、以下のWGETへのURLでは有効期限もLicense的にもアウトでしょうw

 # wget 'https://www6.software.ibm.com/sdfdl/v2/regs2/db2pmopn/db2_v101/expc/Xa.2/Xb.aA_60_-ilKzNqs0mX1lZneAK8oYUwfRmbHOAFpkc5A/Xc.db2_v101/expc/ db2_v1012_linuxx64_expc_lite.tar.gz/Xd./Xf.LPr.D1vk/Xg.7062336/Xi.swg-db2expressc/XY.regsrvs/XZ.O_k6_yqIoQjdQQpa43cC6SnKSIc/db2_v1012_linuxx64_expc_lite.tar.gz'
 --2013-06-04 09:37:24--  https://www6.software.ibm.com/sdfdl/v2/regs2/db2pmopn/db2_v101/expc/Xa.2/Xb.aA_60_-ilKzNqs0mX1lZneAK8oYUwfRmbHOAFpkc5A/Xc.db2_v101/expc/ db2_v1012_linuxx64_expc_lite.tar.gz/Xd./Xf.LPr.D1vk/Xg.7062336/Xi.swg-db2expressc/XY.regsrvs/XZ.O_k6_yqIoQjdQQpa43cC6SnKSIc/db2_v1012_linuxx64_expc_lite.tar.gz
 www6.software.ibm.com をDNSに問いあわせています... 170.225.15.41
 www6.software.ibm.com|170.225.15.41|:443 に接続しています... 接続しました。
 HTTP による接続要求を送信しました、応答を待っています... 200 OK
 長さ: 472841425 (451M) [application/octet-stream]
 `db2_v1012_linuxx64_expc_lite.tar.gz' に保存中
 
 100%[===================================================>] 472,841,425  126K/s 時間 28m 30s 
 
 2013-06-04 10:06:00 (270 KB/s) - `db2_v1012_linuxx64_expc_lite.tar.gz' へ保存完了 [472841425/472841425]
 
 # ll
 total 461764
 -rw-r--r-- 1 root root 472841425 Dec  4 03:12 db2_v1012_linuxx64_expc_lite.tar.gz
 
 # tar xzvf db2_v1012_linuxx64_expc_lite.tar.gz 
 
 # ll
 total 461768
 -rw-r--r-- 1 root root 472841425 Dec  4 03:12 db2_v1012_linuxx64_expc_lite.tar.gz
 drwxr-xr-x 3 root root      4096 Jun  4 10:06 devinst
 
 # cd devinst/db2_v101fp2/linuxamd64/s121127/expc_lite/
 
 # ll
 total 56
 drwxr-xr-x  6 bin bin 4096 Nov 29  2012 db2
 -r-xr-xr-x  1 bin bin 5349 Nov 29  2012 db2ckupgrade
 -r-xr-xr-x  1 bin bin 5302 Nov 29  2012 db2_deinstall
 -r-xr-xr-x  1 bin bin 5172 Nov 29  2012 db2_install
 -r-xr-xr-x  1 bin bin 5136 Nov 29  2012 db2ls
 -r-xr-xr-x  1 bin bin 5154 Nov 29  2012 db2prereqcheck
 -r-xr-xr-x  1 bin bin 5154 Nov 29  2012 db2setup
 drwxr-xr-x 28 bin bin 4096 Nov 29  2012 doc
 
 # ./db2_install 
 Requirement not matched for DB2 database "Server" "". Version: "10.1.0.2". 
 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/libpam.so*". 
 
 
 DBI1324W  Support of the db2_install command is deprecated. For
       more information, see the DB2 Information Center.
 
 
  
 Default directory for installation of products - /opt/ibm/db2/V10.1
 
 ***********************************************************
 Install into default directory (/opt/ibm/db2/V10.1) ? [yes/no] 
 yes <<==YES[enter]と入力
 
 …..
 
 The execution completed successfully.
 
 For more information see the DB2 installation log at
 "/tmp/db2_install.log.2274".
 
 
 
 
 # groupadd -g 510 db2grp1
 
 # useradd -u 510 db2inst1 -g db2grp1
 
 # passwd db2inst1
 
 # groupadd -g 511 db2fgrp1
 
 # useradd -u 511 db2fenc1 -g db2fgrp1
 
 # passwd db2fenc1
 
 
 # /opt/ibm/db2/V10.1/instance/db2icrt -u db2fenc1 db2inst1
 DBI1446I  The db2icrt command is running.
 
 ...
 
 The execution completed successfully.
 
 For more information see the DB2 installation log at "/tmp/db2icrt.log.23708".
 Required: Review the following log file also for warnings or errors:
 "/tmp/db2icrt_local.log.*"
 DBI1070I  Program db2icrt completed successfully.
 
 
 # groupadd -g 512 db2asgrp
 
 # useradd -u 512 -g db2asgrp -G db2asgrp -d /home/db2as db2as
 
 # passwd db2as
 
 
 # /opt/ibm/db2/V10.1/instance/dascrt -u db2as
 DBI1070I  Program dascrt completed successfully.
 
 
 # /opt/ibm/db2/V10.1/cfg/db2ln
 
 # vi /etc/services
 
 ------------------
 #lrs-paging      3700/tcp                # LRS NetPage
 #commplex-link   5001/tcp                #
 
 # DB2 services
 db2c_DB2 3700/tcp
 db2i_DB2 5001/tcp
 ------------------
 
 # /opt/ibm/db2/V10.1/instance/db2icrt -a SERVER -u db2fenc1 db2inst1 
 DBI1446I  The db2icrt command is running.
 
 
 DB2 installation is being initialized.
 
  The instance "db2inst1" already exists. Specify a new instance name.
 
 A major error occurred during the execution that caused this program to
 terminate prematurely. If the problem persists, contact your technical service
 representative.
 
 For more information see the DB2 installation log at "/tmp/db2icrt.log.918".
 DBI1264E  Errors were encountered in running db2icrt. Please
       refer to the installation log file /tmp/db2icrt.log.918 for more
       information.
 
 Explanation: 
 
 All processed and failed operations have been saved into this log file.
 
 User response: 
 
 Do not modify this file in any way. This file is for IBM Technical
 Support reference.
 



DB2起動&DB作成等々

 # su - db2inst1
 
 
 $ db2 update database manager configuration using svcename db2c_DB2
 DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed 
 successfully.
 
 
 $ db2 get database manager configuration |grep -i svcename 
  TCP/IP Service name                          (SVCENAME) = db2c_DB2
  SSL service name                         (SSL_SVCENAME) = 
 
 
 $ db2set DB2COMM=tcpip
 
 $ db2set DB2DAS00 DB2COMM=tcpip
 
 $ db2set DB2_COMPATIBILITY_VECTOR=3F
 
 
 $ db2start
 SQL1063N  DB2START processing was successful.
 
 
 $ db2 list db directory
 SQL1031N  The database directory cannot be found on the indicated file system. 
 SQLSTATE=58031
 
 $ db2 create database testdb
 DB20000I  The CREATE DATABASE command completed successfully.
 
 
 $ 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             = /home/db2inst1
  Database release level               = f.00
  Comment                              =
  Directory entry type                 = Indirect
  Catalog database partition number    = 0
  Alternate server hostname            =
  Alternate server port number         =
 
 
 $ db2 connect to testdb
 
    Database Connection Information
 
  Database server        = DB2/LINUXX8664 10.1.2
  SQL authorization ID   = DB2INST1
  Local database alias   = TESTDB
 
 $ db2 terminate
 DB20000I  The TERMINATE command completed successfully.