RedisIt is an efficient memory database, and fuse is a module of the Linux kernel. It can be used to create its ownFile System(As mentioned earlier, gridfs-fuse of MongoDB ). This article describes how to implement a file system of a redis storage system:Redisfs
Usage
After redisfs is installed, run the following command to specify the host and port of the redis server and the Mount directory to mount a file system supported by redis as storage.
Redisfs -- Host = localhost -- Port = 6379 -- Mount =/mnt/redis [-- Read-Only] [-- debug] [-- prefix = skx]
Synchronization Mechanism
The main reason why redisfs chooses redis is to use redis's high performance and synchronization mechanism. The author provides two methods to build two synchronized file systems:
1. Use redisfs to mount different directories on two different machines to the same redis
2. The above method may cause at least one file system and redis to be not on the same machine, resulting in unnecessary network overhead. The method is to set the master and slave redis on different machines, and then directly use redisfs to mount the local redis. Data Synchronization is done through redis's own synchronization mechanism, however, the cost is that the file system on the server Load balancer is read-only.
Snapshot function
Redisfs provides a snapshot function for the file system. The snapshot function is very simple to implement. You only need to scan all the keys (equivalent to file names) stored in the current redis, and copy it to the new key. As follows:
$ Redisfs-snapsot -- from = skx -- To = copy
The above operation is to copy all keys starting with skx to a key starting with copy. Then, we can use the Mount parameter to create a new file system using this snapshot. The operation is as follows:
# Mkdir/tmp/safe # redisfs -- prefix = copy -- Mount =/tmp/safe
For installation instructions, see the official page: http://www.steve.org.uk/Software/redisfs/