GlusterFS をマウントしたいけど順序が・・・
GlusterFS を /etc/fstab に書いてマウントしようとするとなにげに面倒。
チュートリアルに書いてあるように /etc/fstab に記述すると glusterd が立ち上がるより先にマウントしようとしてコケてしまう。(Scientific Linux 6 (RHEL6クローン)使用。)
ならば、glusterd より後にマウントするスクリプトを組めば良いではないか、ということで
以下のような適当スクリプトを組んで /etc/init.d/glustermount にコピーし、sudo /sbin/chkconfig --add glustermount した。試してみたところちゃんと動いている。
スクリプトの上の方にある変数を書き換えればみなさんの環境でも動くはずだ。
#!/bin/bash # # chkconfig: 35 92 11 # description: Mounting Gluster File System # # Get function from functions library . /etc/rc.d/init.d/functions BASE=gluster-mount GLUSTER=/usr/sbin/gluster FSTYPE=glusterfs VOLUME=gbio GLUSTER_HOST=`hostname`-ib MOUNT_POINT=/gluster GLUSTER_OPTS="defaults,transport=ib-verb,direct-io-mode=enable" RETVAL=0 # Start the service $BASE start() { echo -n $"Starting $BASE:" if [ ! -d $MOUNT_POINT ] ; then mkdir -p $MOUNT_POINT fi /bin/mount -t $FSTYPE -o $GLUSTER_OPTS $GLUSTER_HOST:$VOLUME $MOUNT_POINT RETVAL=$? if [ $RETVAL -ne 0 ] ; then failure $"Could not mount" exit $RETVAL fi success $"" echo } # Stop the service $BASE stop() { echo -n $"Stopping $BASE:" /bin/umount $MOUNT_POINT RETVAL=$? if [ $RETVAL -ne 0 ] ; then failure $"Not mounted" exit $RETVAL fi success $"" echo } # Check the status gstatus() { echo -n $"Checking $BASE: " mount | grep $GLUSTER_HOST:$VOLUME > /dev/null 2>&1 RETVAL=$? if [ $RETVAL -ne 0 ] ; then echo "glusterfs is not mounted" exit $RETVAL fi echo "glusterfs is mounted" echo } ### service arguments ### case $1 in start) start ;; stop) stop ;; status) gstatus ;; restart) $0 stop $0 start ;; *) echo $"Usage: $0 {start|stop|status|restart}." exit 1 esac exit $RETVAL