2019年8月12日月曜日

Vagrantで3ノード構成のGluster Serverをインストールした仮想マシン(Debian Buster/10)を構築する

GlusterFSは分散ファイルシステムです。以下のVagrantfileを使用して、3ノード構成のGluster Serverをインストールした仮想マシン(Debian Buster/10)を構築する事ができます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "glusternode1" do |server|
    server.vm.box = "bento/debian-10"
    server.vm.hostname = "glusternode1"
server.vm.network :public_network, ip:"192.168.1.107"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "glusternode1"
      vbox.cpus = 2
      vbox.memory = 2048
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*glusternode1$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.1.107    glusternode1
192.168.1.108    glusternode2
192.168.1.109    glusternode3
EOF

# update packages
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo

# create the brick directory
mkdir -p /gluster/data/myvol1/brick1/brick

# install gluster server
apt-get update 
apt-get -y upgrade
sudo apt-get -y install glusterfs-server
systemctl enable glusterd
systemctl start glusterd
systemctl status glusterd

echo 'localhost:/gfs /mnt glusterfs defaults,_netdev,backup-volfile-servers=glusternode2:glusternode3 0 0' >> /etc/fstab

SHELL
  end
  #----------------------------------------------------------------------------------------
  config.vm.define "glusternode2" do |server|
    server.vm.box = "bento/debian-10"
    server.vm.hostname = "glusternode2"
server.vm.network :public_network, ip:"192.168.1.108"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "glusternode2"
      vbox.cpus = 2
      vbox.memory = 2048
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*glusternode2$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.1.107    glusternode1
192.168.1.108    glusternode2
192.168.1.109    glusternode3
EOF

# update packages
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo

# create the brick directory
mkdir -p /gluster/data/myvol1/brick1/brick

# install gluster server
apt-get update 
apt-get -y upgrade
sudo apt-get -y install glusterfs-server
systemctl enable glusterd
systemctl start glusterd
systemctl status glusterd

echo 'localhost:/gfs /mnt glusterfs defaults,_netdev,backup-volfile-servers=glusternode1:glusternode3 0 0' >> /etc/fstab

SHELL
  end
  #----------------------------------------------------------------------------------------
  config.vm.define "glusternode3" do |server|
    server.vm.box = "bento/debian-10"
    server.vm.hostname = "glusternode3"
server.vm.network :public_network, ip:"192.168.1.109"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "glusternode3"
      vbox.cpus = 2
      vbox.memory = 2048
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*glusternode3$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.1.107    glusternode1
192.168.1.108    glusternode2
192.168.1.109    glusternode3
EOF

# update packages
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo

# create the brick directory
mkdir -p /gluster/data/myvol1/brick1/brick

# install gluster server
apt-get update 
apt-get -y upgrade
sudo apt-get -y install glusterfs-server
systemctl enable glusterd
systemctl start glusterd
systemctl status glusterd

# peer with other nodes
gluster peer probe glusternode1
gluster peer probe glusternode2
gluster peer status

# create replicated volume.
gluster volume create gfs \
replica 3 \
glusternode1:/gluster/data/myvol1/brick1/brick \
glusternode2:/gluster/data/myvol1/brick1/brick \
glusternode3:/gluster/data/myvol1/brick1/brick \
force
gluster volume start gfs


# set auth.allow for thevolume
gluster volume set gfs auth.allow 192.168.1.*

echo 'localhost:/gfs /mnt glusterfs defaults,_netdev,backup-volfile-servers=glusternode1:glusternode2 0 0' >> /etc/fstab

echo 'please execute "vagrant reload" on the host machine.'
SHELL
  end
  #----------------------------------------------------------------------------------------

end

0 件のコメント:

コメントを投稿