Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Introduction to MooseFS: Architecture, Deployment, and Management

Tech Nov 15 17

Overview of MooseFS

MooseFS (MFS) is a fault-tolerant, distributed network file system that stores data across multiple physical servers, disks, or partitions, maintaining redundant copies for reliability. To clients, the entire cluster appears as a single unified filesystem, behaving similarly to tradisional Unix filesystems like ext4 or NFS.

  • Uses a hierarchical directory tree structure.
  • Supports POSIX-compliant file attributes (permissions, access/modification times).
  • Handles special files: block/character devices, pipes, sockets, symbolic/hard links.
  • Offers IP-based and password-authenticated cliant access.

Key Features

  • High Reliability: Configurable replication (e.g., 3 copies across different hosts).
  • Scalability: Storage capacity grows dynamically by adding disks or servers.
  • Trash Mechanism: Deleted files remain recoverable for a configurable period.
  • Consistency: Supports consistent snapshots during concurrent read/write operations.

Advantages

  • Lightweight, simple configuration, and easy maintenance.
  • Online expension without service interruption.
  • Active development and community support.
  • Presents stored objects (e.g., images) as regular files on client mounts.
  • Efficient disk utilization with configurable trash retention.
  • Distributed I/O load across all chunk servers.

Limitations

  • Master server was historically a single point of failure (SPoF), though mitigated via DRBD+Heartbeat or similar HA setups.
  • Master requires significant RAM (e.g., ~300 MB for 1 million files).
  • Metadata logger (Metalogger) sync intervals may be slow by default.

Use Cases

  • High-concurrency storage for both small and large files.
  • Log processing and analytics where HDFS is overkill.

Note: Avoid using distributed filesystems unnecessarily; consider front-end caching first.

Comparison with Other Distributed Filesystems

  • MogileFS: Key-value store; no FUSE support; optimized for web-scale small files.
  • FastDFS: Chinese-developed MogileFS variant; better performance, no FUSE.
  • GlusterFS: Stackable architecture, no metadata server, linear scalability.
  • Ceph: Fully distributed, kernel-integrated (since Linux 2.6.34), but historically unstable due to btrfs dependency.
  • Lustre: Enterprise-grade but complex; requires kernel recompilation.

System Architecture

MooseFS consists of four components:

  1. Master Server: Manages metadata and coordinates the system.
  2. Metalogger: Backs up metadata change logs for disaster recovery.
  3. Chunk Servers: Store actual file data in 64 MB chunks.
  4. Clients: Mount the filesystem via FUSE, similar to NFS.

Data Flow

  • Read: Client → Master (gets chunk locations) → Chunk Server (fetches data).
  • Write: Client → Master (allocates chunks) → Chunk Server (writes + replicates) → Ack to client → Notify master.

Deployment Environment


Master:       192.168.1.100
Backup:       192.168.1.101
ChunkServer1: 192.168.1.102 (+10G disk)
ChunkServer2: 192.168.1.103 (+10G disk)
ChunkServer3: 192.168.1.104 (+10G disk)
Client:       192.168.1.105

Common Setup Steps (All Nodes)


# /etc/hosts
192.168.1.100 master
192.168.1.101 backup
192.168.1.102 data1
192.168.1.103 data2
192.168.1.104 data3
192.168.1.105 client

# Disable firewall
/etc/init.d/iptables stop

# Time sync
ntpdate cn.pool.ntp.org

# Set hostname
hostname <role>

Master Server Setup


# Create user
useradd -s /sbin/nologin -M mfs

# Install dependencies
yum install -y gcc gcc-c++ zlib-devel fuse-devel fuse

# Build from source
tar xf mfs-1.6.27-1.tar.gz
cd mfs-1.6.27
./configure --prefix=/opt/mfs --with-default-user=mfs --with-default-group=mfs
make && make install

# Configure exports
cat > /opt/mfs/etc/mfsexports.cfg <<EOF
*             .       rw
192.168.1.0/24 /       rw,alldirs,mapall=mfs:mfs,password=111111
EOF

# Initialize metadata
cp /opt/mfs/var/mfs/metadata.mfs.empty /opt/mfs/var/mfs/metadata.mfs
chown -R mfs:mfs /opt/mfs

# Start master
/opt/mfs/sbin/mfsmaster start

Key Configuration Files

  • mfsmaster.cfg: Controls ports (9420 for chunks, 9421 for clients, 9419 for Metalogger), replication delays, and memory settings.
  • mfsexports.cfg: Defines client access rules (IP ranges, paths, permissions like rw, alldirs).

Web Monitoring


/opt/mfs/sbin/mfscgiserv start  # Listens on port 9425

Metalogger Setup


# Copy MFS binaries from master
scp master:/opt/mfs.tar.gz /
tar xf mfs.tar.gz

# Configure
echo "MASTER_HOST = 192.168.1.100" > /opt/mfs/etc/mfsmetalogger.cfg

# Start
useradd -s /sbin/nologin -M mfs
chown -R mfs:mfs /opt/mfs
/opt/mfs/sbin/mfsmetalogger start

Chunk Server Setup


# Prepare disk
parted /dev/vdb mklabel gpt
parted /dev/vdb mkpart primary 1 100%
mkfs.ext4 /dev/vdb1
mount /dev/vdb1 /data

# Configure
echo "MASTER_HOST = 192.168.1.100" > /opt/mfs/etc/mfschunkserver.cfg
echo "/data" > /opt/mfs/etc/mfshdd.cfg

# Permissions and start
chown -R mfs:mfs /opt/mfs /data
/opt/mfs/sbin/mfschunkserver start

Note: Each chunk server must have >1 GB usable space; MFS reserves 256 MB per volume.

Client Mounting


# Load FUSE module
modprobe fuse
echo "modprobe fuse" >> /etc/rc.modules
chmod +x /etc/rc.modules

# Mount
mkdir -p /mnt/mfs /mnt/mfsmeta
/opt/mfs/bin/mfsmount /mnt/mfs -H 192.168.1.100 -o mfspassword=111111
/opt/mfs/bin/mfsmount -m /mnt/mfsmeta -H 192.168.1.100 -o mfspassword=111111

File Management Commands


# Check/set replication goal
mfsgetgoal file.txt
mfssetgoal -r 3 /path

# Manage trash retention
mfsgettrashtime file.txt
mfssettrashtime -r 7200 /path

# Restore deleted file
mv /mnt/mfsmeta/trash/0000002\|filename undel/

Startup/Shutdown Order

  • Start: Master → Chunk Servers → Metalogger → Clients
  • Stop: Unmount Clients → Stop Chunk Servers → Stop Metalogger → Stop Master

Disaster Recovery

If the Master fails:

  1. Deploy a new Master with identical config.

  2. Copy Metalogger’s /opt/mfs/var/mfs/ logs to the new Master.

  3. Rebuild metadata: ```

    mfsmetarestore -m metadata_ml.mfs.back -o metadata.mfs changelog_ml.*.mfs /opt/mfs/sbin/mfsmaster start

    
     If startup fails, run `mfsmetarestore -a` for auto-repair.
    
    

High Availability for Master

  • Use DRBD + Heartbeat to replicate Master state.
  • Alternative: Keepalived + inotify for failover.
Tags: MooseFS

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.