yinl_li 发表于 2019-2-1 13:05:47

glusterfs实战系列-1:类似nfs的方式

  本文环境:一台服务器,一台测试机均为CentOS-5.2操作系统,服务器端的ip为:192.168.10.252,测试机的ip为192.168.10.14 在服务端有一个独立的磁盘用来测试
  一 服务器端的安装和配置
  1.首先安装fuse扩展
  # tar zvxf fuse-2.8.3.tar.gz
  # cd fuse-2.8.3
  # ./configure --enable-dependency-tracking --enable-lib --enable-util
  # make
  # make install
  2. 检查fuse是否安装正确,如果不正确后面启动和挂载glusterfs时候都会报错
  # ll /dev/fuse
  crw-rw-rw- 1 root root 10, 229 Apr 23 14:08 /dev/fuse
  3. 安装服务器端
  # cd ..
  # tar zvxf glusterfs-3.0.3.tar.gz
  # cd glusterfs-3.0.3
  # ./configure --enable-fusermount
http://img1.运维网.com/attachment/201004/26/1246748_1272259273PPcG.jpg
  # make
  # make install
  4. 创建本地的共享点同时挂载硬盘分区
  # mkdir /home/gluster
  # mount /dev/sdb1 /home/gluster/
  # chmod 777 /home/gluster/
  5. 查看挂载是否正常
  # df -lh

  Filesystem>  /dev/mapper/VolGroup00-LogVol00
  7.0G 3.4G 3.2G 52% /
  /dev/sda1 99M 12M 83M 13% /boot
  tmpfs 125M 0 125M 0% /dev/shm
  /dev/sdb1 4.0G 8.0M 3.8G 1% /home/gluster
  6. 开始配置服务器端配置文件,首先先备份示例文件
  #cd /usr/local/etc/glusterfs
  # mkdir bak
  # mv *.sample bak
  # cp bak/glusterfsd.vol.sample glusterfsd.vol
  # echo "" >glusterfsd.vol
  # vi glusterfsd.vol(配置如下)
  ### Export volume "brick" with the contents of "/home/export" directory.
  volume brick
  type storage/posix # POSIX FS translator
  option directory /home/gluster # Export this directory
  end-volume
  volume locker
  type features/locks
  subvolumes brick
  end-volume
  volume bricks
  type performance/io-threads
  option thread-count 50 #//开启50个线程
  subvolumes locker
  end-volume
  ### Add network serving capability to above brick.
  volume server
  type protocol/server
  option transport-type tcp/server
  option listen-port 6996 # Default is 6996
  subvolumes locker
  option auth.addr.bricks.allow *
  option auth.addr.locker.allow *
  end-volume
  7. 启动服务器端
  # glusterfsd -l /var/log/glusterfs.log -f /usr/local/etc/glusterfs/glusterfsd.vol -p /var/run/glusterfs.pid
  启动的过程中指定了pid文件位置和日志文件位置
  8. 验证服务启动是否正常,端口监听
  # netstat -nltp |grep 6996 |grep -v grep
  tcp 0 0 0.0.0.0:6996 0.0.0.0:* LISTEN 27698/glusterfsd
  #
  二 客户端的安装和配置
  1. 和服务器端同样的安装操作此处不多说了,接下来配置客户端配置文件
  #cd /usr/local/etc/glusterfs
  # mkdir bak
  # mv *.sample bak
  # cp bak/glusterfs.vol.sample glusterfs.vol
  # echo "" >glusterfs.vol
  # vi glusterfs.vol
  volume client1
  type protocol/client
  option transport-type tcp/client
  option remote-host 192.168.10.252 #//server ip
  option remote-port 6996
  option remote-subvolume locker
  end-volume
  volume bricks
  type cluster/distribute
  subvolumes client1
  end-volume
  2. 开始客户端的挂载,把服务器端对文件系统挂载到本地的/mnt目录
  #glusterfs -l /var/log/glusterfs.log -f /usr/local/etc/glusterfs/glusterfsd.vol -p /var/run/glusterfs.pid
  同样指定了pid文件和日志文件
  3. 看看是否挂载成了本地文件系统
  # df -h

  Filesystem>  /dev/hda2 5.7G 2.0G 3.4G 38% /
  /dev/hda1 99M 12M 83M 12% /boot
  tmpfs 252M 0 252M 0% /dev/shm
  glusterfs#/usr/local/etc/glusterfs/glusterfs.vol
  7.0G 3.2G 3.4G 49% /mnt
  # mount | tail -1
  glusterfs#/usr/local/etc/glusterfs/glusterfs.vol on /data type fuse (rw,allow_other,default_permissions,max_read=131072)
  #
  三 测试部分
  1. 在服务器的共享点上创建文件和目录
  # cd /home/gluster/
  # touch test
  # mkdir -p qubaoquan
  # ls
  qubaoquan test
  #
  2. 在客户记得挂载点上查看
  # cd /mnt/
  # ls
  qubaoquan test

页: [1]
查看完整版本: glusterfs实战系列-1:类似nfs的方式