Deployment Guide

Attention

This document is for the JuiceFS Hosted Service. If you are using the open source version, please refer to this document.

JuiceFS is quite easy to deploy with the following steps:

  1. Create a file system in JuiceFS web console

  2. Download JuiceFS command line tool

  3. Mount JuiceFS filesystem

You may do it manually following the Getting Started guide.

Alternatively, you may automate it with DevOps tools such as Ansible, SaltStack and etc.

Linux

Suppose you have created a filesystem in the JuiceFS official website console. Then, on the Linux host where you want to mount the filesystem, use curl or wget to download the JuiceFS command line tool:

curl -L juicefs.com/static/juicefs -o juicefs && chmod +x juicefs

Then use the juicefs command line tool to mount the filesystem. Please replace $JFS_NAME with the filesystem name in the following command, and replace $JFS_MOUNTPONT with the local mount point path. Of course, you can also use the export command to create these two environment variables and use them directly:

sudo ./juicefs mount $JFS_NAME $JFS_MOUNTPONT

When the filesystem is mounted on a host for the first time, the command line will interactively ask for the token of the filesystem and the key pair for accessing the object storage API. After successful authentication, these infomation will be saved in a configuration file in the current user’s $HOME/.juicefs directory, and then when the filesystem is mounted, the secret key will be automatically read from the configuration file without manual input.

You can also use the auth command to generate the filesystem configuration file before mounting a filesystem:

sudo ./juicefs auth --token $JFS_TOKEN --accesskey $ACCESSKEY --secretkey $SECRETKEY $JFS_NAME

Tip

Compared with using the mount subcommand to provide the secret key interactively, the auth subcommand can provide more detailed filesystem configurations by specifying parameters. This command is very useful when you need to deploy JuiceFS through scripts, or use self-hosted object storage for privatized deployment.

In order to make the filesystem mount automatically at boot, you can write the mount information into the /etc/fstab configuration file.

First, you need to rename and copy the JuiceFS client to the /sbin directory of the host:

$ sudo cp ./juicefs /sbin/mount.juicefs

Edit the /etc/fstab configuration file, start a new line and add the following record, pay attention to replace NAME-OF-JUICEFS with your actual filesystem name, and replace /jfs Into the mount point you actually want to use:

NAME-OF-JUICEFS   /jfs     juicefs    _netdev   0 0

Note: By default, CentOS 6 will not automatically mount the network filesystem at startup. You need to run the following command to enable automatic mounting:

$ sudo chkconfig --add netfs

macOS

The installation and deployment methods on macOS are basically the same as the Linux system, but the configuration method of automatic mounting is different. Please refer to this document.

Windows

For the deployment method of JuiceFS on Windows, please contact us.

Using Shell Script

#!/bin/sh
cd /tmp
curl -L juicefs.com/static/juicefs -o juicefs && chmod +x juicefs
sudo ./juicefs auth "$1" --token "$2" --accesskey "$3" --secretkey "$4"
sudo ./juicefs mount "$1" "$5"

Save the above content as a shell script setup-juicefs.sh and mount JuiceFS with one-line command:

./setup-juicefs.sh $JFS_NAME $JFS_TOKEN $ACCESSKEY $SECRETKEY $JFS_MOUNTPONT

Note

For environment that does not require accesskey or secretkey, e.g. using AWS IAM role for authentication, put a placeholder '' for the corresponding arguments.

Using SaltStack

Example state snippets to deploy JuiceFS with SaltStack.

/root/juicefs:
    file.managed:
        - source: https://juicefs.com/static/juicefs
        - mode:  0755
        - skip_verify: True

juicefs auth:
    cmd.run:
        - name: /root/juicefs auth {{jfs_name}} --token {{jfs_token}} --accesskey={{accesskey}} --secretkey={{secretkey}}
        - creates: /root/.juicefs/{{jfs_name}}.conf
    require:
        - file: /root/juicefs

/jfs:
    mount.mounted:
        - device: {{jfs_name}}
        - fstype: juicefs
        - mkmnt: True
        - opts: _netdev
        - device_name_regex:
            - JuiceFS:{{jfs_name}}
    require:
        - cmd: juicefs auth

Note

JuiceFS command line tool will automatically add prefix JuiceFS: to the device name. Therefore, you need to apply a regex match for it.

Using Ansible

Example for mounting JuiceFS on localhost using Ansible playbook:

- hosts: localhost
  tasks:
    - set_fact:
        jfs_bin: /usr/local/bin/juicefs

    - get_url:
        url: https://juicefs.com/static/juicefs
        mode: 0755
        dest: "{{jfs_bin}}

    - command: {{jfs_bin}} auth {{jfs_name}} --token {{jfs_token}} --accesskey={{accesskey}} --secretkey={{secretkey}}
      args:
        creates: /root/.juicefs/{{jfs_name}}.conf

    - mount:
        path: "{{jfs_path}}"
        src: "{{jfs_name}}"
        fstype: juicefs
        opts: _netdev
        state: mounted