DB2中使用裸装备作为容器需要3个步骤:1. 创建LV。2. 绑定LV和裸装备 3.创建表空间
1. 创建lv
root@ubuntu:~# vgdisplay <-查看可用的Volume Group
root@ubuntu:~# vgdisplay
--- Volume group ---
VG Name mainVG
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.00 GiB
PE Size 4.00 MiB
Total PE 511
Alloc PE / Size 125 / 500.00 MiB
Free PE / Size 386 / 1.51 GiB
VG UUID b15u8R-Kt91-Tgfe⑵RX8-buKP-dfU9-Uw5a2J
root@ubuntu:~# lvcreate -L 200M -n testlv mainVG <--创建lv
Logical volume "testlv" created
root@ubuntu:~# ls -l /dev/mainVG/testlv
lrwxrwxrwx 1 root root 7 Oct 31 02:28 /dev/mainVG/testlv -> ../dm⑶
root@ubuntu:~# ls -l /dev/dm⑶
brw-rw---- 1 root disk 252, 3 Oct 31 02:28 /dev/dm⑶
可以看到新创建的lv只是1个符号链接,指向块装备dm⑶
2. 创建裸装备raw3,并绑定到lv上
root@ubuntu:~# modprobe raw
root@ubuntu:~# mknod /dev/raw/raw3 c 162 3
root@ubuntu:~# raw /dev/raw/raw3 /dev/mainVG/testlv
/dev/raw/raw3: bound to major 252, minor 3
root@ubuntu:~# chown qingsong:qingsong /dev/raw/raw3
root@ubuntu:~# ls -l /dev/raw/raw3
crw-rw---- 1 qingsong qingsong 162, 3 Oct 31 02:32 /dev/raw/raw3
3. 切换至实例用户,启动http://www.wfuyu.com/db/,并创建表空间,容器使用刚刚创建的裸装备。
qingsong@ubuntu:~$ db2start
SQL1063N DB2START processing was successful.
qingsong@ubuntu:~$ db2 connect to qsmiao
Database Connection Information
Database server = DB2/LINUXX8664 10.5.4
SQL authorization ID = QINGSONG
Local database alias = QSMIAO
qingsong@ubuntu:~$ db2 "create tablespace lvtbs managed by database using(device '/dev/raw/raw3' 300)"
DB20000I The SQL command completed successfully.
不过,重启机器以后,创建的裸装备/dev/raw/raw3就会消失,目前没有找到解决办法,1种替换方案是1开机就自动创建1次,把下面4行添加进/etc/rc.local中
modprobe raw
mknod /dev/raw/raw3 c 162 3
raw /dev/raw/raw3 /dev/mainVG/thirdlv
chown qingsong:qingsong /dev/raw/raw3
测试环境:
Ubuntu 14.04
DB2 10.5.4
参考:
http://www.informix-zone.com/node/38#fromlog
欢迎批评指正