db2在linux的裸设备上创建表空间总结

1、在创建表表空间时,确认裸设备一定是存在的方式:
fdisk -l 命令查看裸设备使用情况。
如 执行fdisk -l 后
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 65 522081 83 Linux
/dev/sdc2 66 130 522112+ 83 Linux

以上说明了磁盘设备的使用情况
sda为系统区域不宜食用
sdb已经全部占用,分配给文件系统
sdc可以使用,为新挂载的磁盘设备

2、使用fdisk /dev/sdc来创建磁盘分区

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help):

可以通过以上看到,使用n来创建新分区

Command (m for help): n
Command action
e extended
p primary partition (1-4)

键入p创建分区 ,然后选择创建按分区号,创建分区号后,键入分区起始位置与结束位置。来确认分区大小
键入完毕后,使用w命令来保存设置。

目前对磁盘分区创建完毕。

3、在/dev下查看磁盘创建情况,也可以通过fdisk -l命令来创建

4、然后通过 chown db2inst1:disk /dev/sdc1 对磁盘分区的权限进行调整。
5、然后就可以通过db2inst1用户来创建表空间了。
如果第5步行在创建表空间时,有问题。可以通过以下:
raw创建设备
# raw /dev/raw/raw5 /dev/sdb5 # 用于user tablespace1 (32k),存储表
raw来连接设备与磁盘分区

将设备添加到启动项目中,对/etc/rc.d/sysinit添加raw /dev/raw/raw5 /dev/sdb5

修改设备处理权限chown db2inst1:disk /dev/raw/raw[5]

额外信息
当已经在raw设备上创建容器之后,若没有通过正常的步骤删

除表空间所在数据库,也没有直接删除容器或者容器所在表空间,则再次利用这些raw设备时,db2会报错:
the container is already in use

此时应使用db2untag命令释放container标志,而采用重新对磁盘进行分区或者格式化的操作是无济于事的。

释放已经在raw设备raw1上建立的container标志:

# su - db2inst1
$ db2untag /dev/raw/raw1

 



相关文档
最新文档