linux下安裝db2
A. 求助在linux下安裝DB2 v10.5出現的問題
0.環境信息
os: Red Hat Enterprise Linux Server release 6.0 (Santiago)
DB: v10.5fp1_linuxx64_expc
1、部分包缺失,32位包缺失
安裝之前一定要先把下面的包直接補充安裝一下,默認是不安裝的,另外要記得修改配置,直接連32位包也一並安裝上。RH6.0以後,好多32包都默認不安裝的,會引發不少問題。
echo 'multilib_policy=all' >> /etc/yum.conf
yum install -y glibc* libstdc*
2、關閉iptables和selinux
service iptables stop
sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
(或 vi /etc/selinux/config
[root@TSMClt expc]# cat /etc/selinux/config |grep SELINUX=
# SELINUX= can take one of these three values:
SELINUX=disabled
)
3、安裝之前,做一下db2precheck,檢查日誌
4、libpam.so問題,不一定遇得上,看人品。
db2setup安裝過程中,報錯內容如下:
Validating "/lib/libpam.so*" ...
DBT3514W The db2prereqcheck utility failed to find the following 32-bit libr
ary file: "/lib/libpam.so*".
WARNING : Requirement not matched.
解決辦法如下:
[root@TSMClt expc]# find / -name libpam.so*
/usr/lib64/libpam.so
/lib64/libpam.so.0.82.2
/lib64/libpam.so.0
很明顯,缺失32位包
[root@TSMClt expc]# rpm -qf /usr/lib64/libpam.so
pam-devel-1.1.1-4.el6.x86_64
[root@TSMClt expc]# rpm -qf /lib64/libpam.so.0.82.2
pam-1.1.1-4.el6.x86_64
[root@TSMClt expc]# rpm -qf /lib64/libpam.so.0
pam-1.1.1-4.el6.x86_64
yum install -y pam*
B. 虛擬機Linux上部署DB2pureScale過程
在Linux 操作系統 中,可在虛擬機上搭建DB2 pureScale,那麼搭建的步驟是怎麼樣的呢?DB2 pureScale又有什麼用呢?下面隨我一起來了解下Linux系統如何在虛擬機上部署DB2 pureScale。
在虛擬機Linux上部署DB2pureScale實踐過程
1、環境准備
硬體環境:3 台 x86-64虛擬機,內存要求 1.5G 或以上(主要針對虛擬機,內存過低會造成資料庫實例啟動失敗)
操作系統:Suse Linux Enterprise Server 11.3
DB2 版本:DB2 v10.5
機器名:node01 node02 node03
IP:192.168.18.201 192.168.18.202 192.168.18.203
網關:192.168.18.2
利用iscsi服務來做共享存儲功能,其中node01 作為 iscsi 的 Server,node01、node02和 node03 作為 iscsi Client,這樣三台虛擬機上都能看到相同的磁碟了(按照developer workers上的 文章 :非 InfiniBand 環境下搭建 DB2 pureScale,我用DB2 v10.5時啟動實例失敗,可能10.5做了限制,CF與member在同一台機器啟動失敗,幫多了一台虛擬機)。
2、操作系統安裝:
Node01預留出一塊分區,不進行格式化(文件類型為0x83 Linux)做為 pureScale 集群的 Sharing Disk 使用,Node02與Node03跟node01 其它 相同就可,
安裝必要的包:
libstdc++(32 位和 64 位庫)
glibc(32 位和 64 位庫)
cpp
gcc
gcc-c++
kernel-source
binutils
ksh-93u-0.8.1
openssh
ntp
完成SUSE 11 SP3的安裝。
驗證:檢查/lib/moles/3.0.76-0.11-default/build/include/linux有無autoconf.h,如果沒有autoconf.h,安裝DB2時會報Compiling GPL :.......Failure錯誤。
解決 方法 :cp –v /usr/src/linux-3.0.76-0.11-obj/x86_64/default/include/generated /lib/moles/3.0.76-0.11-default/build/include/linux
3、添加用戶和用戶組
三台機器全部執行如下命令(如果不做特殊說明,以#表示root身份登錄,以$表示db2inst1身份,以下相同)。
#groupadd -g 1001 db2fadm1
#groupadd -g 1002 db2iadm1
#useradd -g db2fadm1 -u 1001 -m -d /home/db2fenc1 -p db2fenc1 db2fenc1
#useradd -g db2iadm1 -u 1002 -m -d /home/db2inst1 -p db2inst1 db2inst1
#mkdir /root/.ssh
# su - db2inst1 -c "mkdir -p /home/db2inst1/.ssh"
4、配置ssh 信任連接
ssh信任通俗的說就是直接ssh不用輸入密碼
在/etc/hosts添加另外兩台機器的IP地址及機器名(確保3台機器名與ip地址全部出現在hosts文件中)
例如我的機器hosts如下:
127.0.0.1 localhost
192.168.18.201 node01.site node01
192.168.18.202 node02.site node02
192.168.18.203 node03.site node03
node01執行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id01
#scp /root/.ssh/id01 node02:/root/.ssh
#scp /root/.ssh/id01 node03:/root/.ssh
#su - db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id01
$scp /home/db2inst1/.ssh/id01 node02:/home/db2inst1/.ssh
$scp /home/db2inst1/.ssh/id01 node03:/home/db2inst1/.ssh
node02執行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id02
#scp /root/.ssh/id02 node01:/root/.ssh/
#scp /root/.ssh/id02 node03:/root/.ssh/
#su - db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id02
$scp /home/db2inst1/.ssh/id02 node01:/home/db2inst1/.ssh/
$scp /home/db2inst1/.ssh/id02 node03:/home/db2inst1/.ssh/
node03執行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id03
#scp /root/.ssh/id03 node01:/root/.ssh
#scp /root/.ssh/id03 node02:/root/.ssh
#su - db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id03
$scp /home/db2inst1/.ssh/id03 node01:/home/db2inst1/.ssh/
$scp /home/db2inst1/.ssh/id03 node02:/home/db2inst1/.ssh/
分別在node01、node02、node03執行如下命令
#cd /root/.ssh
#cat id01 id02 id03 > authorized_keys
#chmod 600 authorized_keys
#su - db2inst1
$cd /home/db2inst1/.ssh
$ cat id01 id02 id03 > authorized_keys
測試是否配置成功
3台機器分別以root與db2inst1執行:
#ssh node01 ls
#ssh node02 ls
#ssh node03 ls
#su - db2inst1
$ssh node01 ls
$ssh node02 ls
$ssh node03 ls
確保不用輸入密碼,則配置成功。
5、ISCSI 共享存儲配置
Iscsi server端配置(node01上執行):
修改/etc/ietd.conf,添加如下內容:
Target iqn.2014-03.node01.site:scsidisk01
Lun 0 Path=/dev/sda4,Type=fileio
注意:我的未分區硬碟為/dev/sda4,你的可能不一樣的@_@~~~~
添加自啟動
#chkconfig -a iscsitarget
檢查是否成功
#chkconfig -l iscsitarget
結果:iscsitarget 0:off 1:off 2:off 3:on 4:off 5:on 6:off
重啟iscsitarget服務
# /etc/init.d/iscsitarget restart
iscsi client端配置(node01、node02、node03執行,):
iscsitarget文件內容如下:
#! /bin/sh
### BEGIN INIT INFO
# Provides: iscsiclsetup
#node02與node03上如果未裝iscsitarget需將下下行的$iscsitarget
# Required-Start: $network $syslog $iscsitarget $remote_fs smartd
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: ISCSI client setup
### END INIT INFO
case "$1" in start)
iscsiadm --mode discoverydb --type sendtargets --portal 192.168.18.201 --discover
iscsiadm --m node --targetname iqn.2014-03.node01.site:scsidisk01 --portal 192.168.18.201:3260 --login
;;
stop)
iscsiadm -m node -T iqn.2014-03.node01.site:scsidisk01 -p 192.168.18.201 --logout
;;
restart) ## Stop the service and regardless of whether it was ## running or not, start it again.
$0 stop
$0 start
;;
*)
Esac
保存後執行:#/etc/init.d/iscsiclient restart
驗證iscsiclient是否啟動成功:
#fdisk -l
檢查有無/dev/sdb出現
6、配置Linux環境變數
/etc/profie.local添加內容
alias sl='tail -f /var/log/messages'
alias fc='fcslogrpt /var/log/messages'
export PATH=/root/bin:/usr/sbin/rsct/bin:/opt/ibm/db2/v10.5/bin:$PATH
export PATH=/usr/lpp/mmfs/bin:$PATH
export DB2USENONIB=TRUE
export DB2_CFS_GPFS_NO_REFRESH_DATA=true
然後執行# . /etc/profile.local,完成後你就可以安裝purescale了,我猜測應該是設置了變數DB2USENONIB,使purescale不再要求你強制InfiniBand或萬兆網卡,使我等窮人可以有機會玩這種高檔、洋氣、上檔次的資料庫。。。
7、DB2 V10.5 的安裝:
node01:~/server_t # ./db2_install
DBI1324W Support of the db2_install command is deprecated. For
more information, see the DB2 Information Center.
Default directory for installation of procts - /opt/ibm/db2/V10.5
***********************************************************
Install into default directory (/opt/ibm/db2/V10.5) ? [yes/no]
yes
Specify one of the following keywords to install DB2 procts.
SERVER
CONSV
EXP
CLIENT
RTCL
Enter "help" to redisplay proct names.
Enter "quit" to exit.
***********************************************************
server
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no]
Yes
曾經出現的錯誤:
ERROR: An error occurred while compiling IBM General Parallel File System
(GPFS) Portability Layer (GPL) on host "node01". Return code "2". GPL
compilation log file location "/tmp/compileGPL.log.000". The GPFS file system
cannot be mounted properly until the GPL mole is successfully compiled on
this host. For details, see the specified GPL compilation log. After fixing
the problems shown in the log file, re-run the DB2 installer. For information
regarding the GPFS GPL mole compile, see DB2 Information Center.
Compiling GPL :.......Failure
ERROR: A major error occurred while installing "DB2 Server Edition " on this
computer.
解決方案:
查看錯誤日誌:compileGPL.log.000,為以下內容:
cd /usr/lpp/mmfs/src/config; ./configure --genenvonly; if [ $? -eq 0 ]; then /usr/bin/cpp -P def.mk.proto > ./def.mk; exit $? || exit 1; else exit $?; fi
手工執行時會發現在./configure --genenvonly; 這一步報找不到
/usr/bin/diff: /lib/moles/3.0.76-0.11-default/build/include/linux/autoconf.h: No such file or directory
Kernel source tree does not have the correct autoconf.h file.
See /usr/lpp/mmfs/src/README for further information
手工拷唄一下autoconf.h文件即可
#cp –v /usr/src/linux-3.0.76-0.11-obj/x86_64/default/include/generated/autoconf.h /lib/moles/3.0.76-0.11-default/build/include/linux/
GPFS 文件系統配置與掛載
方法1:使用db2cluster_prepare
node01上執行:
#/opt/ibm/db2/v10.5/instance/db2cluster_prepare -instance_shared_dev /dev/sdb
DBI1446I The db2cluster_prepare command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 1
Total estimated time for all tasks to be performed: 60 second(s)
Task #1 start
Description: Creating IBM General Parallel File System (GPFS) Cluster and Filesystem
Estimated time 60 second(s)
Task #1 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2cluster_prepare.log".
DBI1070I Program db2cluster_prepare completed successfully.
此時df -l查看一下會發現多了一個掛載點
node01:/opt/ibm/db2/V10.5/instance # df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 19599036 8122392 10481060 44% /
udev 958688 120 958568 1% /dev
tmpfs 958688 76 958612 1% /dev/shm
/dev/sda3 10327940 154460 9648836 2% /home
/dev/db2fs1 15728640 627712 15100928 4% /db2sd_20140401103940
曾經出現報錯:
DBI20022E The DB2 installer detected that the variable record "GPFS_CLUSTER" is
defined in the global registry. However, the GPFS cluster does not exist on
host "node01".
Creating IBM General Parallel File System (GPFS) Cluster and Filesystem :.......Failure
查看/tmp/ibm.db2.cluster.GuOypP發現有如下內容報錯:
014-04-01-10.26.12.358494+480 I5385E400 LEVEL: Warning
PID : 7469 TID : 139670848014112 PROC : db2cluster
INSTANCE: NODE : 000
HOSTNAME: node01
FUNCTION: DB2 UDB, oper system services, sqloMessage, probe:1
MESSAGE : Cannot obtain registry variables
DATA #1 : Hexmp, 4 bytes
0x00007FFF17631758 : B400 0F87
解決方案:由於此前我在此機器上試過N次db2cluster_prepare,包括V9.8、V10.1,V10.5安裝,導致全局注冊表變數沒有刪除干凈,使用db2greg -mp
V,GPFS_CLUSTER,NAME,db2cluster_20140403105617.site,-,DB2_CREATED將其刪除。
#cp -v /var/db2/global.reg /var/db2/global.reg_20140401
#db2delgreg -delvarrec service= GPFS_CLUSTER
總結 :db2cluster_prepare這個命令失敗時
檢查iscsi client是否准備好,fdisk -l查看一下是否有/dev/sdb
全局注冊表變數是否未刪除干凈 ,db2greg -mp查看
檢查一下是否tsa的domain存在,lsrpdomain,使用rmrpdomain將其刪掉,如果其node為活動需先將其node停掉。具體參考tsa相關命令,
檢查一下gpfs cluster domain是否未清理干凈,如果未清理干凈,需要使用將fs、nsd、node清理掉,具體命令參考gpfs信息中心。
方法2:手工掛載GPFS
遇到過使用db2cluster_prepare時無法成功,手工安裝(不確定是否遇到了 傳說 中的bug)。
創建cluster,不加-filesystem -disk選項:
node01:
#db2cluster -cfs -create -domain mydomain -host node01
#db2cluster -cfs -add -host node02
# db2cluster -cfs -add -host node03
說明:上面如果不出故障當然可以加上-filesystem –disk參數,當然也可以用mmaddnode –N XXX來添加節點
添加許可協議:
提供兩種方法
#mmchlicense server --accept -N node01,node02,node03
#/opt/ibm/db2/v10.5/bin/db2cluster -cfs -add -license
創建nsd:任意node執行
編寫newNSD文件內容如下
%nsd:
device=/dev/sdb
nsd=nsd1
usage=dataAndMetadata
#mmcrnsd -F /tmp/newNSD (-v no)
如果報mmcrnsd: Disk device sdb refers to an existing NSD,而使用mmlsnsd 又查找不到相應的nsd,添加-v no可以跳過此驗證。
#mmlsnsd 查看創建的nsd名稱,記下,在第3步時需要用到.
創建Cluster File System並掛載
啟動所有node,任意node執行
#mmstartup -a
#mmgetstate -a
確保所有node全部啟動成功為active
# mmcrfs -T /db2sd_20140401 db2sd_20140401 nsd1(此處的nsd1為第2步的nsd名稱)
#mmmount all -a
--曾經出現的錯誤:mmstartup -a無響應
,查看日誌/var/adm/ras/mmfs.log.previous
Tue Apr 1 22:02:11 CST 2014: runmmfs starting
Removing old /var/adm/ras/mmfs.log.* files:
Unloading moles from /lib/moles/3.0.76-0.11-default/extra
runmmfs: The /lib/moles/3.0.76-0.11-default/extra/mmfslinux.ko kernel extension does not exist.
runmmfs: Unable to verify kernel/mole configuration.
Loading moles from /lib/moles/3.0.76-0.11-default/extra
runmmfs: The /lib/moles/3.0.76-0.11-default/extra/mmfslinux.ko kernel extension does not exist.
runmmfs: Unable to verify kernel/mole configuration.
Tue Apr 1 22:02:11 CST 2014 runmmfs: error in loading or unloading the mmfs kernel extension
Tue Apr 1 22:02:11 CST 2014 runmmfs: stopping GPFS
解決方案:重新編譯一下gpfs的源碼,因為手工卸載gpfs。
/usr/lpp/mmfs/src/README有詳細的編譯方法:主要命令方法如下:
#cd /usr/lpp/mmfs/src
#make Autoconfig
#make InstallImages
make InstallImages會在/lib/moles/`uname -r`/extra目錄生成3個文件,大功告成.
創建實例
創建實例前:
node02#/opt/ibm/db2/V10.5/instance/db2icrt -cf node01 -cfnet node01
-m node02 -mnet node02 -instance_shared_dir /db2sd_20140401
-tbdev 192.168.18.2 -u db2fenc1 db2inst1
-tbdev 官方解釋為:Specifies a shared device path for a device that will act as a tiebreaker in the DB2 pureScale environment to ensure that the integrity of the data is maintained. 通俗的講就是在member出現故障時,判斷哪個member可以恢復服務,窮屌絲們就用網關IP來代替了,只要能 ping 通即可判斷為可用。
此時執行:# db2instance -instance db2inst1 -list可以查看
node01:/opt/ibm/db2/V10.5/instance # mmlscluster
GPFS cluster information
========================
GPFS cluster name: db2cluster_20140401103900.site
GPFS cluster id: 6571095102926235332
GPFS UID domain: db2cluster_20140401103900.site
Remote shell command: /var/db2/db2ssh/db2locssh
Remote file command: /var/db2/db2ssh/db2scp
GPFS cluster configuration servers:
-----------------------------------
Primary server: node01.site
Secondary server: node02.site
Node Daemon node name IP address Admin node name Designation
----------------------------------------------------------------------
1 node01.site 192.168.18.201 node01.site quorum-manager
2 node02.site 192.168.18.202 node02.site quorum-manager
曾經出現報錯:
錯誤1、報2632-044、2632-068,此類錯誤為創建tsa domain時的錯誤,原因在於虛擬機是拷貝的,不是重新安裝的。
解決方法:#/usr/sbin/rsct/install/bin/recfgct
啟動實例
node01:$/home/db2inst1/sqllib/adm/db2start
怎麼樣,報錯了吧,應該是SQL1721N
SQL1721N Starting the DB2 database manager failed because of a problem with a configuration file that is needed by RDMA.受打擊吧。
你裝完了實例啟動不了,沒關系,這么高檔的玩意怎麼能讓你這么快啟動啊。
你得設置兩個注冊表變數才能用普通網路.
$db2set DB2_SD_SOCKETS_RESTRICTIONS=false
$db2set DB2_CA_TRANSPORT_METHOD=SOCKETS
使用如下命令可以查看CF與member的狀態。
#db2instance -instance db2inst1 -list
node01:/home/db2inst1 # db2instance -instance db2inst1 -list
ID TYPE STATE HOME_HOST CURRENT_HOST ALERT PARTITION_NUMBER LOGICAL_PORT NETNAME
-- ---- ----- --------- ------------ ----- ---------------- ------------ -------
0 MEMBER STARTED node02 node02 NO 0 0 node02
128 CF PRIMARY node01 node01 NO - 0 node01
HOSTNAME STATE INSTANCE_STOPPED ALERT
-------- ----- ---------------- -----
node01 ACTIVE NO NO
node02 ACTIVE NO NO
此時你可以使用lssam查看tsa的兩個節點的狀態。
#lssam
添加成員
將node03添加為另一個member,如果實例沒有啟動會自動啟動實例,所以預先將上一步的兩台機器上的db2set執行完畢先。
node01:
#/opt/ibm/db2/v10.5/instance/db2iupdt -d -add -m node03 –mnet node03 db2inst1
#su - db2inst1 -c "db2start member 1"
開啟你的purescale之旅
#db2sampl
執行完畢後兩台member都可以看到資料庫sample,可以同時對庫進行操作
C. Linux下DB2監聽服務怎麼啟動
操作方法如下:
1.將secureCRT連接到資料庫所在的linux機器,然後切換到oracle用戶模式下;
2.接下來用sqlplus登錄到資料庫,然後再關閉資料庫;
3.然後起動監聽;
4.最後客戶端連接。
工具和原料:linux安裝,oracle資料庫,SecureCRT,任意ssh連接工具都可以。
D. DB2哪個版本可以在linux系統下安裝
IBMDB2 目前支持Linux、Unix、Windows 到 z/OS 的各種平台
諸如看到這樣的字樣:DB2 for Linux, UNIX and Windows 即是
DB2的軟體版本分為:
Enterprise Server Edition
Workgroup Server Edition
Advanced Enterprise Server Edition
1 . DB2 Everyplace 版
2 . DB2 個人版(Personal Edition)
3 . DB2 工作組版(Workgroup Edition)
4 . DB2 企業伺服器版(Enterprise Server Edition)
5 .Express-C 免費版
Express Edition
DB2 Express 是針對中小型企業的入門級
DB2 可以運行在從 IBM 到非 IBM(HP 及 SUN UNIX 系統等)的各種操作平台。它既可以在主機上以主 / 從方式獨立運行,也可以在客戶 / 伺服器環境中運行。其中伺服器平台可以是 OS/400,AIX,HP-UNIX,SUN-Solaris 和 Windows 等操作系統,客戶機平台可以是 Windows,Dos,AIX,HP-UX 和 SUN Solaris 等操作系統。各種平台上的 DB2 產品有共同的應用程序介面,運行在一種平台上的程序可以方便地移植到其他平台
可見上述列出來的各版本皆有 在Windows上運行的相關程序包。 目前DB2最新版本是 DB210 !!
E. IBM/DB2.Linux的安裝配置管理
IBM/DB2.Linux的安裝配置管理
作為關系型資料庫技術的領導者,IBM公司在2001年將世界排名第四的Informix資料庫公司納入麾下,並將其所擁有的先進特性融入到DB2當中。下面我准備了關於IBM/DB2.Linux的安裝配置管理的.文章,提供給大家參考!
1.安裝IBM/DB2 V9.1 Linux版
下載得到安裝文件 db2exc_912_LNX_x86.tar.gz ,解壓到ext2/3分區
# cd db2exc_912_LNX_x86
# ./db2setup
(1)彈出java的安裝界面,install new instance
(2)使用“Typical Mode”,選擇安裝目錄,默認為 DB2_root=/opt/ibm/db2/V9.1/
# echo DB2_root=/opt/ibm/db2/V9.1/ >> /etc/profile
(3)並默認創建 db2inst?、db2fenc?、db2adsusr? 這個幾個用戶最重要的是本地實例管理用戶 db2inst? 其負責管理資料庫實例
(4)創建Instance,然後下一步繼續安裝,看到successful結果,表示成功
(5) # ps -e | grep db2 應該可以看到三個不同名稱的進程
(6) # tail /etc/inittab #可以看到最後一行就是啟動db2的方法
fmc:2345:respawn:/opt/ibm/db2/V9.1/bin/db2fmcd #DB2 Fault Monitor Coordinator
2.配置IBM/DB2的庫開發和CLI/ODBC連接
# su db2inst1
$ cd $DB2_ROOT
## 編目(catalog):
$ ./db2 catalog tcpip node remote server
$ ./db2 catalog db at node
$ ./db2 connect to user using
## 反編目(uncatalog):
$ ./db2 uncatalog db
$ ./db2 uncatalog node
3.修改,使用IBM/DB2的CLI/ODBC進行程序開發
(1)如果不想使用db2實例,而只是想使用CLI/ODBC來開發程序,可以注釋 /etc/inittab 中啟動db2的那一句,放棄啟動IBM/DB2資料庫服務。
(2)環境變數配置文件 : /home/db2inst1/sqllib/db2profile
查看 /etc/profile ,保證(添加或者修改)有以下兩句
export DB2INSTANCE=db2inst1
export PATH=$DB2_ROOT/binPATH
export LD_LIBRARY_PATH=$DB2_ROOT/lib32LD_LIBRARY_PATH
(3)編目目標機器地址與ODBC的DSN的關系,CLI/ODBC 中最重要的頭文件(include)和庫(lib)
$DB2_ROOT/lib32 或 其聯接 /home/db2inst1/sqllib/lib,其中最重要的是libdb2.so
4.資料庫備份及恢復
(1).使用用戶名和口令登錄伺服器
# db2 connect to ecm3000 user using
(2).強制停止所有應用,是非同步的
# db2 force applications all
(3).將資料庫備份到指定目錄下
# db2 backup database to
(4).從指定目錄中恢復資料庫
# db2 restore database from
5.修改和卸載DB2
請先反編目()如步驟2中
# su db2inst1
$ cd $DB2_ROOT/install
$ ./db2_deinstall -a
等待結束 ...
修改該/etc/inittab 中啟動db2的那一句,保證放棄啟動IBM/DB2資料庫服務。
;F. 怎麼在linux上咱裝DB2
我網上復制來的,可以稍微看下,其實DB2也有安裝腳本的
安裝DB2
DB2的安裝可以算是再各個資料庫裡面最簡單的了。除了sqlite。
下載安裝包,解壓
[root@Enterprise tmp]# tar xvf DB2_V82_PE_LNX_32_NLV.tar
解開以後的文件都被放置在當前目錄下的pe文件夾中。
開始安裝:
[root@Enterprise tmp]# cd pe
[root@Enterprise pe]# ls
db2 db2_deinstall db2_install db2setup doc
[root@Enterprise pe]# ./db2_install
Specify one or more of the following keywords,
separated by spaces, to install DB2 procts.
選擇自己要安裝的產品,輸入名字後回車。等待安裝完成。
我們現在需要做的是,對資料庫的初始化工作。包括安裝授權文件和創建一個實例並運行它。
首先,我們安裝授權文件。
不安裝授權文件的話,則是評估版,九十天後就要過期。授權文件,在安裝包已經有了。我們用下面的命令安裝它:
[root@Enterprise pe]# /opt/IBM/db2/V8.2/adm/db2licm -a /tmp/pe/db2/lic
ense/db2pe.lic
如果沒有db2pe.lic 文件。可以去網上找找。
我們需要創建一個用戶。
[root@Enterprise pe]# useradd db2inst1
[root@Enterprise pe]# passwd db2inst1
開始創建實例:
[root@Enterprise pe]# /opt/IBM/db2/V8.2/instance/db2icrt -u db2inst1 db2inst1
這樣,我們就創建了一個實例db2ins1。
[root@Enterprise pe]# su db2inst1
[db2inst1@Enterprise pe]$ db2start
07/26/2007 16:45:10 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
這樣我們資料庫就啟動成功。
[db2inst1@Enterprise pe]$ db2
(c) Copyright IBM Corporation 1993,2002
Command Line Processor for DB2 SDK 8.2.0
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 =>
創建一個最簡單的資料庫
db2 => create database testdb
DB20000I The CREATE DATABASE command completed successfully.
查看本instance下有哪些database
db2 => list database directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = TESTDB
Database name = TESTDB
Local database directory = /home/db2inst1
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = OMNIDB
Database name = OMNIDB
Local database directory = /home/db2inst1/data
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =