Distributed File System on Amazon Linux — MooseFS

By , 2015年5月13日 6:40 上午

[Introduction]

This article provides a quick started guide on how to set up and configure MooseFS on Amazon Linux. Two EC2 instance are being launched to accomplish this goal. On both EC2 instances, there is an instance-store volume serving as the shared storage. One of the EC2 instance is being used as the master server, while both EC2 instances are chunk servers (storage servers).

[Master Server Installation]

Edit /etc/hosts, add the following record (assuming that the private IP of the master node is 172.31.0.10):

172.31.0.10    mfsmaster

Then run the following commands to add the MooseFS repository:

wget http://ppa.moosefs.com/stable/yum/RPM-GPG-KEY-MooseFS
sudo cp RPM-GPG-KEY-MooseFS /etc/pki/rpm-gpg/
wget http://ppa.moosefs.com/stable/yum/MooseFS.repo
sudo cp MooseFS.repo /etc/yum.repos.d/

Install MooseFS master and CLI:

sudo yum update
sudo yum install moosefs-ce-master
sudo yum install moosefs-ce-cli
cd /etc/mfs

In the /etc/mfs folder, you should see mfsmaster.cfg and mfsexports.cfg. If they don’t exist, copy mfsmaster.cfg.dist to mfsmaster.cfg and copy mfsexports.cfg.dist to mfsexports.cfg.

Modify mfsexports.cfg to add permission for the 172.31.0.0/16 subnet. Add this line to the end of the file:

172.31.0.0/16        /    rw.alldirs,maproot=0

One more CRITICAL modification:

cd /var/lib/mfs
sudo cp metadata.mfs.empty metadata.mfs

Start MFS master

sudo service mfsmaster start

At this point, the MooseFS master node is running successfully. You can use the following MFS CLI to do a quick check:

mfscli -SIN

[Chunk Server Installation]

Edit /etc/hosts, add the following record (assuming that the private IP of the master node is 172.31.0.10):

172.31.0.10    mfsmaster

Then run the following commands to add the MooseFS repository:

wget http://ppa.moosefs.com/stable/yum/RPM-GPG-KEY-MooseFS
sudo cp RPM-GPG-KEY-MooseFS /etc/pki/rpm-gpg/
wget http://ppa.moosefs.com/stable/yum/MooseFS.repo
sudo cp MooseFS.repo /etc/yum.repos.d/

Install MooseFS chunk server and CLI:

sudo yum update
sudo yum install moosefs-ce-chunkserver
sudo yum install moosefs-ce-cli
cd /etc/mfs

In the /etc/mfs folder, you should see mfschunkserver.cfg and mfshdd.cfg. If they don’t exist, copy mfschunkserver.cfg.dist to mfschunkserver.cfg and copy mfshdd.cfg.dist to mfshdd.cfg.

Assuming that you have a second EBS volume (or instance-store volume) on your EC2 instance, which is /dev/xvdb, that you would like to use as the storage for MooseFS.

sudo mkfs.ext4 /dev/xvdb
sudo mkdir /mfs
sudo mount /dev/xvdb /mfs
sudo chown -R mfs:mfs /mfs

Then edit /etc/mfs/mfshdd.cfg, add one line to the end of the file:

/mfs

Create a file /etc/default/moosefs-ce-chunkserver, with the following content:

MFSCHUNKSERVER_ENABLE=true

Start MooseFS chunk server with the following command:

sudo service mfschunkserver start

Now you can check the status of the whole storage system using MooseFS CLI:

mfscli -h
mfscli -SCS

[Client Installation]

Edit /etc/hosts, add the following record (assuming that the private IP of the master node is 172.31.0.10):

172.31.0.10    mfsmaster

Then run the following commands to add the MooseFS repository:

wget http://ppa.moosefs.com/stable/yum/RPM-GPG-KEY-MooseFS
sudo cp RPM-GPG-KEY-MooseFS /etc/pki/rpm-gpg/
wget http://ppa.moosefs.com/stable/yum/MooseFS.repo
sudo cp MooseFS.repo /etc/yum.repos.d/

Install MooseFS client and CLI:

sudo yum update
sudo yum install fuse
sudo yum install moosefs-ce-client
sudo yum install moosefs-ce-cli

Actually mount the MooseFS shared storage to local computer:

sudo mkdir -p /mnt/mfs
sudo mfsmount /mnt/mfs -H mfsmaster
df -h

Now the shared file system has been set up, and you can create a text file under /mnt/glusterfs and observe that the file created appears on both EC2 instances. Please bear in mind that this is only a quick start guide, and you should not use this configuration directly in a production system without further tunings.

One Response to “Distributed File System on Amazon Linux — MooseFS”

  1. qyjohn说道:

    If you create an AMI for a chunk server, and the chunk server ended up as “disconnected” when queried by the “muscle -SCS” command, you need to remove /var/lib/mfs/chunkserverid.mfs on the chunk server and restart the chunk server service daemon.

    If you write a large amount of files to MooseFS and then deleted them, you will find that the disk space is not immediately reclaimed by MooseFS. To enable immediate disk space reclaim, you need to set the desired cache period for deleted files. Assuming that MooseFS is mounted to /mnt, and /mnt/test is a folder containing your test files, you will need to do the following to delete your files:

    $ cd /mnt
    $ mfssettrashtime -r 0 test
    $ rm -Rf test

Leave a Reply

Panorama Theme by Themocracy