Home >Database >Mysql Tutorial >DB2中使用裸设备作为表空间容器

DB2中使用裸设备作为表空间容器

WBOY
WBOYOriginal
2016-06-07 16:06:411486browse

DB2中使用裸设备作为容器需要三个步骤: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 M

DB2中使用裸设备作为容器需要三个步骤:1. 创建LV。2. 绑定LV和裸设备 3.创建表空间

1. 创建lv

root@ubuntu:~# vgdisplay

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-2RX8-buKP-dfU9-Uw5a2J

root@ubuntu:~# lvcreate -L 200M -n testlv mainVG

Logical volume "testlv" created

root@ubuntu:~# ls -l /dev/mainVG/testlv

lrwxrwxrwx 1 root root 7 Oct 31 02:28 /dev/mainVG/testlv -> ../dm-3

root@ubuntu:~# ls -l /dev/dm-3

brw-rw---- 1 root disk 252, 3 Oct 31 02:28 /dev/dm-3

可以看到新创建的lv只是一个符号链接,指向块设备dm-3

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. 切换至实例用户,启动数据库,并创建表空间,容器使用刚刚创建的裸设备。

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就会消失,目前没有找到解决办法,一种替代方案是一开机就自动创建一次,把下面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

欢迎批评指正

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn