Using File Storage

Environment Dependencies

  • Insert the kernel FUSE module
  • Install libfuse
modprobe fuse
yum install -y fuse

Mounting the File System

After successfully creating a replica volume, mount the volume by executing the following command:

cfs-client -c client.json

After successful execution, you can use the df -h command to view the mount point. If the execution fails, you can judge according to the content of output.log in the log directory.

The example configuration file is as follows:

{
    "mountPoint":"/mnt/cfs",
    "subdir":"/",
    "volName":"vol_test",
    "owner":"test",
    "accessKey":"**********",
    "secretKey":"*********",
    "masterAddr":"192.168.0.1:17010",
    "rdonly":"false",
    "logDir":"/home/service/var/logs/cfs/log",
    "logLevel":"warn",
    "profPort":"17410"
}

The meaning of each parameter in the configuration file is shown in the following table:

ParameterTypeMeaningRequired
mountPointstringMount pointYes
subdirstringMount subdirectoryNo
volNamestring sliceVolume nameYes
ownerstringVolume ownerYes
accessKeystringAuthentication key of the user to which the volume belongsYes
secretKeystringAuthentication key of the user to which the volume belongsYes
masterAddrstringMaster node addressYes
rdonlyboolMount as read-only, default is falseNo
logDirstringLog storage pathNo
logLevelstringLog level: debug, info, warn, errorNo
profPortstringGolang pprof debugging portNo

Other configuration parameters can be set according to actual needs:

ParameterTypeMeaningRequired
exporterPortstringPort for Prometheus to obtain monitoring dataNo
consulAddrstringMonitoring registration server addressNo
lookupValidstringValidity period of kernel FUSE lookup, in secondsNo
attrValidstringValidity period of kernel FUSE attribute, in secondsNo
icacheTimeoutstringValidity period of client inode cache, in secondsNo
enSyncWritestringEnable DirectIO synchronous write, that is, DirectIO forces data nodes to write to diskNo
autoInvalDatastringUse the AutoInvalData option for FUSE mountingNo
writecacheboolUse the write cache function of the kernel FUSE module. This function requires the kernel FUSE module to support write cache. The default is false.No
keepcacheboolKeep the kernel page cache. This function requires the writecache option to be enabled. The default is false.No
tokenstringIf enableToken is enabled when creating a volume, fill in the token corresponding to the permission.No
readRateintLimit the number of reads per second. The default is unlimited.No
writeRateintLimit the number of writes per second. The default is unlimited.No
followerReadboolRead data from the follower. The default is false.No
disableDcacheboolDisable Dentry cache. The default is false.No
fsyncOnCloseboolPerform fsync operation after the file is closed. The default is true.No
maxcpusintThe maximum number of CPUs that can be used, which can limit the CPU usage of the client process.No
enableXattrboolWhether to use xattr. The default is false.No
enableBcacheboolWhether to enable local level 1 cache. The default is false.No
maxStreamerLimitstringWhen local level 1 cache is enabled, the number of file metadata caches.No
bcacheDirstringThe target directory for read cache when local level 1 cache is enabled.No

Unmounting the File System

Execute the following command to unmount the replica volume:

umount -l /path/to/mountPoint

/path/to/mountPoint is the mount path in the client configuration file.

Live Upgrade or hot restart

cfs-client -c fuse.json -r -p 27510

Before live-upgrading, old cfs-client is running with profPort 27510. -r restore FUSE instead of mounting. -p 27510 tells new cfs-client to communicate with old cfs-client through port 27510.

Enabling Level 1 Cache

The local read cache service deployed on the user client is not recommended for scenarios where the data set has modified writes and requires strong consistency. After deploying the cache, the client needs to add the following mount parameters, and the cache will take effect after remounting.

./cfs-bcache -c bcache.json

The meaning of each parameter in the configuration file is shown in the following table:

{
   "cacheDir":"/home/service/var:1099511627776",
   "logDir":"/home/service/var/logs/cachelog",
   "logLevel":"warn"
}
ParameterTypeMeaningRequired
cacheDirstringLocal storage path for cached data: allocated space (Byte)Yes
logDirstringLog pathYes
logLevelstringLog levelYes
Edit on GitHub