Debian下配置GlusterFS安裝和配置

服務端安裝

初始化基礎環境

  • 假設2個節點作2個副本,修改hosts文件。追加 /etc/hosts
192.168.18.15	storage-5
192.168.18.16	storage-6
  • 格式化2臺服務端的磁盤,多個存儲節點都要執行
apt-get -y install glusterfs-server # yum -y install glusterfs-server
mkfs.xfs -i size=512 /dev/sdb
mkdir -pv /mnt/gfs
mount /dev/sdb /mnt/gfs # 記得更新 /etc/fstab
mkdir -pv /mnt/gfs/public-share # 假設要新建一個 public-share 共享點

組建GlusterFS集羣

glusterfsd --version
gluster peer probe storage-6 # 任1節點執行增長新節點

建立存儲卷

gluster volume create public-share replica 2 storage-5:/mnt/gfs/public-share storage-6:/mnt/gfs/public-share
glusterfsd --version
gluster volume info
gluster volume status
gluster volume start public-share
gluster volume quota public-share  enable
gluster volume quota public-share  limit-usage / 1024GB
gluster volume set public-share performance.write-behind-window-size 512MB
gluster volume set public-share performance.cache-size 512MB
gluster volume set public-share performance.io-thread-count 32
gluster volume set public-share auth.allow 192.168.18.*,192.168.16.*
gluster volume set public-share nfs.disable on

客戶端配置

安裝客戶端並掛載

wget -O - http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.5/Debian/jessie/pub.key | apt-key add -
echo 'deb http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.5/Debian/jessie/apt jessie main' > /etc/apt/sources.list.d/gluster.list 
apt-get update
apt-get -y install glusterfs-client
mkdir -pv /mnt/gfs
mount -t glusterfs -o rw storage-5:/public-share /mnt/gfs # 記得添加開機啓動或fstab

注意事項

  • 不推薦使用nfs掛載,由於它有單點故障致使應用卡死。
  • 客戶端儘可能同服務器版本保持一致,不然可能沒法進行Runtime Setting
# gluster volume set public-share auth.allow 192.168.*

volume set: failed: Staging failed on storage-5. Error: One or more connected clients cannot support the feature being set. These clients need to be upgraded or disconnected before running this command againnode

  • 若是要使用nfs掛載,筆者的參數示例:
mount -t nfs -o rw,nosuid,nodev,noexec,nouser,bg,soft,intr,rsize=1048576,wsize=1048576,timeo=10,acregmin=3,acregmax=10,acdirmin=1,acdirmax=5 storage-5:/public-share /mnt/log
  • GlusterFS錯誤日誌不少,加個計劃任務天天清:
echo '#!/bin/bash' > /etc/cron.daily/clean-glusterfs
echo 'rm -f /var/log/glusterfs/*.log.*; for logfile in $(find /var/log/glusterfs -type f -name "*.log"); do :>$logfile ;done' >> /etc/cron.daily/clean-glusterfs
chmod +x /etc/cron.daily/clean-glusterfs
相關文章
相關標籤/搜索