You have an application that wants a POSIX path (/var/lib/appdata) on every container, the data is large enough that copying it to every node is unworkable, and the cloud-native answer “use S3 in the application code” is six months of refactoring you don’t have. JuiceFS is the bridge: it gives the application a real POSIX mount, stores the actual blobs in any S3-compatible object backend, and keeps the directory tree in Redis (or any of the supported metadata engines). Done well, it’s faster than NFS for most workloads and cheaper than a managed network filesystem. Done badly — single-node Redis without persistence, no local cache, FUSE mounted by hand — it’s a latency landmine. The full deployment with Redis Sentinel for metadata HA, a real local cache, and systemd-managed mounts is what makes it production-grade.
What’s happening
JuiceFS splits storage into three layers that you can scale independently. The metadata engine (Redis, in this guide; alternatives: TiKV, FoundationDB, Postgres, MySQL) holds the directory tree, file attributes, and the mapping from POSIX paths to chunk IDs. The object backend (S3, MinIO, Garage — anything S3-compatible) holds the actual file content, split into 4 MB chunks by default, with content-addressable hashing for dedup. The client is a FUSE mount that translates POSIX syscalls into metadata reads from Redis and object reads from S3, with a local block cache on the client’s disk to absorb the read latency.
The metadata is the hot path. Every stat, every readdir, every open round-trips to Redis. A single-node Redis without persistence and without a replica is the worst configuration: lose the Redis VM and the entire filesystem is, structurally, gone — the blobs in S3 are still there, but without metadata they’re an unparseable pile. The correct configuration is Redis Sentinel with at least one replica, AOF persistence enabled, and the JuiceFS client configured to fail over via Sentinel — that way, a Redis primary loss is a few seconds of latency, not data loss.
The other big lever is the cache. JuiceFS reads from the object backend are slow (it’s S3); JuiceFS reads from the local block cache are fast (it’s NVMe). A 100 GB cache directory on each client absorbs the hot working set and means most reads never hit S3. Without it, your application’s cat /var/lib/appdata/config.yaml is a multi-hop network call.
How to verify
After the installer runs, the mount is healthy:
mount | grep juicefs
# JuiceFS:appdata on /var/lib/appdata type fuse.juicefs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
juicefs status redis://10.40.0.20:26379/0
# {"Setting":{"Name":"appdata","UUID":"...","Storage":"s3", ...}}
Write and read through the mount:
echo "probe-$(date +%s)" > /var/lib/appdata/probe
cat /var/lib/appdata/probe
# Per-mount stats: open files, cache hits, slow ops
juicefs stats /var/lib/appdata
Confirm Redis is in Sentinel mode and JuiceFS is using the master:
redis-cli -h 10.40.0.20 -p 26379 SENTINEL get-master-addr-by-name jfs-meta
# 1) "10.40.0.21"
# 2) "6379"
redis-cli -h 10.40.0.21 -p 6379 INFO replication
# role:master
# connected_slaves:1
Cache hit rate (should be high after warming up):
juicefs stats /var/lib/appdata --interval=1
# look at the `cache_hits` and `cache_misses` columns
Failover drill: stop Redis on the current master (systemctl stop redis-server). Sentinel promotes the replica within a few seconds. From the client, ls /var/lib/appdata should resume working without intervention — if the mount goes unrecoverable, the JuiceFS client wasn’t configured for Sentinel.
The fix
Save the script as /root/setup-juicefs.sh and run it with ROLE=redis-master on one node, ROLE=redis-replica on a second, ROLE=sentinel on three nodes (can be co-located with Redis), and ROLE=client on every application node that needs the mount. The installer covers: Ubuntu base hardening (UFW, fail2ban, unattended-upgrades, SSH key-only), Redis 7 with AOF persistence (master/replica), Sentinel quorum for metadata-engine HA, JuiceFS CLI install, format-once volume creation pointing at S3 + Redis-Sentinel, FUSE mount with a 100 GB local block cache, systemd unit so the mount survives reboot, and a cache-warm hook.
#!/usr/bin/env bash
set -euo pipefail
### Ubuntu 22.04 JuiceFS deployer (Redis Sentinel meta + S3 object)
### Roles: redis-master | redis-replica | sentinel | client
### Run on each node after editing variables below
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
# === EDIT PER NODE ===
ROLE="redis-master" # role for this node
NODE_IP="10.40.0.21"
REDIS_MASTER_IP="10.40.0.21"
REDIS_REPLICA_IPS=("10.40.0.22")
SENTINEL_IPS=("10.40.0.20" "10.40.0.21" "10.40.0.22")
REDIS_PASSWORD="CHANGE_ME_REDIS"
SENTINEL_NAME="jfs-meta"
# S3 backend (any S3-compatible — MinIO, AWS S3, Garage)
S3_ENDPOINT="https://s3.internal.example.com"
S3_BUCKET="juicefs-appdata"
S3_ACCESS_KEY="app-key"
S3_SECRET_KEY="app-secret-CHANGE_ME"
# JuiceFS volume name (one-time format)
VOLUME_NAME="appdata"
MOUNT_POINT="/var/lib/appdata"
CACHE_DIR="/var/cache/juicefs"
CACHE_SIZE_MB=102400 # 100 GB
# =====================
echo
echo "========================================"
echo "JuiceFS ${ROLE} on ${NODE_IP}"
echo "========================================"
echo
echo "==> Updating base OS"
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get -y upgrade
apt-get -y install \
curl wget ca-certificates gnupg jq lsof net-tools dnsutils tcpdump \
ufw fail2ban unattended-upgrades chrony \
fuse3 libfuse3-3 \
apparmor apparmor-utils
systemctl enable --now chrony
echo "==> Unattended security updates"
cat > /etc/apt/apt.conf.d/52unattended-upgrades-local <<'APT'
Unattended-Upgrade::Origins-Pattern {
"origin=Ubuntu,codename=${distro_codename},label=Ubuntu-Security";
};
Unattended-Upgrade::Automatic-Reboot "false";
APT
dpkg-reconfigure -fnoninteractive unattended-upgrades
echo "==> SSH key-only"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart ssh
echo "==> fail2ban"
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban
echo "==> Kernel/sysctl"
cat > /etc/sysctl.d/99-juicefs.conf <<'SYSCTL'
fs.file-max = 4194304
vm.swappiness = 1
vm.dirty_background_ratio = 5
vm.dirty_ratio = 20
net.core.somaxconn = 8192
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
SYSCTL
sysctl --system
echo "==> UFW base rules"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
# --- ROLE-SPECIFIC ---
if [[ "${ROLE}" == "redis-master" || "${ROLE}" == "redis-replica" || "${ROLE}" == "sentinel" ]]; then
echo "==> Installing Redis 7"
apt-get -y install redis-server redis-sentinel
# FUSE module not needed on metadata nodes
apt-get -y remove fuse3 libfuse3-3 || true
fi
if [[ "${ROLE}" == "redis-master" || "${ROLE}" == "redis-replica" ]]; then
echo "==> Configuring redis-server"
cat > /etc/redis/redis.conf <<EOF
bind ${NODE_IP} 127.0.0.1
port 6379
protected-mode yes
requirepass ${REDIS_PASSWORD}
masterauth ${REDIS_PASSWORD}
appendonly yes
appendfsync everysec
maxmemory-policy noeviction
tcp-backlog 8192
timeout 0
tcp-keepalive 60
loglevel notice
logfile /var/log/redis/redis-server.log
dir /var/lib/redis
EOF
if [[ "${ROLE}" == "redis-replica" ]]; then
echo "replicaof ${REDIS_MASTER_IP} 6379" >> /etc/redis/redis.conf
fi
for ip in "${SENTINEL_IPS[@]}" "${REDIS_MASTER_IP}" "${REDIS_REPLICA_IPS[@]}"; do
ufw allow from "${ip}" to any port 6379 proto tcp
done
# Application clients reach Redis via Sentinel-discovered master — open broadly within VPC
ufw allow from 10.40.0.0/16 to any port 6379 proto tcp
systemctl enable --now redis-server
fi
if [[ "${ROLE}" == "sentinel" ]]; then
echo "==> Configuring redis-sentinel"
cat > /etc/redis/sentinel.conf <<EOF
bind ${NODE_IP} 127.0.0.1
port 26379
protected-mode yes
sentinel monitor ${SENTINEL_NAME} ${REDIS_MASTER_IP} 6379 2
sentinel auth-pass ${SENTINEL_NAME} ${REDIS_PASSWORD}
sentinel down-after-milliseconds ${SENTINEL_NAME} 5000
sentinel parallel-syncs ${SENTINEL_NAME} 1
sentinel failover-timeout ${SENTINEL_NAME} 10000
logfile /var/log/redis/redis-sentinel.log
dir /var/lib/redis
EOF
chown redis:redis /etc/redis/sentinel.conf
for ip in "${SENTINEL_IPS[@]}"; do
ufw allow from "${ip}" to any port 26379 proto tcp
done
ufw allow from 10.40.0.0/16 to any port 26379 proto tcp
systemctl enable --now redis-sentinel
fi
if [[ "${ROLE}" == "client" ]]; then
echo "==> Installing JuiceFS CLI"
JFS_VERSION="1.2.1"
cd /tmp
curl -sSL "https://github.com/juicedata/juicefs/releases/download/v${JFS_VERSION}/juicefs-${JFS_VERSION}-linux-amd64.tar.gz" \
-o juicefs.tar.gz
tar -xzf juicefs.tar.gz
install -m 0755 juicefs /usr/local/bin/juicefs
rm -f juicefs.tar.gz juicefs LICENSE README.md
# Sentinel URI for the metadata engine
SENTINEL_HOSTS=""
for ip in "${SENTINEL_IPS[@]}"; do
SENTINEL_HOSTS+="${ip}:26379,"
done
SENTINEL_HOSTS="${SENTINEL_HOSTS%,}"
META_URL="redis://:${REDIS_PASSWORD}@${SENTINEL_HOSTS}/0?master_name=${SENTINEL_NAME}"
echo "==> Format volume (idempotent — only first client succeeds, others get 'already formatted')"
juicefs format \
--storage s3 \
--bucket "${S3_ENDPOINT}/${S3_BUCKET}" \
--access-key "${S3_ACCESS_KEY}" \
--secret-key "${S3_SECRET_KEY}" \
--block-size 4096 \
--compress lz4 \
--encrypt-rsa-key "" \
"${META_URL}" \
"${VOLUME_NAME}" || echo "Already formatted (this is expected on second+ clients)"
echo "==> Creating mount point and cache"
mkdir -p "${MOUNT_POINT}" "${CACHE_DIR}"
echo "==> systemd unit for mount"
cat > /etc/systemd/system/juicefs-${VOLUME_NAME}.service <<EOF
[Unit]
Description=JuiceFS ${VOLUME_NAME} mount
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStartPre=/bin/sh -c 'until juicefs status "${META_URL}" >/dev/null 2>&1; do sleep 1; done'
ExecStart=/usr/local/bin/juicefs mount \\
--foreground \\
--cache-dir=${CACHE_DIR} \\
--cache-size=${CACHE_SIZE_MB} \\
--max-uploads=20 \\
--max-downloads=200 \\
--buffer-size=600 \\
--writeback \\
--no-syslog \\
--log=/var/log/juicefs.log \\
--io-retries=10 \\
--metrics=127.0.0.1:9567 \\
"${META_URL}" \\
"${MOUNT_POINT}"
ExecStop=/bin/umount ${MOUNT_POINT}
Restart=on-failure
LimitNOFILE=1048576
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now juicefs-${VOLUME_NAME}
echo "==> Waiting for mount"
for i in {1..30}; do
if mountpoint -q "${MOUNT_POINT}"; then break; fi
sleep 1
done
echo
echo "==> Cache warm hook (optional — pre-populate cache from common paths)"
cat > /usr/local/bin/juicefs-warm.sh <<'WARM'
#!/usr/bin/env bash
set -e
MOUNT="$1"
# Pre-warm: walk hot directories with juicefs warmup
juicefs warmup -f "${MOUNT}" || true
WARM
chmod +x /usr/local/bin/juicefs-warm.sh
fi
ufw --force enable
echo "==> Validation"
case "${ROLE}" in
redis-master)
redis-cli -h "${NODE_IP}" -a "${REDIS_PASSWORD}" INFO replication | head -10
;;
redis-replica)
redis-cli -h "${NODE_IP}" -a "${REDIS_PASSWORD}" INFO replication | head -10
;;
sentinel)
redis-cli -h "${NODE_IP}" -p 26379 SENTINEL get-master-addr-by-name "${SENTINEL_NAME}" || true
;;
client)
df -h "${MOUNT_POINT}" || true
juicefs status "${META_URL}" 2>/dev/null | jq '.Setting | {Name,UUID,Storage,BlockSize}' || true
;;
esac
echo
echo "========================================"
echo "DONE on this node (role=${ROLE})."
echo "========================================"
Make it executable and run on each node in this order:
chmod 700 /root/setup-juicefs.sh
# 1. Redis primary
ROLE=redis-master /root/setup-juicefs.sh
# 2. Redis replicas
ROLE=redis-replica /root/setup-juicefs.sh
# 3. Sentinels (can be the same VMs as Redis)
ROLE=sentinel /root/setup-juicefs.sh
# 4. Application clients (each one)
ROLE=client /root/setup-juicefs.sh
The first client to format the volume claims the volume name in Redis — subsequent clients see “already formatted” and proceed to mount. Once mounted, df -h /var/lib/appdata reports the volume size, juicefs stats /var/lib/appdata shows the live op profile, and the FUSE process owns the cache directory at /var/cache/juicefs. The cache fills as the application reads; for cold starts, juicefs warmup /var/lib/appdata/<hot-path> pulls common paths up front.
The Sentinel failover drill is the critical test before production: stop Redis on the master, watch Sentinel promote within down-after-milliseconds, and confirm the JuiceFS client keeps serving I/O. If the mount goes into an unrecoverable state during failover, the META_URL on the client is wrong — it must reference Sentinels with master_name, not the master IP directly.
Two operational notes. First, this is a stateful filesystem on top of two backing services — Redis loss without replication is data loss for the entire mount, S3 backend loss is data loss for the blobs. Snapshot both. Second, watch your S3 egress bill: JuiceFS reads pull from S3 if the local cache misses, so a small cache on a read-heavy workload is expensive. Right-size the cache against the working set, not against the total volume.
Operate JuiceFS, Redis Sentinel, and the S3 backend together on Stack Harbor’s managed cloud compute under environment management — failover drills, cache-hit-rate alerting, and snapshot rotation included. Bring us your workload profile and we’ll size the metadata engine and cache against it.