summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml20
-rw-r--r--CentOS/Dockerfile2
-rw-r--r--CentOS/gluster-setup.sh107
-rw-r--r--Fedora/Dockerfile27
-rw-r--r--Fedora/gluster-setup.service10
-rw-r--r--Fedora/gluster-setup.sh96
6 files changed, 215 insertions, 47 deletions
diff --git a/.travis.yml b/.travis.yml
index 78f0592..3bc0479 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,10 +21,30 @@ before_install:
- docker run -d --name gcentos --privileged gluster/centos
- sleep 10
- docker exec -it gcentos systemctl is-active glusterd
+- docker stop gcentos
+- docker rm gcentos
+- sudo mkdir -p /home/centos-glusterd
+- sudo mkdir -p /home/centos-gluster-etc
+- sudo mkdir -p /home/centos-gluster-log
+- docker run -d --name gcentos -v /home/centos-glusterd:/var/lib/glusterd/:z -v /home/centos-gluster-etc:/etc/glusterfs:z -v /home/centos-gluster-log:/var/log/glusterfs --privileged gluster/centos
+- sleep 10
+- docker exec -it gcentos systemctl is-active glusterd
+- docker stop gcentos
+- docker rm gcentos
- docker build -t gluster/fedora ./Fedora/
- docker run -d --name gfedora --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro gluster/fedora
- sleep 10
- docker exec -it gfedora systemctl is-active glusterd
+- docker stop gfedora
+- docker rm gfedora
+- sudo mkdir -p /home/fedora-glusterd
+- sudo mkdir -p /home/fedora-gluster-etc
+- sudo mkdir -p /home/fedora-gluster-log
+- docker run -d --name gfedora -v /home/fedora-glusterd:/var/lib/glusterd/:z -v /home/fedora-gluster-etc:/etc/glusterfs:z -v /home/fedora-gluster-log:/var/log/glusterfs -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged gluster/fedora
+- sleep 10
+- docker exec -it gfedora systemctl is-active glusterd
+- docker stop gfedora
+- docker rm gfedora
- docker build -t gluster/s3object ./gluster-s3object/CentOS/docker-gluster-s3/
- docker run -d --name s3object --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -e S3_ACCOUNT=vol -e S3_USER="admin" -e S3_PASSWORD="redhat" gluster/s3object
- sleep 10
diff --git a/CentOS/Dockerfile b/CentOS/Dockerfile
index db7a578..c2a12f2 100644
--- a/CentOS/Dockerfile
+++ b/CentOS/Dockerfile
@@ -23,7 +23,7 @@ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;\
-yum --setopt=tsflags=nodocs -y install wget nfs-utils attr iputils iproute openssh-server openssh-clients ntp rsync tar cronie sudo xfsprogs glusterfs glusterfs-server glusterfs-geo-replication;yum clean all; \
+yum --setopt=tsflags=nodocs -y install nfs-utils attr iputils iproute openssh-server openssh-clients ntp rsync tar cronie sudo xfsprogs glusterfs glusterfs-server glusterfs-geo-replication;yum clean all; \
sed -i '/Defaults requiretty/c\#Defaults requiretty' /etc/sudoers; \
sed -i '/Port 22/c\Port 2222' /etc/ssh/sshd_config; \
sed -i 's/Requires\=rpcbind\.service//g' /usr/lib/systemd/system/glusterd.service; \
diff --git a/CentOS/gluster-setup.sh b/CentOS/gluster-setup.sh
index 98570f5..1fdaf37 100644
--- a/CentOS/gluster-setup.sh
+++ b/CentOS/gluster-setup.sh
@@ -13,57 +13,84 @@
###
main () {
- if test "$(ls /var/lib/heketi/fstab)"
- then
- mount -a --fstab /var/lib/heketi/fstab
- if [ $? -eq 1 ]
- then
- echo "mount failed"
- exit 1
- fi
- echo "Mount Successful"
- else
- echo "heketi-fstab not found"
- fi
- DIR_1="/etc/glusterfs"
- DIR_2="/var/log/glusterfs"
- DIR_3="/var/lib/glusterd"
- var=0
- for i in $DIR_1 $DIR_2 $DIR_3
+ GLUSTERFS_CONF_DIR="/etc/glusterfs"
+ GLUSTERFS_LOG_DIR="/var/log/glusterfs"
+ GLUSTERFS_META_DIR="/var/lib/glusterd"
+ GLUSTERFS_LOG_CONT_DIR="/var/log/glusterfs/container"
+ GLUSTERFS_CUSTOM_FSTAB="/var/lib/heketi/fstab"
+
+ mkdir $GLUSTERFS_LOG_CONT_DIR
+ for i in $GLUSTERFS_CONF_DIR $GLUSTERFS_LOG_DIR $GLUSTERFS_META_DIR
do
if test "$(ls $i)"
then
- echo "$i is not empty"
- var=$((var+1))
+ echo "$i is not empty"
+ else
+ bkp=$i"_bkp"
+ cp -r $bkp/* $i
+ if [ $? -eq 1 ]
+ then
+ echo "Failed to copy $i"
+ exit 1
+ fi
+ ls -R $i > ${GLUSTERFS_LOG_CONT_DIR}/${i}_ls
fi
done
- if [ $var -eq 3 ]
+ if test "$(ls $GLUSTERFS_LOG_CONT_DIR)"
then
- exit 1
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/brickattr
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/lvscan
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ else
+ mkdir $GLUSTERFS_LOG_CONT_DIR
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/brickattr
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/failed_bricks
fi
-
- cp -r /etc/glusterfs_bkp/* /etc/glusterfs
- if [ $? -eq 1 ]
+ if test "$(ls $GLUSTERFS_CUSTOM_FSTAB)"
then
- echo "Failed to copy $DIR_1"
- exit 1
- fi
-
- cp -r /var/log/glusterfs_bkp/* /var/log/glusterfs
- if [ $? -eq 1 ]
- then
- echo "Failed to copy $DIR_2"
- exit 1
+ sleep 5
+ pvscan > $GLUSTERFS_LOG_CONT_DIR/pvscan
+ vgscan > $GLUSTERFS_LOG_CONT_DIR/vgscan
+ lvscan > $GLUSTERFS_LOG_CONT_DIR/lvscan
+ mount -a --fstab $GLUSTERFS_CUSTOM_FSTAB > $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ if [ $? -eq 1 ]
+ then
+ echo "mount binary not failed" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ exit 1
+ fi
+ echo "Mount command Successful" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ sleep 40
+ cut -f 2 -d " " $GLUSTERFS_CUSTOM_FSTAB | while read -r line
+ do
+ if grep -qs "$line" /proc/mounts; then
+ echo "$line mounted." >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ if test "ls $line/brick"
+ then
+ echo "$line/brick is present" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ getfattr -d -m . -e hex "$line"/brick >> $GLUSTERFS_LOG_CONT_DIR/brickattr
+ else
+ echo "$line/brick is not present" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ sleep 1
+ fi
+ else
+ grep "$line" $GLUSTERFS_CUSTOM_FSTAB >> $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ echo "$line not mounted." >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ sleep 0.5
+ fi
+ done
+ if [ "$(wc -l $GLUSTERFS_LOG_CONT_DIR/failed_bricks )" -gt 1 ]
+ then
+ vgscan --mknodes > $GLUSTERFS_LOG_CONT_DIR/vgscan_mknodes
+ sleep 10
+ mount -a --fstab $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ fi
+ else
+ echo "heketi-fstab not found"
fi
- cp -r /var/lib/glusterd_bkp/* /var/lib/glusterd
- if [ $? -eq 1 ]
- then
- echo "Failed to copy $DIR_3"
- exit 1
- fi
-
echo "Script Ran Successfully"
+ exit 0
}
main
diff --git a/Fedora/Dockerfile b/Fedora/Dockerfile
index fc3f722..c0ea63d 100644
--- a/Fedora/Dockerfile
+++ b/Fedora/Dockerfile
@@ -25,14 +25,29 @@ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*; \
-yum --setopt=tsflags=nodocs -y install wget nfs-utils iputils iproute attr glusterfs glusterfs-server glusterfs-geo-replication openssh-server; yum clean all;\
-systemctl disable nfs-server.service;\
-systemctl enable rpcbind.service;\
-systemctl enable glusterd.service;
+yum --setopt=tsflags=nodocs -y install ntp nfs-utils iputils iproute attr glusterfs glusterfs-server glusterfs-geo-replication openssh-server; yum clean all;\
+sed -i '/Port 22/c\Port 2222' /etc/ssh/sshd_config; \
+sed -i 's/Requires\=rpcbind\.service//g' /usr/lib/systemd/system/glusterd.service; \
+sed -i 's/rpcbind\.service/gluster-setup\.service/g' /usr/lib/systemd/system/glusterd.service; \
+mkdir -p /etc/glusterfs_bkp /var/lib/glusterd_bkp /var/log/glusterfs_bkp;\
+cp -r /etc/glusterfs/* /etc/glusterfs_bkp;\
+cp -r /var/lib/glusterd/* /var/lib/glusterd_bkp;\
+cp -r /var/log/glusterfs/* /var/log/glusterfs_bkp; \
+sed -i.save -e "s#udev_sync = 1#udev_sync = 0#" -e "s#udev_rules = 1#udev_rules = 0#" -e "s#use_lvmetad = 1#use_lvmetad = 0#" /etc/lvm/lvm.conf;
VOLUME [ "/sys/fs/cgroup" ]
-
-EXPOSE 22 111 245 443 24007 2049 8080 6010 6011 6012 38465 38466 38468 38469 49152 49153 49154 49156 49157 49158 49159 49160 49161 49162 49163
+ADD gluster-setup.service /etc/systemd/system/gluster-setup.service
+ADD gluster-setup.sh /usr/sbin/gluster-setup.sh
+
+RUN chmod 644 /etc/systemd/system/gluster-setup.service; \
+chmod 500 /usr/sbin/gluster-setup.sh; \
+systemctl disable nfs-server.service; \
+systemctl mask getty.target; \
+systemctl enable ntpd.service; \
+systemctl enable glusterd.service; \
+systemctl enable gluster-setup.service;
+
+EXPOSE 2222 111 245 443 24007 2049 8080 6010 6011 6012 38465 38466 38468 38469 49152 49153 49154 49156 49157 49158 49159 49160 49161 49162 49163
CMD ["/usr/sbin/init"]
diff --git a/Fedora/gluster-setup.service b/Fedora/gluster-setup.service
new file mode 100644
index 0000000..4bb8b68
--- /dev/null
+++ b/Fedora/gluster-setup.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Configuring GlusterFS in container
+Before=glusterd.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/gluster-setup.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/Fedora/gluster-setup.sh b/Fedora/gluster-setup.sh
new file mode 100644
index 0000000..77ec6ef
--- /dev/null
+++ b/Fedora/gluster-setup.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+###
+# Description: Script to move the glusterfs initial setup to bind mounted directories of Atomic Host.
+# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
+#
+# This file is part of GlusterFS.
+#
+# This file is licensed to you under your choice of the GNU Lesser
+# General Public License, version 3 or any later version (LGPLv3 or
+# later), or the GNU General Public License, version 2 (GPLv2), in all
+# cases as published by the Free Software Foundation.
+###
+
+main () {
+ GLUSTERFS_CONF_DIR="/etc/glusterfs"
+ GLUSTERFS_LOG_DIR="/var/log/glusterfs"
+ GLUSTERFS_META_DIR="/var/lib/glusterd"
+ GLUSTERFS_LOG_CONT_DIR="/var/log/glusterfs/container"
+ GLUSTERFS_CUSTOM_FSTAB="/var/lib/heketi/fstab"
+
+ mkdir $GLUSTERFS_LOG_CONT_DIR
+ for i in $GLUSTERFS_CONF_DIR $GLUSTERFS_LOG_DIR $GLUSTERFS_META_DIR
+ do
+ if test "$(ls $i)"
+ then
+ echo "$i is not empty"
+ else
+ bkp=$i"_bkp"
+ cp -r $bkp/* $i
+ if [ $? -eq 1 ]
+ then
+ echo "Failed to copy $i"
+ exit 1
+ fi
+ ls -R $i > ${GLUSTERFS_LOG_CONT_DIR}/${i}_ls
+ fi
+ done
+
+ if test "$(ls $GLUSTERFS_LOG_CONT_DIR)"
+ then
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/brickattr
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/lvscan
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ else
+ mkdir $GLUSTERFS_LOG_CONT_DIR
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/brickattr
+ echo "" > $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ fi
+ if test "$(ls $GLUSTERFS_CUSTOM_FSTAB)"
+ then
+ sleep 5
+ pvscan > $GLUSTERFS_LOG_CONT_DIR/pvscan
+ vgscan > $GLUSTERFS_LOG_CONT_DIR/vgscan
+ lvscan > $GLUSTERFS_LOG_CONT_DIR/lvscan
+ mount -a --fstab $GLUSTERFS_CUSTOM_FSTAB > $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ if [ $? -eq 1 ]
+ then
+ echo "mount binary not failed" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ exit 1
+ fi
+ echo "Mount command Successful" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ sleep 40
+ cut -f 2 -d " " $GLUSTERFS_CUSTOM_FSTAB | while read line
+ do
+ if grep -qs "$line" /proc/mounts; then
+ echo "$line mounted." >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ if test "ls $line/brick"
+ then
+ echo "$line/brick is present" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ getfattr -d -m . -e hex $line/brick >> $GLUSTERFS_LOG_CONT_DIR/brickattr
+ else
+ echo "$line/brick is not present" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ sleep 1
+ fi
+ else
+ grep $line $GLUSTERFS_CUSTOM_FSTAB >> $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ echo "$line not mounted." >> $GLUSTERFS_LOG_CONT_DIR/mountfstab
+ sleep 0.5
+ fi
+ done
+ if [ $(wc -l $GLUSTERFS_LOG_CONT_DIR/failed_bricks ) -gt 1 ]
+ then
+ vgscan --mknodes > $GLUSTERFS_LOG_CONT_DIR/vgscan_mknodes
+ sleep 10
+ mount -a --fstab $GLUSTERFS_LOG_CONT_DIR/failed_bricks
+ fi
+ else
+ echo "heketi-fstab not found"
+ fi
+
+ echo "Script Ran Successfully"
+ exit 0
+}
+main