gdeploy를 이용한 glusterfs install

gdeploy를 이용해서 glsuterfs 설치를 해봤다.

좀 삽질하면서 써봤는데 잘 만들어 둔것 같다.

사용법을 좀 알아보면… [<section>[number]] 을 지정하고 원하는 option들을 넣어 준다. 이때 중복되는 section은 뒤에 숫자를 붙여준다.

### 사용할 hostslist이다. ip addreshostname을 넣는다. ###

[hosts]

rhgs1.test.dom

rhgs2.test.dom

rhgs3.test.dom

rhgs4.test.dom

rhgs5.test.dom

rhgs6.test.dom

### hardware raid(sas controller) type이다 기본이 JBOD(raid 없음)이고 raid6, raid10을 지정 할 수 있다. ###

[disktype]

raid6

### data disk의 갯수 이다. raid6disk 12개 이면 보통 data disk10개이다. raid6 erasure code는 보통 parity disk2개로 설정하지만 그 이상으로도 설정 할 수 있다. ###

[diskcount]

10

### raid를 구성 할 때 지정 한 stripe-unit(chunk)size이다. red hat glusterfs admin guide 에서는 raid6일때 128k, raid10일때 256k를 권장 하고 있다. 단위는 KB이다. ###

[stripesize]

128

### fileupdate 할 때 쓰는 옵션이다. copy하거나 안에 있는 내용을 수정 할 수 있다. ###

#[update-file1]

#action=add

#dest=/etc/ntp.conf

#line=server clock.redhat.com iburst

### servicemanagement 할 수 있다. action에는 enable, disable, stop 이 들어간다. ###

[service1]

action=enable

service=ntpd

[service2]

action=restart

service=ntpd

### 특정 script를 실행 시킬 수가 있다. 아래는 gdeploy package안에 들어있는 multipathdisable하는 shell script이다. 실행 시 /etc/multipath.conf fileblocklist { devnode “*” } 를 추가하여 모든 devicemultipath에서 제외시키게 된다. ###

#[script1]

#action=execute

#file=/usr/share/ansible/gdeploy/scripts/disable-multipath.sh

### 역시 gdeploy package 안에 있는 scriptgluster hookdisable시킨다. 잠깐 봤는데 nfs나 등등의 상황에서 hook을 걸어서 뭘 하게끔 설정 되어 있는걸 없애더라… ###

#[script2]

#action=execute

#file=/usr/share/ansible/gdeploy/scripts/disable-gluster-hooks.sh

### shell 에서 command를 실행 시킨다. 아래 commandparted를 이용해서 /dev/vdb block device에서 1개의 통 파티션(1개의 파티션이 모든영역을 차지하게끔)을 만드는 command이다. ###

[shell100]

action=execute

command=parted -s -a optimal /dev/vdb mklabel msdos — mkpart primary ext2 1 -1

[shell101]

action=execute

command=parted -s -a optimal /dev/vdc mklabel msdos — mkpart primary ext2 1 -1

[shell102]

action=execute

command=parted -s -a optimal /dev/vdd mklabel msdos — mkpart primary ext2 1 -1

[shell103]

action=execute

command=parted -s -a optimal /dev/vde mklabel msdos — mkpart primary ext2 1 -1

### physical volume group을 만든다. action에는 create, resize가 들어간다. 아래는 위에서 만든 /dev/vdb1, vdc1, vdd1, vde1physical volume group에 넣는데 만약 filesystem format이 되어 있는경우 filesystem label을 강제로 지워버리겠다는 뜻이다. ###

[pv]

action=create

devices=vdb1,vdc1,vdd1,vde1

wipefs=yes

force=yes

### volume group을 생성한다. action에는 createextend가 들어간다. 아래는 volume group namegv1로 하고 /dev/vdb1, /dev/vdc1physical volume을 이용하여 volume group을 생성 시키겠다는 뜻이다. ###

[vg1]

action=create

vgname=gv1

pvname=vdb1,vdc1

### logical volume을 만드는 section이다. action에는 create, setup-cache, convert, change가 있다. 옵션들도 굉장히 많다. 아래를 일단 보면… logical volume을 만드는데 volume group gv1pysical volume /dev/vdb1을 이용하고, 크기는 /dev/vdb1에있는 모든 extent를 사용하고, lvtypethick으로 한다. lvtypethinthick이 있다. 만든 후 mount/mnt/gluster1에 할 것이며, xfsformat 하는데 optioninode size 512, logical block size 8192로 하고 강제로 format을 한다. logical volume을 만들 때 강제로 만든다. ###

[lv1]

action=create

vgname=gv1

pvname=/dev/vdb1

lvname=glv1

extent=100%PVS

lvtype=thick

mount=/mnt/gluster1/

mkfs=xfs

mkfs-opts=-i size=512 -n size=8192 -f

force=yes

ignore_lv_errors=no

#size=3GB

### lv 생성 시 setup-cache를 이용하여 dm-cache를 구성 할 수 있다. actionsetup-cache로 넣고 ssdcache영역으로 사용할 disk를 지정 해준다. vgnamelvname을 지정해주고, poolnamecache-pool 이름을 지정해준다. cache_lv에는 생성 할 cache-data volume 의 이름을 지정해준다. cache_lvsize에는 cache-data 영역의 크기를 지정한다. cache_meta_lvmetadata로 쓸 volume의 이름을 지정한다. cach_meta_lvsize에는 metadata로 쓸 volume의 크기를 지정한다. cachemode에는 기본 writethrough가 되어 있으므로 writeback을 지정해준다. ignore_lv_error는 만약에 error가 생기면 무시 하겠느냐 물어보는건데 error가 발생 시 무시하지않고 멈추겠다는 뜻이다. 아직 cache pool 만 만들고 위에서 생성한 lv와 붙이진 않았다 이건 convert에서 해야한다. ###

[lv2]

action=setup-cache

ssd=vdc1

vgname=gv1

lvname=glv1

poolname=cache-pool

cache_lv=glv1-cache-data

cache_lvsize=700M

cache_meta_lv=glv1-meta-data

cache_meta_lvsize=50M

cachemode=writeback

force=yes

ignore_lv_errors=no

### 원래 lv sectionconver 에서 lvconver가 되야 하는데 잘안되서 shell command로 하게끔 우회하였다. 아래는 mount된 것을 umount 하는것. ###

[shell1]

action=execute

command=umount /mnt/gluster1/

### lvconvert를 이용하여 cache영역과 lv를 연결시킨다. ###

[shell2]

action=execute

command=lvconvert –type cache /dev/gv1/glv1 –cachepool /dev/gv1/glv1-cache-data

### 다시 format을 시킨다 사실 위에서([lv1] section) format할 필요가 없는데 format을 안시키거나 mount를 안시키는 옵션이 없더라…###

[shell4]

action=execute

command=mkfs.xfs -i size=512 -n size=8192 /dev/gv1/glv1 -f

### 다시 원래 위치에 mount 시킨다. ###

[shell5]

action=execute

command=mount /dev/gv1/glv1 /mnt/gluster1/

### 위에서 한걸 반복한다 이번엔 두번째 volume group을 만든다. ###

[vg2]

action=create

vgname=gv2

pvname=vdd1,vde1

[lv3]

action=create

vgname=gv2

pvname=/dev/vdd1

lvname=glv2

extent=100%PVS

lvtype=thick

mount=/mnt/gluster2/

mkfs=xfs

force=yes

ignore_lv_errors=no

#mkfs-opts=-i size=512 -n size=8192 -f

#size=3GB

[lv4]

action=setup-cache

ssd=vde1

vgname=gv2

lvname=glv2

poolname=cache-pool

cache_lv=glv2-cache-data

cache_lvsize=700M

cache_meta_lv=glv2-meta-data

cache_meta_lvsize=50M

cachemode=writeback

force=yes

ignore_lv_errors=no

[shell6]

action=execute

command=umount /mnt/gluster2/

[shell7]

action=execute

command=lvconvert –type cache /dev/gv2/glv2 –cachepool /dev/gv2/glv2-cache-data

[shell8]

action=execute

command=mkfs.xfs -i size=512 -n size=8192 /dev/gv2/glv2 -f

[shell9]

action=execute

command=mount /dev/gv2/glv2 /mnt/gluster2/

### sed command를 이용하여 lvm.conf file을 수정한다. issu_discards optionfilesystem trim을 하라는 뜻이다. trim에 관해서는 나중에 다시 또 posting 하겠다. ###

[shell10]

action=execute

command=sed -i ‘/issue_discards = 0/ s/= 0/= 1/’ /etc/lvm/lvm.conf

### selinux disable ###

[shell11]

action=execute

command=sed -i ‘/SELINUX=/ s/enforcing/disabled/’ /etc/selinux/config

### selinux permissive로 만든다. 행여 enforcing으로 되어 있으면 permissive로 바꾸라는뜻… ###

[shell12]

action=execute

command=setenforce 0

### network managerstop disable 한다. redhat admin guide에 보니까 disable하라고 나와있더라. ###

[service4]

action=stop

service=NetworkManager

[service5]

action=disable

service=NetworkManager

### 기초 설정이 끝난 뒤 glusterd를 재시작 시켜준다. ###

[service6]

action=restart

service=glusterd

### filewalld 가 죽어있으면 시작 시켜준다. actionrestart로 해봤는데 이상하게 여기서 멈추더라… 그래서 start로 해둠. ###

[service7]

action=start

service=firewalld

[service8]

action=enable

service=firewalld

### kernel nfs stop, disable 해준다. kernel nfs(기존의 nfs, native nfs)를 쓰게되면 얘가 nfs port를 먼저 점유해버리게 되서 glusterfs에서 nfs service를 할 수가 없게된다. ###

[service9]

action=stop

service=nfs

[service10]

action=disable

service=nfs

### fstab의 내용을 바꾼다. sed -i “/gv/ s/,/,discard,/” /etc/fstab 이게 들어가 있는데… 안에 쉼표가 있어서 shell section에서 인식을 못하더라. 그래서 shell script로 만들어서 실행 하게끔 하였다. mount 할 때 discard 옵션을 넣어서 mount하게 할려는 것이다. 이것도 역시 위에서와같이 os에서 ssd devicetrim을 알려주라는 뜻이다. ###

[script3]

action=execute

file=/root/fstab_setup.sh

### firewall port를 열어주거나 닫을 수 가 있다. 아래는 glusterfs servicenfs와 필요 port들을 열어주는것이다. permanent=true를 안해주면 휘발성이되어, firewalld 재시작 시 설정이 없어진다. ###

[firewalld]

action=add

ports=111/tcp,2049/tcp,54321/tcp,5666/tcp,16514/tcp,4379/tcp

services=glusterfs

permanent=true

### 간단하게 pv, vg, lv를 다 만들어줄 수 가있다. 세부적인 옵션은 지정할 수가 없다. ###

#[backend-setup]

#devices=/dev/vdb1

#lvtype=thick

#poolnanme=gl-pool

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#mkfs=xfs

#force=yes

### 특정 host에서만 lv를 만들게 지정 할 수 있다. rhgs1에서만 실행 하라는 뜻 ###

#[backend-setup:rhgs1]

#devices=/dev/vdb1

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#brick_dirs=vol1

#force=yes

#[backend-setup:rhgs2]

#devices=/dev/vdb1

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#brick_dirs=vol1

#force=yes

#[backend-setup:rhgs3]

#devices=/dev/vdb1

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#brick_dirs=vol1

#force=yes

### selinux 설정인데… 이거 no로하면 아무것도 하지 말라는 뜻인지… enforcing으로 되어 있는데도 바뀌질 않더라. 그래서 위에 shell command로 바꾸게끔 해줬다. ###

[selinux]

no

### tuned를 이용한 glusterfs tunning이다. rhgs-sequential-io setting을 하라는뜻… kernel parameter setting이 들어가 있다. ###

[tune-profile]

rhgs-sequential-io

### gluster peer probe를 해주라는뜻 ###

[peer]

action=probe

### 드디어 gluster volume을 만들수가 있다. volume namegvol1로 하고 어떤 brick을 이용하여 만들지를 지정한다. 아래는 모든 hostbrick/mnt/gluster1/gvol1로 지정한다. replica_count를 이용하여 몇 way replica를 할 지 지정할 수 있다. 아래는 6 distribut volume을 만들게 될것이다. ###

[volume1]

action=create

volname=gvol1

transport=tcp

#replica=yes

#replica_count=3

brick_dirs=/mnt/gluster1/gvol1/

#force=yes

### 6 way replica volume을 만든다. ###

[volume2]

action=create

volname=gvol2

transport=tcp

replica=yes

replica_count=6

brick_dirs=/mnt/gluster2/gvol2/

#force=yes

### client 설정이다. centos7이라는 hostnameclientrhgs1:gvol1/mnt/gluster1mount시킨다. ###

[clients1]

action=mount

volname=rhgs1:gvol1

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster1

### 같은 client에서 다른 mount pointmount를 또 할 수 있다. 이렇게 되면 glusterfs daemon이 하나 더 뜨게 되는데, 각각의 daemon이 따로 일을 하기 때문에 작은 파일에 대한 성능을 비약적으로 올릴 수 있다. sequential io는 안높아짐. network bandwidth에서 bottleneck이 걸려서… ###

[clients2]

action=mount

volname=rhgs1:gvol1

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster1-1

[clients3]

action=mount

volname=rhgs1:gvol2

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster2

[clients4]

action=mount

volname=rhgs1:gvol2

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster2-1

다음으로 remove script를 알아보면…

#!/bin/bash

# change LIST, CLIENT, GLUSTERVOL

### 아래 변수들은 대상에 맞게 바꿔주면 된다. ###

### host, client, gluster volume list ###

HOSTLIST=”rhgs6 rhgs5 rhgs4 rhgs3 rhgs2 rhgs1″

CLHOST=”centos7″

GLUSTERVOL=”gvol1 gvol2″

SEDSEARCHGV=”gv”

DELVG=”${SEDSEARCHGV}{1,2}”

DELPV=”/dev/{vdb1,vdc1,vdd1,vde1}”

CLMOUNTPOINT=”/mnt/gluster{1,2,1-1,2-1}”

HSMOUNTPOINT=”/mnt/gluster1 /mnt/gluster2″

### client host로 접속하여 umount 하는 script이다. 왜 그런지 한번에 안될때가 있어서 2번 하게 해놨다. ###

### client unmount ###

for c in $CLHOST

do

ssh $c “umount $CLMOUNTPOINT”

sleep 1

ssh $c “umount $CLMOUNTPOINT”

echo unmount done’!!’ ———————

echo “”

done

### glusterfs volume delete 이다. here documents 를 이용해서 만들었다. gluster vol stop volumename 을 실행 시키면 진짜 할거냐고 물어보는데 이때 y를 넣는 script이다. ###

### volume delete ###

for d in $GLUSTERVOL

do

gluster vol stop $d << DD

y

DD

sleep 1

gluster vol del $d << DD

y

DD

sleep 1

done

echo gluster volume deleted’!!’ —————

echo

### glusterfs server에서 실행되는 script이다. /etc/fstab에서 volume group을 검색하여 그 라인을 지운다. 그리고 umount를 하고, volume groupforce로 지운다. volume group만 지우면 logical volume은 따라서 지워진다. 다음 pysical volume을 삭제해준다. 마지막으로 gluster peer detach 를 실행 시켜준다. ###

### service remove ###

for I in $HOSTLIST

do

echo —– $I processing ——————–

ssh $I sed -i “/$SEDSEARCHGV/d” /etc/fstab

ssh $I “umount $HSMOUNTPOINT”

ssh $I “vgremove $DELVG -f”

ssh $I “pvremove $DELPV -f”

gluster peer detach $I

#ssh $I “sed -i “/lv[12]/d” /etc/fstab”

#ssh $I “lvremove gv1/glv1 gv2/glv2 -f”

#ssh $I “vgremove gv{1,2} -f”

#ssh $I “pvremove /dev/{vdb1,vdc1,vdd1,vde1} -f”

#ssh $I “shutdown -r +0”

echo —– $I done ‘!!’ ———————–

echo “”

done

모든 과정이 종료되엇다. 이로서 설치 및 제거를 자동화하여 할 수가 있다.

 

https://leeyj7141blog.wordpress.com/2016/10/17/gdeploy를-이용한-glusterfs-install/ 에서 가져옴

댓글 남기기

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin