cyper 2017筆記:適用於ubuntu16.04.1 + db2 10.1.0.2
##
抓緊下載v10.5fp1_linuxx64_expc.tar.gz到~/Downloads/java_soft
cd java_soft
tar xf v10.5fp1_linuxx64_expc.tar.gz
能夠看到在當前目錄下產生了一個expc目錄
cd expc
而後檢查一下是否知足了安裝條件:
./db2prereqcheck
提示java
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/libpam.so*".
按照這裏的方案http://askubuntu.com/questions/428072/64-bit-db2-10-5-missing-32-bit-libpam-and-64-bit-libaio-on-ubuntu-12-04
執行了以下命令:linux
sudo apt-get install libpam0g:i386 libaio1 ln -s /lib/i386-linux-gnu/libpam.so.0 /lib/libpam.so.0
解決c++
另外一個錯:
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6".sql
解決方案shell
Install the 32-bit libstdc++6 in the terminal command line: sudo apt-get install libstdc++6:i386數據庫
and then run the ./db2prerecheck again, you will see all the requirements are matched. ubuntu
接下來是正式安裝:
sudo ./db2_install -b /opt/ibm/db2/v10.5
或者使用sudo ./db2_setup以圖形方式安裝
方法同 v9.7
在這裏羅列一遍:
建立3個用戶組和3個用戶(並給db2inst1設置密碼)安全
useradd -m db2inst1 #-m表示建立相應的home directory sudo passwd db2inst1 useradd -m db2fenc1 sudo passwd db2fenc1 useradd -m db2das1 sudo passwd db2das1
切換成root用戶bash
su - root #建立das和instance cd /opt/ibm/db2/v10.5/instance ./dascrt -u db2das DBI1070I Program dascrt completed successfully. ./db2icrt -u db2inst1 db2inst1 DBI1070I Program db2icrt completed successfully. ./db2ilist db2inst1
切換成das用戶(由於給das分配的shell是sh而不是bash,咱們進入了原始時代(不能tab補全了,當前路徑pwd才能知道)app
root@zerorun:/opt/ibm/db2/v10.5/instance# su - db2das $ pwd /home/db2das $ ls das/ adm conv dasprofile java metadata usercshrc bin ctrl dump lib msg userprofile cfg dascshrc function log tmp $ . das/dasprofile (注意這裏的點命令,點號後面必須有空格,點至關於source命令) $ echo $PATH 。。home/db2das/das/bin:/home/db2das/das/adm $ which db2admin /home/db2das/das/bin/db2admin $ db2admin start SQL4409W The DB2 Administration Server is already active.
切換成db2inst1用戶
$ su - db2inst1 Password: db2inst1@zerorun:~$ pwd /home/db2inst1 db2inst1@zerorun:~$ ls examples.desktop sqllib db2inst1@zerorun:~$ . sqllib/db2profile db2inst1@zerorun:~$ echo $PATH 。。:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin db2inst1@zerorun:~$ which db2start /home/db2inst1/sqllib/adm/db2start db2inst1@zerorun:~$ db2start SQL1063N DB2START processing was successful.
若是db2start報錯 error while loading shared libraries: libnuma.so.1,解決"
sudo apt-get install numactl
關閉db2自動運行(先確認一下)
db2inst1@zerorun:~$ db2set
DB2AUTOSTART=YES
db2inst1@zerorun:~$ db2iauto -off db2inst1
db2inst1@zerorun:~$ db2set
建立數據庫
db2inst1@zerorun:~$ db2 "create database tpch USING CODESET UTF-8 TERRITORY CN pagesize 32 k"
DB20000I The CREATE DATABASE command completed successfully.
這一步很是慢,硬盤燈狂閃,須要10分鐘
設置遠程能夠訪問DB:
db2inst1@zerorun:~$ db2set
db2inst1@zerorun:~$ db2set DB2COMM=TCPIP
db2inst1@zerorun:~$ db2set
DB2COMM=TCPIP
db2inst1@zerorun:~$ db2 get dbm cfg |grep SVCENAME
TCP/IP Service name (SVCENAME) =
SSL service name (SSL_SVCENAME) =
修改默認的端口號爲60000
db2inst1@zerorun:~$ db2 update dbm cfg using SVCENAME 60000
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
SQL1362W One or more of the parameters submitted for immediate modification
were not changed dynamically. Client changes will not be effective until the
next time the application is started or the TERMINATE command has been issued.
Server changes will not be effective until the next DB2START command.
db2inst1@zerorun:~$ db2 get dbm cfg |grep SVCENAME
TCP/IP Service name (SVCENAME) = 60000
SSL service name (SSL_SVCENAME) =
db2inst1@zerorun:~$
(這個命令是如此之長, 注意SVCENAME是端口號的意思,咋不用PORT呢!)
db2inst1@zerorun:~$ clpplus -nw db2inst1/db2@localhost:60000/tpch
CLPPlus: Version 1.6
Copyright (c) 2009, 2011, IBM CORPORATION. All rights reserved.
Database Connection Information :
---------------------------------
Hostname = localhost
Database server = DB2/LINUXX8664 SQL10051
SQL authorization ID = db2inst1
Local database alias = TPCH
Port = 60000
SQL> set timi on (這一步是讓DB2顯示SQL語句的執行時間,同set timing on)
SQL> select sysdate from dual;
ERROR near line 1:
SQL0204N "DB2INST1.DUAL" is an undefined name.
SQL> select sysdate from SYSIBM.dual;
1
---------------------
2014-12-21 23:36:44
Elapsed time: 28 millisecond(s)
SQL>
Win7下的安裝
抓緊下載C:\Users\IBM_ADMIN\DownloadDirector\v10.5fp1_winx64_expc.exe
雙擊自解壓.
而後雙擊setup.exe
安裝產品>安裝新產品>下一步 >贊成(此步有BUG!)
>選擇自定義安裝,不要選擇典型安裝(裝出來命令行全是中文,很不方便) > 下一步
>下一步(把簡體中文從右邊移除!!!!!!!!!!)
>若干下一步
>取消設置通知!
>取消啓用操做系統安全性
>完成
裝好後, 打開開始菜單 > IBM DB2 DB2COPY1> DB2命令窗口 - Adminstrator
注意在這個菜單上面shift右鍵, 而後選擇run as different user,輸入db2admin/adb2admin登陸後
而後
db2sampl.exe建立sample數據庫,
或者db2sampl.exe -force(若是db已經存在)
C:\IBM\SQLLIB\BIN>db2sampl.exe -force Creating database "SAMPLE"... Existing "SAMPLE" database found... Dropping and recreating database "SAMPLE"... Connecting to database "SAMPLE"... Creating tables and data in schema "DB2ADMIN"... Creating tables with XML columns and XML data in schema "DB2ADMIN"... 'db2sampl' processing complete. C:\IBM\SQLLIB\BIN>
校驗:
db2
connect to sample
select * from staff
不然默認建立的數據庫的schema是操做系統的用戶,使用起來很不方便.
參考: http://askubuntu.com/questions/428072/64-bit-db2-10-5-missing-32-bit-libpam-and-64-bit-libaio-on-ubuntu-12-04 http://www.tuicool.com/articles/FbaYbm