메뉴 닫기

Ubuntu lvm thin provisioning 구성

thin provisioning이란 기존의 스토리지나 볼륨, 물리적 저장소 체계에서는
리소스 할당시 물리적으로 고정된 용량을 할당하지요.

이렇게 사용시 문제점중 하나가 운영시 고정된 용량 만큼 사용하지 않을수 있어서 리소스를
효율적으로 사용하지 못하는 단점이 있지요.

만약에 100G를 쓰는 고객이 실제로 1G만 쓴다면 얼마나 심한 리소스 낭비 겠는가요….

우분투에서 lvm 운영시 thin provisioning 구성 해보지요

# thin pool 생성


root@share:~# vgs
  VG             #PV #LV #SN Attr   VSize   VFree  
  cinder-volumes   1   0   0 wz--n- 232.83g 232.83g
  manila-volumes   1   0   0 wz--n- 232.93g 232.93g
# 현재 구성된 볼륨 그룹 확인

root@share:~# lvcreate -L 15G --thinpool tp cinder-volumes 
  Rounding up size to full physical extent 16.00 MiB
  device-mapper: remove ioctl on  failed: Device or resource busy
  Logical volume "tp" created
# tp라는 이름의 15G pool 생성 되지만  Device or resource busy 출력된다.

root@share:~# cd /lib/udev/rules.d/
root@share:/lib/udev/rules.d# vi 60-persistent-storage-dm.rules
# Udev rules for device-mapper devices.
# See /usr/share/doc/dmsetup/README.udev for further information.

ACTION!="add|change", GOTO="persistent_storage_dm_end"
ENV{DM_UDEV_RULES}=="", GOTO="persistent_storage_dm_end"
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="persistent_storage_dm_end"

ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"

SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"

ENV{DM_SUSPENDED}=="1", GOTO="persistent_storage_dm_end"

#OPTIONS+="watch"
IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"

LABEL="persistent_storage_dm_end"
# 60-persistent-storage-dm.rules 파일에서 OPTIONS+="watch"  주석 처리한다

root@share:/lib/udev/rules.d#  lvcreate -L 15G --thinpool tp cinder-volumes
  Rounding up size to full physical extent 16.00 MiB
  Logical volume "tp" created
# 60-persistent-storage-dm.rules 파일 수정후 Device or resource busy 출력이 없다.

root@share:~# lvs
  LV   VG             Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  tp   cinder-volumes twi-a-tz- 15.00g               0.00            
# 생성 확인

root@share:~# vgs
  VG             #PV #LV #SN Attr   VSize   VFree  
  cinder-volumes   1   1   0 wz--n- 232.83g 217.81g
  manila-volumes   1   0   0 wz--n- 232.93g 232.93g

root@share:~# lvdisplay cinder-volumes/tp 
  --- Logical volume ---
  LV Name                tp
  VG Name                cinder-volumes
  LV UUID                UbYWDH-hUTq-ZitI-kbJt-ARxo-xsCQ-TCgIwJ
  LV Write Access        read/write
  LV Creation host, time share, 2016-05-20 16:09:19 +0900
  LV Pool transaction ID 0
  LV Pool metadata       tp_tmeta
  LV Pool data           tp_tdata
  LV Pool chunk size     64.00 KiB
  LV Zero new blocks     yes
  LV Status              available
  # open                 0
  LV Size                15.00 GiB
  Allocated pool data    0.00%
  Allocated metadata     0.59%
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:3

# thin volume 생성


root@share:~# lvcreate -V 5G --thin -n thin_vol1 cinder-volumes/tp
  Logical volume "thin_vol1" created

root@share:~# lvcreate -V 5G --thin -n thin_vol2 cinder-volumes/tp
  Logical volume "thin_vol2" created

root@share:~# lvcreate -V 5G --thin -n thin_vol3 cinder-volumes/tp
  Logical volume "thin_vol3" created
# 5G 사이즈의 볼륨 3개 생성

root@share:~# lvs
  LV        VG             Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  thin_vol1 cinder-volumes Vwi-a-tz-  5.00g tp            0.00                        
  thin_vol2 cinder-volumes Vwi-a-tz-  5.00g tp            0.00                        
  thin_vol3 cinder-volumes Vwi-a-tz-  5.00g tp            0.00                        
  tp        cinder-volumes twi-a-tz- 15.00g               0.00           

# thin volume 포맷 및 마운트


root@share:~# mkdir -p /mnt/vol1 /mnt/vol2 /mnt/vol3

root@share:~# ls -l /mnt/
total 12
drwxr-xr-x 2 root root 4096 May 20 16:16 vol1
drwxr-xr-x 2 root root 4096 May 20 16:16 vol2
drwxr-xr-x 2 root root 4096 May 20 16:16 vol3

root@share:~# mkfs.ext4 /dev/cinder-volumes/thin_vol1
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
...
...
...

root@share:~# mount /dev/cinder-volumes/thin_vol1 /mnt/vol1 

root@share:~# mkfs.ext4 /dev/cinder-volumes/thin_vol2
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
...
...
...

root@share:~# mount /dev/cinder-volumes/thin_vol2 /mnt/vol2

root@share:~# mkfs.ext4 /dev/cinder-volumes/thin_vol3
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
...
...
...
root@share:~# mount /dev/cinder-volumes/thin_vol3 /mnt/vol3

root@share:~# df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   2.0G   12K  2.0G   1% /dev
tmpfs                                  395M  496K  394M   1% /run
/dev/sda2                              451G  2.6G  426G   1% /
none                                   4.0K     0  4.0K   0% /sys/fs/cgroup
none                                   5.0M     0  5.0M   0% /run/lock
none                                   2.0G     0  2.0G   0% /run/shm
none                                   100M     0  100M   0% /run/user
/dev/mapper/cinder--volumes-thin_vol1  4.8G   10M  4.6G   1% /mnt/vol1
/dev/mapper/cinder--volumes-thin_vol2  4.8G   10M  4.6G   1% /mnt/vol2
/dev/mapper/cinder--volumes-thin_vol3  4.8G   10M  4.6G   1% /mnt/vol3

# 볼륨 추가 및 pool 디스크 용량 확장


root@share:/mnt/vol1# lvcreate -V 5G --thin -n thin_vol4 cinder-volumes/tp
  Logical volume "thin_vol4" created

root@share:/mnt/vol1# mkfs.ext4 /dev/cinder-volumes/thin_vol4
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
...
...
...

root@share:/mnt/vol1# mkdir /mnt/vol4

root@share:/mnt/vol1# mount /dev/cinder-volumes/thin_vol4 /mnt/vol4

root@share:/mnt/vol4# lvextend -L +20G /dev/cinder-volumes/tp
  Extending logical volume tp to 35.00 GiB
  Logical volume tp successfully resized

root@share:/mnt/vol4# lvs
  LV        VG             Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  thin_vol1 cinder-volumes Vwi-aotz-  5.00g tp           20.03                        
  thin_vol2 cinder-volumes Vwi-aotz-  5.00g tp            9.83                        
  thin_vol3 cinder-volumes Vwi-aotz-  5.00g tp            9.74                        
  thin_vol4 cinder-volumes Vwi-aotz-  5.00g tp            9.81                        
  tp        cinder-volumes twi-a-tz- 35.00g               7.06   
# pool 사이즈가 15G에서 30G 늘어 났다.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x