월간 보관물: 2016 10월

gdploy configuration, ctdb setup

gdeploy를 이용해서 glusterfs를 설치해 보았다.

gdeploy config file은 이전에 이미 살펴 봣고…

이제 실제 설치하면서 겪은일들이나 덧 필요한 script, ctdb 구성시 필요한것들을 알아본다.

먼저 fstab setup script이다.

#!/bin/bash

MOUNTDIR=”/mnt/gluster1/ /mnt/gluster2/”

SEARCHGV=”RHGS-VG”

umount $MOUNTDIR

sed -i “/$SEARCHGV/ s/,/,discard,/” /etc/fstab

mount -a

gdeploy를 돌리면 /etc/fstab file에 자동으로 추가가되는데, sed를 이용해서 RHGS-VG라는 곳을 찾아서 첫번째 쉼표를 만나면 거기다가 discard 옵션을 추가해 넣는 script이다.

sed 구문이 gdeploy config file에 넣을 수가 없더라. 이유는 “,” 이 쉼표 때문… 이걸 gdeploy에서 각 환경변수값의 구분자로 취급하다보니 이상하게 parsing이 된다.

다음으로 ctdb 설정인데… 설정하는것은 쉽다. red hat manual 보고 따라하면 된다. 그런데… reboot을 하게되면 이게 잘 안올라옴 ㅋㅋㅋ

일일히 봐가면서 mount해주고 service 다시시작 해줘야된다… 이유는 glusterfs에서 제공하는 ctdb package가 있는데 어떤 script를 실행 시키면 설정파일들이 자동으로 알아서 세팅이 된다. gluster volume을 만들고 /gluster/lock/ 이라는 directorymoun를 하고 여기다가 lockfile을 만들어서 먼저 lock 거는놈이 master가 되어서 다른놈들한테 ip들을 분배 시켜준다.

여기서 첫 번째 문제가 한가지 발생하는데… 위에서 만든 gluster volumemountlockfile을 만든다고 했는데… 이게 server 재시작을 하면 mount가 잘 안된다. 어떨땐 mount 잘 되고.. 어떨땐 마운트가 잘 안되고… mount가 잘 되면 glusterfs가 만든 공유볼륨안에 lockfile을 보게 되는데… mount가 안되면 그냥 root filesystem에있는 /gluster/lock/lockfile 을 락을 잡아버려서 master가 두놈이 되는 현상이 발생한다. 어떤nodeglusterfs 공유볼륨에 있는 lockfile을 잘 lock을 걸어서 작동하는데… 어떤 node는 지 root filesystem에 있는 lockfile을 락을 잡아서 서로 lock 잡은게 두개라 무한 recovery mode로 빠진다. glusterfs가 어디서 계속 동작하고 있는게 아니라, rebooting mount가 안되는 문제를 해결 하기가 힘들었다. 그래서 이것저것 해보다가 생각한게… /lib/systemd/system/ctdb.service file을 수정해줬다. ctdb servicesystemd unit config file인데…

하나하나 살펴보자.

일단 service[unit], [service], [install] 이 세개의 섹션이 필요하다.

[Unit]

Description=CTDB ### 단순 설명임. 뭘적든 상관없다. internet manual을 적어 놓기도 하더라.

After=network.target glusterd.service ### networkglusterd가 뜬 후에 이게 구동 되게끔 해달라는것 dependancy를 만든다.

Requires=glusterd.service ### 이것 역시 dependancy를 만드는데… glusterfs가 구동되어도 만약 fail이 되면 이것역시 구동되지 않는다.

RequiresMountsFor=/gluster/lock ### fstab에 있는 /gluster/lock mount를 해야지만이 구동된다. 근데 이것만 해놔도 잘 안되드라… 그래서 아래 나오겠지만 crontab에 까지 넣어줬음

[Service] ### service section이다. 여기서 service 시작 및 action에 관련된것들을 정의한다.

Type=forking ### forking을 하여서 동작 시키라는것. 기본적으로 daemonforking으로 되어 있는듯 하다. simple, oneshot, dbus, notify가 있다. 그냥 default로 두면됨 ㅋ

LimitCORE=infinity ### cpu resource 제한하는건데 이것도 그냥 둿다. 다 점유해서 쓸 수 있게 했다.

PIDFile=/run/ctdb/ctdbd.pid ### pid file이 생성되는 path이다.

#ExecStartPre=/usr/bin/umount /gluster/lock ### 삽질한 흔적인데 별의미 없었음… 똑같더라.

#ExecStartPre=/usr/bin/mount -t glusterfs rhgs11.test.dom:/ctdb /gluster/lock ### 이것역시 삽질한 흔적… 이렇게 하면 안됨

ExecStart=/usr/sbin/ctdbd_wrapper /run/ctdb/ctdbd.pid start ### 실질적인 start script이다.

ExecStop=/usr/sbin/ctdbd_wrapper /run/ctdb/ctdbd.pid stop ### 실질적인 stop script이다.

KillMode=control-group ### killmode인데 죽일 때 cgroup에 잇는 남은 관련 process를 전부 죽이라는 뜻이다. 몇가지 옵션이 더 있는데 man page참조.

Restart=always ### 이게 설정파일에 넣은건데… 뭔일이 있던지 멈추면 재시작 하라는 뜻이다. 아래 no가 있는데 저게 default였다. 하지만 난 service를 죽이기 싫으니까 always로 해둠 ㅋ

RestartSec=3s ### service 재시작 할때 3초 쉬고 하라는 뜻. service계속 실패하면 3초마다 계속 뜬다.

#Restart=no

[Install] ### install section인데 여기다가 runlevel 몇데 띄울지(정확히는 어떤 target에 띄울지) 결정한다.

WantedBy=multi-user.target ### 기본으로 multi-user.target ( runlevel 3 )에 뜨게 되어있다.

내가 추가한 것들은 bold 체로 해놧다.

이렇게 수정 후… 한가지더.. crontab에다가 1분마다 shell script를 실행하게 설정 해놨다.

#!/bin/bash

/usr/bin/ctdb status |grep -q mode:RECOVERY ### recovery mode인지 확인한다.

if test $? = 0 ### 이전 commandreturn code0인지 아닌지를 확인한다. 0이면 true 아니면 다 false, 위의 grap command에서 recovery mode라는 구문이 검출되면 return code0이고 아니면 1이 나온다.

then

/usr/bin/mount /gluster/lock ### fstab에 있는 /gluster/lock mount를 한다.

/usr/bin/systemctl restart ctdb.service ### ctdb servicerestart 한다.

else

sleep 0 ### return code 0 이 아니면 아무일도 안한다.

fi

위에 ctdb.service file에도 mount를 넣어놧고 여기에다가도 넣어 놧는데 … 별 문제는 없더라. 일단 마운트가 되야하는게 중요하니까…

scriptctdb가 정상적으로 작동 중일때는 아무일도 하지않고 종료된다. 그러나 recovery mode로 들어가 있으면 그 node에서 ctdb service를 재시작 한다. 재시작을 한다해도 normal mode가 되는데 1분이 안걸리니 작동하는데는 문제가 없더라.

한가지 보충 할 것이 있다면… ctdb 공유 볼륨의 mount point/gluster/lock 이 아니라 /gluster/ 로 하고 공유 volume안에 /lock/lockfile 을 만들면 위와같은 master가 두개가 되는 일은 발생 하지 않을것 같다. 한이사님이 알려주셧다.

다음 test할 때 유용한 remove script이다. 그냥 내가만든 shell script인데 나름 잘 쓰고 있다.

또 한줄 한줄 살펴 보면

#!/bin/bash

# change LIST, CLIENT, GLUSTERVOL

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

HOSTLIST=”rhgs16 rhgs15 rhgs14 rhgs13 rhgs12 rhgs11″ ### 변수 들이다… 여기다가 삭제할 node들을 넣자.

CLHOST=”centos7″ ### 삭제 할 client

GLUSTERVOL=”`gluster vol list`” ### 삭제할 볼륨 이름인데 만들어진 gluster volume 전부를 지정한것임.

#GLUSTERVOL=”glustervol1 glustervol2″ ### 위와 같은데 이름으로 지정해도 된다.

SEDSEARCHVG=”RHGS-VG” ### fstab에서 삭제할때 검색 할 volume group

DELVG=”${SEDSEARCHVG}{1,2}” ### vgremove 로 삭제할 volume group

#DELVG=”${SEDSEARCHVG}1″ ### 위와 같은데 1번만 만 있을때

DELPV=”/dev/{vda1,vdb1,vdc1,vdd1}” ### 삭제할 pv

CLMOUNTPOINT=”/mnt/gluster{1,2,1-1,2-1}” ### unmount clientmount되어있는 mount point

HSMOUNTPOINT=”/mnt/gluster1 /mnt/gluster2″ ### unmount node들의 mount point

### volume delete ###

for d in $GLUSTERVOL ### volume을 먼저 지운다.

do ### for 문을 시작한다.

gluster vol stop $d << DD ### volumestop 시키고… 뒤에 나온 << hear document이다. 멈출려면 y 를 쳐줘야 됨…

y ### y를 쳐주고…

### 그냥 빈칸이 아니라 enter이다.

### enter 두번을 해줘야지 되더라.

DD ### hear document .

sleep 1 ### 별 의미없이 1초 쉬어주고

gluster vol del $d << DD ### 이제 gluster volume을 삭제한다.

y ### y를 쳐줘야 지울 수가 있음.…

### 위에도 말했지만 그냥 빈칸이 아님..!! enter이다.

### enter 두번

DD ### hear document . !!

sleep 1 ### 1초 쉬어주고

done ### for 문을 끝낸다.

echo gluster volume deleted’!!’ ————— ### 어떤 볼륨이 지워졌는지 echo로 알려주자.

echo ### 보기 편하게 하기위한 빈칸

### client unmount ###

for c in $CLHOST ### client를 순회하면서 umount를 해준다. 이걸 하려면 같은곳에 mount되어 있어야 한다는 조건이 필요함.

do

ssh $c “umount $CLMOUNTPOINT” ### 해당 볼륨들을 umount 시켜준다.

sleep 1

ssh $c “umount $CLMOUNTPOINT” ### 두번 unmount 시켜준다. 간혹 umount안 될때가 있더라.

echo unmount done’!!’ ——————— ### umount 한것을 알려준다.

echo “” ### 보기 편하게 하기위한 빈칸

done ### for문을 종료한다.

### service remove ###

for I in $HOSTLIST ### 이제 service를 삭제해주자.

do

echo —– $I processing ——————– ### 어디에서 지울지 알려준다.

ssh $I sed -i “/$SEDSEARCHVG/d” /etc/fstab ### fstab에서 volume mount 구문을 지워주고

ssh $I “umount $HSMOUNTPOINT” ### gluster volumeumount를 해준다.

ssh $I “vgremove $DELVG -f” ### volume group을 지워준다. 그럼 알아서 lv도 지워진다.

ssh $I “pvremove $DELPV -f” ### physical volume을 지운다.

gluster peer detach $I ### gluster peer detach

ssh $I “systemctl stop glusterd” ### glusterd stop

ssh $I “systemctl disable glusterd” ### glusterd disable

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

echo “”

done

configuration script 를 다 봤다.

gdeploy config new version

[hosts]

rhgs11.test.dom

rhgs12.test.dom

rhgs13.test.dom

rhgs14.test.dom

rhgs15.test.dom

rhgs16.test.dom

[disktype]

raid6

[diskcount]

10

[stripesize]

128

#[update-file1]

#action=add

#dest=/etc/ntp.conf

#line=server clock.redhat.com iburst

[service1]

action=enable

service=ntpd

[service2]

action=restart

service=ntpd

#[script1]

#action=execute

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

#[script2]

#action=execute

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

[shell100]

action=execute

command=parted -s -a optimal /dev/vda 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/vdb mklabel msdos — mkpart primary ext2 1 -1

[shell103]

action=execute

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

#slow=vda1,vdb1 cache=vdc1,vdd1

[pv]

action=create

devices=vda1,vdc1,vdb1,vdb1

wipefs=yes

force=yes

[vg1]

action=create

vgname=RHGS-VG1

pvname=vda1,vdc1

[lv1]

action=create

vgname=RHGS-VG1

pvname=/dev/vda1

lvname=RHGS-data1

extent=100%PVS

#extent=100%PVS

lvtype=thick

mount=/mnt/gluster1/

mkfs=xfs

mkfs-opts=-i size=512 -n size=8192 -d su=128k -d sw=10 -f

force=yes

ignore_lv_errors=no

#size=3GB

[lv2]

action=setup-cache

ssd=vdc1

vgname=RHGS-VG1

lvname=RHGS-data1

poolname=cache-pool

cache_lv=RHGS-data1-cache-data

cache_lvsize=700M

cache_meta_lv=RHGS-data1-meta-data

cache_meta_lvsize=50M

cachemode=writeback

force=yes

ignore_lv_errors=no

[shell1]

action=execute

command=umount /mnt/gluster1/

[shell2]

action=execute

command=lvconvert –type cache /dev/RHGS-VG1/RHGS-data1 –cachepool /dev/RHGS-VG1/RHGS-data1-cache-data

[shell5]

action=execute

command=mount /dev/RHGS-VG1/RHGS-data1 /mnt/gluster1/

[vg2]

action=create

vgname=RHGS-VG2

pvname=vdb1,vdd1

[lv3]

action=create

vgname=RHGS-VG2

pvname=/dev/vdb1

lvname=RHGS-data2

extent=100%PVS

#size=2400MB

lvtype=thick

mount=/mnt/gluster2/

mkfs=xfs

force=yes

ignore_lv_errors=no

mkfs-opts=-i size=512 -n size=8192 -d su=128k -d sw=10 -f

[lv4]

action=setup-cache

ssd=vdd1

vgname=RHGS-VG2

lvname=RHGS-data2

poolname=cache-pool

cache_lv=RHGS-data2-cache-data

cache_lvsize=700M

cache_meta_lv=RHGS-data2-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/RHGS-VG2/RHGS-data2 –cachepool /dev/RHGS-VG2/RHGS-data2-cache-data

[shell9]

action=execute

command=mount /dev/RHGS-VG2/RHGS-data2 /mnt/gluster2/

[shell10]

action=execute

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

[shell11]

action=execute

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

[shell12]

action=execute

command=setenforce 0

[service4]

action=stop

service=NetworkManager

[service5]

action=disable

service=NetworkManager

[service6]

action=restart

service=glusterd

[service61]

action=enable

service=glusterd

[peer]

action=probe

[service7]

action=start

service=firewalld

[service8]

action=enable

service=firewalld

[service9]

action=stop

service=nfs

[service10]

action=disable

service=nfs

[script3]

action=execute

file=/root/fstab_setup.sh

[firewalld]

action=add

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

services=glusterfs

permanent=true

#[backend-setup]

#devices=/dev/vda1

#lvtype=thick

#poolnanme=gl-pool

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#mkfs=xfs

#force=yes

#[backend-setup:rhgs1]

#devices=/dev/vda1

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#brick_dirs=vol1

#force=yes

#[backend-setup:rhgs2]

#devices=/dev/vda1

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#brick_dirs=vol1

#force=yes

#[backend-setup:rhgs3]

#devices=/dev/vda1

#vgs=vg1

#lvs=lv1

#mountpoints=/mnt/bric1

#brick_dirs=vol1

#force=yes

[tune-profile]

rhgs-sequential-io

[selinux]

no

[volume1]

action=create

volname=glustervol1

transport=tcp

replica=yes

replica_count=2

brick_dirs=/mnt/gluster1/glustervol1/

#force=yes

[volume2]

action=create

volname=glustervol2

transport=tcp

replica=yes

replica_count=2

brick_dirs=/mnt/gluster2/glustervol2/

#force=yes

[clients1]

action=mount

volname=rhgs11:glustervol1

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster1

[clients2]

action=mount

volname=rhgs11:glustervol1

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster1-1

[clients3]

action=mount

volname=rhgs11:glustervol2

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster2

[clients4]

action=mount

volname=rhgs11:glustervol2

hosts=centos7

fstype=glusterfs

client_mount_points=/mnt/gluster2-1

### client discard option mount ###

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 file blocklist { 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

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