Skip to content

Deploying MooseFS Pro 4.x on Ubuntu 22.04 — master + metalogger + chunkservers

Stand up a MooseFS Pro 4.x cluster on Ubuntu 22.04 — a master, a metalogger for metadata redundancy, three chunkservers, FUSE clients, and a goal-driven replication policy.

You’ve been running NFS-on-an-LVM-volume for a media pipeline and the operations team is unhappy: a single host services everything, scaling means doubling the disks on that host, and the only way to add a replica is to migrate to something else. The team picks MooseFS because the data model (a single master that tracks the namespace, chunkservers that hold replicated 64 MB chunks, FUSE clients that read directly from the chunkservers) is the closest thing to NFS-with-replication that still scales, and the Pro license adds the failover that the community edition lacks. This article stands up a MooseFS Pro 4.x cluster with one master, one metalogger for metadata redundancy, three chunkservers, and a goal-driven replication policy.

What’s happening

MooseFS is a centralized-metadata distributed filesystem. One process (mfsmaster) owns the namespace, the file→chunk map, and the goal (replication factor) of every chunk. The chunks themselves — 64 MB blocks of file data — live on chunkserver processes that register with the master, report what they hold, and serve the chunks directly to clients. A FUSE client (mfsmount) asks the master “where is the chunk for this offset” and then talks to the chunkserver directly, so master bandwidth never gates I/O. The pieces that matter operationally: the master is a single point of failure for metadata, which is why Pro adds an automated failover master and the metalogger feeds it a replay log; the chunkserver count determines how many goal levels you can satisfy (goal 3 needs at least three chunkservers, goal 2 needs at least two); replication is per-directory or per-file via mfssetgoal, so a hot pipeline can run goal=3 while archival sits at goal=2; trash retention is on by default and a deleted file lingers for 24 hours in /trash before reclamation, which is one of the operational features that justifies the choice. The mistakes that bite small clusters: running a master without a metalogger so a single metadata corruption is unrecoverable, putting the master and chunkserver on the same VM so a master crash takes the local chunks offline, and setting goal=1 on a directory by mistake — one disk failure away from data loss.

How to verify

Cluster health from the master:

mfsstat | head -30
# mfsmaster server version
# server: 4.57.6
# uptime: 1d 2h 30m
# total space: 12.0 TiB
# free space: 11.7 TiB
# all chunks: 1024
# regular chunks: 1024
# missing chunks: 0
# pending deletes: 0

Chunkserver inventory:

mfscli -SCS
# IP        port hostname     version   maintain  load  total used free
# 10.40.0.13 9422 mfs-cs01    4.57.6    no        0    4 TiB ...
# 10.40.0.14 9422 mfs-cs02    4.57.6    no        0    4 TiB ...
# 10.40.0.15 9422 mfs-cs03    4.57.6    no        0    4 TiB ...

Chunk health — every chunk should match its goal exactly. Under-replicated chunks should drain to zero within minutes after a chunkserver loss:

mfscli -SCC
# valid copies:
#   0 copies   1 copies   2 copies   3 copies   4+ copies
#   0          0          0          1024       0

End-to-end from a client mount:

mount.moosefs mfs-master.local:9421 /mnt/mfs -o mfssubfolder=/
mfssetgoal 3 /mnt/mfs/test
dd if=/dev/urandom of=/mnt/mfs/test/file.bin bs=1M count=64 status=progress
mfsfileinfo /mnt/mfs/test/file.bin
# file.bin:
#   chunk 0: ABCD CRC = ...
#     copy 1: 10.40.0.13:9422 ...
#     copy 2: 10.40.0.14:9422 ...
#     copy 3: 10.40.0.15:9422 ...

If mfsfileinfo shows fewer copies than the goal on a file that’s older than mfsmaster.cfg’s REPLICATION_DELAY_DISCONNECT (default 3600s), one of the chunkservers is silently absent. Investigate before you trust the cluster with new writes.

The fix

Save the script as /root/setup-moosefs-node.sh and run it on each node with the correct NODE_ROLE set (master, metalogger, or chunkserver). The script does a full Ubuntu 22.04 install: base hardening (UFW, fail2ban, unattended-upgrades, SSH key-only), kernel/sysctl tuning for a metadata-heavy workload (fs.file-max, net.core.somaxconn, vm.dirty_*), the MooseFS Pro 4.x APT repo and packages, the role-specific configuration (mfsmaster, mfsmetalogger, or mfschunkserver), a chunkserver disk inventory that uses every block device under /data/mfs/, and a smoke-test FUSE mount on the master host after install.

#!/usr/bin/env bash
set -euo pipefail

### Ubuntu 22.04 MooseFS Pro 4.x installer
### Role per node: master, metalogger, or chunkserver
### Pro license required (free trial available from moosefs.com)

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT PER NODE ===
NODE_NAME="mfs-master"          # mfs-master / mfs-metalogger / mfs-cs01 / mfs-cs02 / mfs-cs03
NODE_IP="10.40.0.11"
NODE_ROLE="master"              # master | metalogger | chunkserver
MASTER_IP="10.40.0.11"          # same as NODE_IP if this IS the master
MASTER_HOSTNAME="mfs-master"
CHUNKSERVER_DATA_ROOT="/data/mfs"   # only used on chunkservers
CHUNKSERVER_DEVS=("/dev/sdb" "/dev/sdc")  # one or more dedicated block devices
EXPORT_NETWORK="10.40.0.0/16"   # client subnet allowed to mount
# =====================

echo
echo "========================================"
echo "MooseFS ${NODE_ROLE} node ${NODE_NAME} (${NODE_IP})"
echo "========================================"
echo

echo "==> Hosts file"
if ! grep -q "${MASTER_HOSTNAME}" /etc/hosts; then
  echo "${MASTER_IP} ${MASTER_HOSTNAME}" >> /etc/hosts
fi
hostnamectl set-hostname "${NODE_NAME}"

echo "==> Base packages"
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y install software-properties-common ca-certificates curl gnupg \
  xfsprogs lvm2 ufw fail2ban unattended-upgrades chrony jq socat \
  openssl tcpdump bind9-dnsutils net-tools fuse3

systemctl enable --now chrony

echo "==> Sysctl tuning"
cat > /etc/sysctl.d/99-moosefs.conf <<'SYSCTL'
vm.swappiness = 10
vm.dirty_background_ratio = 5
vm.dirty_ratio = 15
fs.file-max = 2097152
fs.aio-max-nr = 1048576
fs.inotify.max_user_watches = 524288
net.core.somaxconn = 4096
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 87380 16777216
net.ipv4.tcp_syncookies = 1
SYSCTL
sysctl --system

cat > /etc/security/limits.d/99-moosefs.conf <<'LIMITS'
mfs soft nofile 200000
mfs hard nofile 200000
root soft nofile 200000
root hard nofile 200000
LIMITS

echo "==> SSH hardening"
sed -i 's|^#\?PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^#\?PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart ssh

echo "==> fail2ban + unattended-upgrades"
cat > /etc/fail2ban/jail.d/sshd.local <<'F2B'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
F2B
systemctl enable --now fail2ban
dpkg-reconfigure -fnoninteractive unattended-upgrades

echo "==> UFW rules per role"
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp

case "${NODE_ROLE}" in
  master)
    # 9419 metalogger, 9420 chunkserver, 9421 client, 9425 cgi
    ufw allow from "${EXPORT_NETWORK}" to any port 9419 proto tcp
    ufw allow from "${EXPORT_NETWORK}" to any port 9420 proto tcp
    ufw allow from "${EXPORT_NETWORK}" to any port 9421 proto tcp
    ufw allow from "${EXPORT_NETWORK}" to any port 9425 proto tcp
    ;;
  metalogger)
    # outbound to master only — no inbound listeners
    :
    ;;
  chunkserver)
    # 9422 chunkserver, 9425 cgi
    ufw allow from "${EXPORT_NETWORK}" to any port 9422 proto tcp
    ufw allow from "${EXPORT_NETWORK}" to any port 9425 proto tcp
    ;;
esac

ufw --force enable

echo "==> Adding MooseFS Pro 4 APT repo"
curl -fsSL "https://ppa.moosefs.com/moosefs.key" | gpg --dearmor -o /usr/share/keyrings/moosefs.gpg
cat > /etc/apt/sources.list.d/moosefs.list <<EOF
deb [signed-by=/usr/share/keyrings/moosefs.gpg] https://ppa.moosefs.com/moosefs-4/apt/ubuntu/jammy jammy main
EOF
apt-get update

case "${NODE_ROLE}" in
  master)
    echo "==> Installing MooseFS Pro master + cli + cgi"
    apt-get -y install moosefs-pro-master moosefs-pro-cli moosefs-pro-cgi moosefs-pro-cgiserv

    if [[ ! -f /etc/mfs/mfsexports.cfg ]]; then
      cp /etc/mfs/mfsexports.cfg.sample /etc/mfs/mfsexports.cfg 2>/dev/null || true
    fi

    cat > /etc/mfs/mfsexports.cfg <<EOF
# allow all rw from the export network, with password 'CHANGE_ME_EXPORT_PW'
${EXPORT_NETWORK}        /       rw,alldirs,maproot=0,password=CHANGE_ME_EXPORT_PW
${EXPORT_NETWORK}        .       rw
EOF

    cat > /etc/mfs/mfsmaster.cfg <<EOF
# === MooseFS Pro master configuration ===
WORKING_USER = mfs
WORKING_GROUP = mfs
DATA_PATH = /var/lib/mfs
EXPORTS_FILENAME = /etc/mfs/mfsexports.cfg

MATOML_LISTEN_HOST = 0.0.0.0
MATOML_LISTEN_PORT = 9419
MATOCS_LISTEN_HOST = 0.0.0.0
MATOCS_LISTEN_PORT = 9420
MATOCL_LISTEN_HOST = 0.0.0.0
MATOCL_LISTEN_PORT = 9421

# Pro-specific: enable HA mode (set HA_CLUSTER_NODE if you add a follower master)
# HA_CLUSTER_NODE = mfs-master-follower:9419

# Trash: keep deletes around for 24h before reclamation
SESSION_SUSTAIN_TIME = 86400

REPLICATIONS_DELAY_DISCONNECT = 3600
REPLICATIONS_DELAY_INIT = 300
EOF

    chown -R mfs:mfs /var/lib/mfs /etc/mfs
    if [[ ! -f /var/lib/mfs/metadata.mfs ]]; then
      cp /var/lib/mfs/metadata.mfs.empty /var/lib/mfs/metadata.mfs 2>/dev/null || true
      chown mfs:mfs /var/lib/mfs/metadata.mfs
    fi

    systemctl enable --now moosefs-pro-master
    systemctl enable --now moosefs-pro-cgiserv

    echo "==> Smoke-test client mount on the master host"
    apt-get -y install moosefs-pro-client
    mkdir -p /mnt/mfs
    if ! mountpoint -q /mnt/mfs; then
      mfsmount /mnt/mfs -H 127.0.0.1 -o mfspassword=CHANGE_ME_EXPORT_PW || true
    fi
    ;;

  metalogger)
    echo "==> Installing MooseFS Pro metalogger"
    apt-get -y install moosefs-pro-metalogger

    cat > /etc/mfs/mfsmetalogger.cfg <<EOF
WORKING_USER = mfs
WORKING_GROUP = mfs
DATA_PATH = /var/lib/mfs
MASTER_HOST = ${MASTER_HOSTNAME}
MASTER_PORT = 9419
META_DOWNLOAD_FREQ = 24
EOF

    chown -R mfs:mfs /var/lib/mfs /etc/mfs
    systemctl enable --now moosefs-pro-metalogger
    ;;

  chunkserver)
    echo "==> Installing MooseFS Pro chunkserver"
    apt-get -y install moosefs-pro-chunkserver moosefs-pro-cgi moosefs-pro-cgiserv

    mkdir -p "${CHUNKSERVER_DATA_ROOT}"

    for dev in "${CHUNKSERVER_DEVS[@]}"; do
      if [[ ! -b "${dev}" ]]; then
        echo "ERROR: ${dev} not present. Edit CHUNKSERVER_DEVS and rerun."
        exit 1
      fi
      dev_name=$(basename "${dev}")
      mnt="${CHUNKSERVER_DATA_ROOT}/${dev_name}"

      if ! blkid "${dev}" | grep -q xfs; then
        wipefs -a "${dev}"
        mkfs.xfs -i size=512 -L "mfs-${dev_name}" "${dev}"
      fi

      mkdir -p "${mnt}"
      UUID=$(blkid -s UUID -o value "${dev}")
      if ! grep -q "${UUID}" /etc/fstab; then
        echo "UUID=${UUID} ${mnt} xfs defaults,noatime,nodiratime,inode64 0 2" >> /etc/fstab
      fi
    done
    mount -a

    cat > /etc/mfs/mfshdd.cfg <<EOF
$(for dev in "${CHUNKSERVER_DEVS[@]}"; do echo "${CHUNKSERVER_DATA_ROOT}/$(basename "${dev}")"; done)
EOF

    cat > /etc/mfs/mfschunkserver.cfg <<EOF
WORKING_USER = mfs
WORKING_GROUP = mfs
DATA_PATH = /var/lib/mfs
HDD_CONF_FILENAME = /etc/mfs/mfshdd.cfg
MASTER_HOST = ${MASTER_HOSTNAME}
MASTER_PORT = 9420
MASTER_TIMEOUT = 60
CSSERV_LISTEN_HOST = 0.0.0.0
CSSERV_LISTEN_PORT = 9422
HDD_LEAVE_SPACE_DEFAULT = 4GiB
HDD_TEST_FREQ = 10
EOF

    chown -R mfs:mfs "${CHUNKSERVER_DATA_ROOT}" /var/lib/mfs /etc/mfs
    systemctl enable --now moosefs-pro-chunkserver
    systemctl enable --now moosefs-pro-cgiserv
    ;;

  *)
    echo "ERROR: NODE_ROLE must be master, metalogger, or chunkserver. Got: ${NODE_ROLE}"
    exit 1
    ;;
esac

echo
echo "========================================"
echo "DONE on ${NODE_NAME} (${NODE_ROLE})"
echo "========================================"
echo
ss -lntp | grep -E ':(9419|9420|9421|9422|9425)\b' || true

case "${NODE_ROLE}" in
  master)
    echo
    sleep 5
    mfsstat | head -20 || true
    echo
    echo "CGI dashboard: http://${NODE_IP}:9425"
    echo
    echo "After all chunkservers register, set goal on directories:"
    echo "  mfssetgoal 3 /mnt/mfs/hot"
    echo "  mfssetgoal 2 /mnt/mfs/archive"
    ;;
  metalogger)
    echo
    sleep 5
    ls -l /var/lib/mfs/ | head -10
    ;;
  chunkserver)
    echo
    sleep 5
    ls -l "${CHUNKSERVER_DATA_ROOT}" || true
    ;;
esac

echo
echo "Repeat on the other nodes with their NODE_NAME / NODE_IP / NODE_ROLE."

Run on the master first, the metalogger second (it needs the master to be live before it can register), then the three chunkservers in any order. Once all six processes are up, mfscli -SCS from the master should report all three chunkservers as version 4.57.6, maintain no, load 0. Set goals per directory: mfssetgoal 3 /mnt/mfs/hot puts your hot pipeline at three copies, mfssetgoal 2 /mnt/mfs/archive saves space on cold data.

Three things to verify before you trust the cluster with production data. First, force a metadata save (mfsmaster save from a Pro 4.x master, or restart the metalogger to confirm it ingests the latest dump). Second, kill one chunkserver and watch mfscli -SCC — the 2 copies column should fill up briefly, then mfsmaster replicates new copies on the survivors and 3 copies returns to the full chunk count within minutes. Third, deliberately delete a file under /mnt/mfs and run mfsdirinfo /mnt/mfs/.mfsmeta/trash — the deleted file should be visible in trash, recoverable by moving it back, and reclaimed after SESSION_SUSTAIN_TIME expires.

The free MooseFS edition gives you the chunkserver+master architecture but not the automated master failover; if the master is a single point of failure you can’t tolerate, the Pro license is the line where MooseFS becomes operationally serious. The community edition is fine for archive-class workloads where a manual master failover is acceptable.

For a MooseFS or CephFS cluster you don’t have to operate yourself, our team designs and runs distributed filesystem tiers under environment management on top of cloud compute — start a scoping call if you’d like us to take the storage tier off your plate.