¿ù°£ Àα⠰Խù°

°Ô½Ã¹° 1,358°Ç
   
CEPH RBD (RADOS BLOCK DEVICE)
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2015-03-30 (¿ù) 15:42 Á¶È¸ : 5967
±ÛÁÖ¼Ò :
                                
RBD – MANAGE RADOS BLOCK DEVICE (RBD) IMAGES
rbd is a utility for manipulating rados block device (RBD) images, used by the Linux rbd driver and the rbd storage driver for Qemu/KVM. RBD images are simple block devices that are striped over objects and stored in a RADOS object store. The size of the objects the image is striped over must be a power of two.

1. /etc/hosts 
115.XXX.XXX.7 compute1
115.XXX.XXX.4 compute2

2. CEPH ¼³Á¤
ceph@mgmt:~$ ssh-copy-id ceph@compute1
ceph@mgmt:~$ ssh ceph@compute1
ceph@mgmt:~$ ceph-deploy install compute1
ceph@mgmt:~$ cd cephcluster/
ceph@mgmt:~/cephcluster$ ceph-deploy admin compute1
ceph@mgmt:~/cephcluster$ rados lspools
rbd


¡Ø osd pool create <poolname> <int[0-]>     create pool
     {<int[0-]>} {replicated|erasure}        
     {<erasure_code_profile>} {<ruleset>}    
     {<int>}                                 
   osd pool delete <poolname> {<poolname>}  delete pool
     {--yes-i-really-really-mean-it}         
ceph osd pool create {pool-name} {pg-num} [{pgp-num}] [replicated] \
     [crush-ruleset-name]
ceph osd pool create {pool-name} {pg-num}  {pgp-num}   erasure \
     [erasure-code-profile] [crush-ruleset-name]
ceph@mgmt:~/cephcluster$ ceph osd pool create client07 256 256
pool 'client07' created
ceph@mgmt:~/cephcluster$ rados lspools
rbd
client07
ceph@mgmt:~/cephcluster$ rbd create client07/vm_disk01 --size 4096
ceph@mgmt:~/cephcluster$ rbd list client07
vm_disk01


OpenStack ComputeNode
1. /etc/hosts Ãß°¡
2. À¯Àú»ý¼º 
# useradd -d /home/ceph -m ceph
# passwd ceph
# echo "ceph ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/ceph
# chmod 0440 /etc/sudoers.d/ceph


3. RBD ¼³Á¤ 
root@compute1:~# rbd info client07/vm_disk01
rbd image 'vm_disk01':
size 4096 MB in 1024 objects
order 22 (4096 kB objects)
block_name_prefix: rb.0.1156.238e1f29
format: 1

root@compute1:~# vim /etc/ceph/rbdmap
client07/vm_disk01        id=admin,keyring=/etc/ceph/ceph.client.admin.keyring

root@compute1:~# rbd map client07/vm_disk01
/dev/rbd1

root@compute1:~# rbd showmapped
id pool     image     snap device    
1  client07 vm_disk01 -    /dev/rbd1 

root@compute1:~# mkfs.xfs /dev/rbd1
log stripe unit (4194304 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/rbd1              isize=256    agcount=9, agsize=130048 blks
         =                       sectsz=512   attr=2, projid32bit=0
data     =                       bsize=4096   blocks=1048576, imaxpct=25
         =                       sunit=1024   swidth=1024 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

root@compute1:~# mkdir /CEPH

fstab µî·Ï
oot@compute1:~# vim /etc/fstab
/dev/rbd1 /CEPH xfs defaults,noatime,netdev 0 0

root@compute1:~# mount /dev/rbd1  /CEPH/

root@compute1:~# df -h |grep CEPH
/dev/rbd1       4.0G   33M  4.0G   1% /CEPH


µð½ºÅ© ¾²±â üũ
root@compute1:~# cd /CEPH

root@compute1:/CEPH# for ((i=1; i<36; i++)); do dd if=/dev/zero of=file_$i bs=1MB count=100; done

root@compute1:/CEPH# df -h |grep CEPH
/dev/rbd1       4.0G  3.3G  716M  83% /CEPH


CEPH ½ºÅ丮Áö »óÅÂüũ
ceph@mgmt:~/cephcluster$ ceph status


RBD µð½ºÅ© È®Àå(resize)
ceph@mgmt:~/cephcluster$ rbd resize client01/vm_disk01 --size 8192
Resizing image: 100% complete...done.


root@compute1:/CEPH# df -h |grep CEPH
/dev/rbd1       4.0G  3.3G  716M  83% /CEPH

root@compute1:/CEPH# rbd info client07/vm_disk01
rbd image 'vm_disk01':
size 8192 MB in 2048 objects
order 22 (4096 kB objects)
block_name_prefix: rb.0.1156.238e1f29
format: 1

root@compute1:/CEPH# xfs_growfs /dev/rbd1
meta-data=/dev/rbd1              isize=256    agcount=9, agsize=130048 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=1048576, imaxpct=25
         =                       sunit=1024   swidth=1024 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1048576 to 2097152

root@compute1:/CEPH# df -h |grep CEPH
/dev/rbd1       8.0G  3.3G  4.7G  42% /CEPH

root@compute1:/CEPH# for ((i=36; i<46; i++)); do dd if=/dev/zero of=file_$i bs=1MB count=100; done

root@compute1:/CEPH# df -h |grep CEPH
/dev/rbd1       8.0G  4.3G  3.8G  53% /CEPH


´Ù½Ã È®Àå
root@compute1:/CEPH# rbd resize client07/vm_disk01 --size 16384
Resizing image: 100% complete...done.

root@compute1:/CEPH# rbd info client07/vm_disk01
rbd image 'vm_disk01':
size 16384 MB in 4096 objects
order 22 (4096 kB objects)
block_name_prefix: rb.0.1156.238e1f29
format: 1

root@compute1:/CEPH# df |grep CEPH
/dev/rbd1        8378368  4428048   3950320  53% /CEPH

root@compute1:/CEPH# xfs_growfs /dev/rbd1
meta-data=/dev/rbd1              isize=256    agcount=17, agsize=130048 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=2097152, imaxpct=25
         =                       sunit=1024   swidth=1024 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2097152 to 4194304

root@compute1:/CEPH# df |grep CEPH
/dev/rbd1       16766976  4428560  12338416  27% /CEPH


¡Ø mon daemon restart
root@mgmt:/home/ceph/cephcluster# initctl restart ceph-mon-all
ceph-mon-all start/running


[Err message] ÇöÀç µð½ºÅ© »çÀÌÁî°¡ 10000000 --> 2000000 Ãà¼Ò
# rbd resize backup_img/backup --size 2000000
rbd: shrinking an image is only allowed with the --allow-shrink flag
¡Ø --allow-shrink                     allow shrinking of an image when resizing

# rbd resize backup_img/backup --size 2000000 --allow-shrink


ÃÖ°í°ü¸®ÀÚ 2015-06-15 (¿ù) 14:51
# rbd resize backup_image/backup --size 20000000
Resizing image: 100% complete...done.
20000000  --> size 19531 GB

# rbd resize backup_image/backup --size 30000000
Resizing image: 100% complete...done.
30000000 --> size 29296 GB

ÃÖ°í°ü¸®ÀÚ 2015-06-22 (¿ù) 15:17
[root@CIFS1 ~]# rbd info backup_img/backup
rbd image 'backup':
size 19073 TB in 5000000000 objects
order 22 (4096 KB objects)
block_name_prefix: rb.0.1b8fb.2ae8944a
format: 1

[root@CIFS1 ~]# rbd info backup_image/backup
rbd image 'backup':
size 29296 GB in 7500000 objects
order 22 (4096 KB objects)
block_name_prefix: rb.0.1d387.238e1f29
format: 1

# rbd showmapped 
id pool          image   snap device    
1  image_parking parking -    /dev/rbd1 
2  backup_image  backup  -    /dev/rbd2 
3  backup_img    backup  -    /dev/rbd3 

# mount /dev/rbd3 /backup_img/

:: mgmt ¼­¹ö¿¡¼­
# ceph osd dump
.........................
pool 9 'image_parking' replicated size 3 min_size 2 crush_ruleset 0 object_hash rjenkins pg_num 128 pgp_num 128 last_change 180 flags hashpspool stripe_width 0
pool 10 'backup_img' replicated size 2 min_size 2 crush_ruleset 0 object_hash rjenkins pg_num 128 pgp_num 128 last_change 1573 flags hashpspool stripe_width 0
pool 13 'backup_image' replicated size 3 min_size 2 crush_ruleset 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 1580 flags hashpspool stripe_width 0
.........................
.........................
À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.