当前位置:网站首页>Install and use juicefs storage on Tencent cloud

Install and use juicefs storage on Tencent cloud

2022-06-24 05:50:00 Talk and laugh, Herald

JuiceFS It is a cloud native enterprise level open source shared file system , Widely used in big data 、 Enterprise data sharing 、Kubernetes Container arrangement 、AI machine learning 、Web Services and content management 、 Data disaster recovery backup and other scenarios . It uses object storage as a large capacity local disk , Provide nearly unlimited storage space for cloud applications . meanwhile , Thanks to its unique technical architecture , When storing and processing large-scale data , Performance is usually better than local storage .

in addition ,JuiceFS Cross cloud sharing capability , If you need to share data between multiple cloud servers located in different cloud service providers , Just mount the same on each ECs JuiceFS Storage , Its data consistency design , It can ensure that each host can synchronize the changes of data in real time .

This article will share how to install and use on Tencent cloud platform JuiceFS Storage .

framework

As shown in the figure below ,JuiceFS Storage is driven by both database and object storage . Deposit in JuiceFS The file will be split into fixed size data blocks and stored in the object storage according to certain rules , The metadata corresponding to the data will be stored in the database .

Metadata is completely stored independently , The retrieval and processing of files does not directly manipulate the data stored in the object , Instead, first operate metadata in the database , Only when the data changes , Will interact with the object store .

This design can effectively reduce the cost of storing objects in the number of requests , At the same time, it can also make us feel JuiceFS Performance improvements .

JuiceFS Architecture diagram

Get ready

Through the previous architecture description , You can know JuiceFS It needs to be used together with database and object storage . Here we use Tencent cloud directly CVM Cloud server , Combining cloud database and COS Object storage .

When creating cloud computing resources , Try to choose the same area , This allows resources to access each other through intranet lines , Avoid using public network lines to incur additional traffic costs .

One 、 Cloud server CVM

JuiceFS There are no special requirements for server hardware , Generally speaking , The lowest configured ECS on the cloud platform can also be used stably JuiceFS, Usually you only need to select the configuration that can meet your own business .

One thing to note is that , You don't need to use JuiceFS Buy the server again or reinstall the system ,JuiceFS No business intrusion , It will not cause any interference to your existing systems and programs , You can install and use on a running server JuiceFS.

JuiceFS It will occupy no more than by default 1GB Hard disk space as cache , You can adjust the size of the cache space as needed . The cache is a data buffer layer between the client and the object store , Choose a cloud disk with better performance , You can get better performance .

In terms of the operating system , Tencent cloud CVM All operating systems provided can be installed JuiceFS.

This article uses CVM The configuration is as follows :

Server configuration

CPU

1 nucleus

Memory

2 GB

Storage

50 GB

operating system

Ubuntu Server 20.04 64 position

regional

Five districts of Shanghai

Two 、 Cloud database

JuiceFS All metadata corresponding to the data will be stored in an independent database , At present, the databases that have been opened and supported are Redis、MySQL、PostgreSQL、TiKV and SQLite.

Depending on the database type , The metadata performance and reliability performance are also different . such as Redis It runs completely in memory , It can provide extreme performance , But the operation and maintenance is difficult , Relatively low reliability . and MySQL、PostgreSQL Is a relational database , Performance is not as good as Redis, But the operation and maintenance is not very difficult , Reliability is also guaranteed .SQLite It is a stand-alone single file relational database , Low performance , Nor is it suitable for large-scale data storage , But it is configuration free , It is suitable for a single machine with a small amount of data storage .

If only for evaluation JuiceFS The function of , You can CVM The ECS builds the database manually to use . When you want to use in a production environment JucieFS when , If there is no professional database operation and maintenance team , The cloud database service of Tencent cloud is usually a better choice .

Of course , If you will , You can also use cloud database services provided on other cloud platforms . But in this case , You can only access the cloud database through the public network , in other words , You must expose the port of the database to the public network , There are great security risks , It's best not to use .

If you have to access the database through the public network , You can use the white list function provided by the cloud database console , Strictly restrict access to the database IP Address , So as to improve the security of data . On the other hand , If you cannot successfully connect to the cloud database through the public network , Then you can check the white list of the database , Check if this setting restricts your access .

database

Redis

MySQL、PostgreSQL

SQLite

performance

strong

Moderate

weak

Operation and maintenance threshold

high

Moderate

low

reliability

low

Moderate

low

Application scenarios

Huge amounts of data 、 Distributed high frequency read / write

Huge amounts of data 、 Distributed medium and low frequency read / write

A small amount of data is read and written by a single machine at medium and low frequencies

Be careful : If you use JuiceFS Of hosted services , There is no need to prepare the database separately .

This article uses cloud database TencentDB Redis, adopt VPC Private network and CVM ECS interactive access :

Redis edition

5.0 Community Edition

Example specifications

1GB (1 Lord 1 vice )

Connection address

192.168.5.5:6379

Availability zone

Five districts of Shanghai

Be careful , The connection address of the database depends on the VPC Network settings , establish Redis Instance will automatically get the address in the network segment you defined .

3、 ... and 、 Object storage COS

JuiceFS All the data will be stored in the object store , It supports almost all object storage services . But for best performance , When using Tencent cloud CVM when , With Tencent cloud COS Object storage is usually the best choice . But please note , take CVM and COS Bucket Choose in the same region , In this way, you can access through the intranet line of Tencent cloud , Not only the delay is low , And there is no additional traffic cost .

TIPS: Tencent cloud object storage COS The unique access address provided supports both intranet and Internet access , When accessed through the intranet ,COS Will automatically resolve to the Intranet IP, The traffic generated at this time is the intranet traffic , There will be no traffic charges .

Of course , If you will , You can also use object storage services provided by other cloud platforms , But this is not recommended . First , Through Tencent cloud CVM Access to the object storage of other cloud platforms should go through the public network , Object storage incurs traffic charges , And the access delay is also higher , May affect JuiceFS Performance of .

Tencent cloud COS There are different storage levels , because JuiceFS Need to interact frequently with object stores , Standard storage is recommended . You can match COS Resource pack usage , Reduce the cost of object storage .

API Access key

Tencent cloud COS Need to pass through API Visit , You need to prepare the access key , Include Access Key ID and Access Key Secret, Click here to view the Access method .

Safety suggestion : Use... Explicitly API Access to the secret key may lead to key disclosure , It is recommended to allocate to ECs CAM Service role . When one CVM Be awarded COS After the operation permission , No need to use API Access the secret key to access COS.

install

I'm using Ubuntu Server 20.04 64 Bit system , You can download the latest version of the client by executing the following commands in sequence . You can also visit JuiceFS GitHub Releases Page select another version .

At the time of writing this article ,JuiceFS The latest version of is v0.15.2.

$ JFS_LATEST_TAG=$(curl -s https://api.github.com/repos/juicedata/juicefs/releases/latest | grep 'tag_name' | cut -d '"' -f 4 | tr -d 'v')
$ wget "https://github.com/juicedata/juicefs/releases/download/v${JFS_LATEST_TAG}/juicefs-${JFS_LATEST_TAG}-linux-amd64.tar.gz"

After downloading , Unzip the program to juice Folder :

$ mkdir juice && tar -zxvf "juicefs-${JFS_LATEST_TAG}-linux-amd64.tar.gz" -C juice

take JuiceFS The client is installed to /usr/local/bin

$ sudo install juice/juicefs /usr/local/bin

Carry out orders , See return juicefs Command help information for , On behalf of successful client installation .

$ juicefs 
NAME:
   juicefs - A POSIX file system built on Redis and object storage.

USAGE:
   juicefs [global options] command [command options] [arguments...]

VERSION:
   0.15.2 (2021-07-07T05:51:36Z 4c16847)

COMMANDS:
   format   format a volume
   mount    mount a volume
   umount   unmount a volume
   gateway  S3-compatible gateway
   sync     sync between two storage
   rmr      remove directories recursively
   info     show internal information for paths or inodes
   bench    run benchmark to read/write/stat big/small files
   gc       collect any leaked objects
   fsck     Check consistency of file system
   profile  analyze access log
   status   show status of JuiceFS
   warmup   build cache for target directories/files
   dump     dump metadata into a JSON file
   load     load metadata from a previously dumped JSON file
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --verbose, --debug, -v  enable debug log (default: false)
   --quiet, -q             only warning and errors (default: false)
   --trace                 enable trace log (default: false)
   --no-agent              Disable pprof (:6060) and gops (:6070) agent (default: false)
   --help, -h              show help (default: false)
   --version, -V           print only the version (default: false)

COPYRIGHT:
   AGPLv3

JuiceFS It has good cross platform compatibility , At the same time support in Linux、Windows and macOS Upper use . This article focuses on JuiceFS stay Linux Installation and use on the system , If you need to know how to install on other systems , please Consult the documentation .

establish JuiceFS Storage

JuiceFS After the client is installed , Now you can use the previously prepared Redis Database and COS Object store to create JuiceFS Store .

Strictly speaking , This step should be called “Format a volume”, Format a volume . But considering that many users may not understand or care about the standard terminology of file systems , So for the sake of simplicity , We simply call this process “ establish JuiceFS Storage ”.

The following command uses JuiceFS Provided by the client format The subcommand creates a named mystor The storage , File system :

$ juicefs format \
	--storage cos \
	--bucket https://<your-bucket-name> \
	--access-key <your-access-key-id> \
	--secret-key <your-access-key-secret> \
	redis://:<your-redis-password>@192.168.5.5:6379/1 \
	mystor

Option description :

  • --storage: Specify the object storage type , Click here to view the JuiceFS Supported object storage .
  • --bucket: Object stored Bucket domain name . When using Tencent cloud COS when , Just fill in bucket Name is enough , No need to fill in the complete domain name ,JuiceFS Will automatically identify and complete the address .
  • --access-key and --secret-key: Access object store API The secret key to , Click here to view the Access method .

Redis 6.0 Identity authentication requires two parameters: user name and password , Address format is redis://username:[email protected]:6379/1. At present, Tencent cloud database Redis Version available only Reids 4.0 and 5.0 Two versions , Authentication requires only a password , Set up Redis You only need to leave the user name blank for the server address , for example :redis://:[email protected]:6379/1

Use RAM Character binding CVM when , establish JucieFS Storage only needs to specify --storage and --bucket Two options , No need to provide API Access key . The command can be rewritten as :

$ juicefs format \
	--storage cos \
	--bucket https://juice-1250000025.cos.ap-shanghai.myqcloud.com \
	redis://:<your-redis-password>@192.168.5.5:6379/1 \
	mystor

See output similar to the following , Represents that the file system has been successfully created .

2021/07/30 11:44:31.904157 juicefs[44060] <INFO>: Meta address: redis://@192.168.5.5:6379/1
2021/07/30 11:44:31.907083 juicefs[44060] <WARNING>: AOF is not enabled, you may lose data if Redis is not shutdown properly.
2021/07/30 11:44:31.907634 juicefs[44060] <INFO>: Ping redis: 474.98µs
2021/07/30 11:44:31.907850 juicefs[44060] <INFO>: Data uses cos://juice-1250000025/mystor/
2021/07/30 11:44:32.149692 juicefs[44060] <INFO>: Volume is formatted as {Name:mystor UUID:dbf05314-57af-4a2c-8ac1-19329d73170c Storage:cos Bucket:https://juice-1250000025.cos.ap-shanghai.myqcloud.com AccessKey:AKIDGLxxxxxxxxxxxxxxxxxxZ8QRBdpkOkp SecretKey:removed BlockSize:4096 Compression:none Shards:0 Partitions:0 Capacity:0 Inodes:0 EncryptKey:}

mount JuiceFS Storage

File system creation complete , Object storage related information will be stored in the database , There is no need to input the stored data of the object when mounting Bucket And secret keys .

Use mount Sons command , Mount the file system to /mnt/jfs Catalog :

$ sudo juicefs mount -d redis://:<your-redis-password>@192.168.5.5:6379/1 /mnt/jfs

Be careful : When mounting a file system , Just fill in Redis Database address , No file system name is required . If you use root Mount the file system as , The default cache path is /var/jfsCache, If you use an ordinary user identity to mount on your home directory , The default cache path is ~/.juicefs/cache.

See output similar to the following , On behalf of file system mount success .

2021/07/30 11:49:56.842211 juicefs[44175] <INFO>: Meta address: redis://@192.168.5.5:6379/1
2021/07/30 11:49:56.845100 juicefs[44175] <WARNING>: AOF is not enabled, you may lose data if Redis is not shutdown properly.
2021/07/30 11:49:56.845562 juicefs[44175] <INFO>: Ping redis: 383.157µs
2021/07/30 11:49:56.846164 juicefs[44175] <INFO>: Data use cos://juice-1250000025/mystor/
2021/07/30 11:49:56.846731 juicefs[44175] <INFO>: Disk cache (/var/jfsCache/dbf05314-57af-4a2c-8ac1-19329d73170c/): capacity (1024 MB), free ratio (10%), max pending pages (15)
2021/07/30 11:49:57.354763 juicefs[44175] <INFO>: OK, mystor is ready at /mnt/jfs

Use df command , You can see the mounting of the file system :

$ df -Th
 file system             type            Capacity     Already used    You can use     Already used %  Mount point 
JuiceFS:mystor   fuse.juicefs  1.0P   64K  1.0P    1% /mnt/jfs

After the file system is mounted successfully , Now you can use your local hard drive , stay /mnt/jfs Data is stored in the directory .

Multi host sharing :JuiceFS Storage can be mounted and used by multiple ECS at the same time , You can do it in other places CVM Installation on JuiceFS client , And then use redis://:<your-redis-password>@192.168.5.5:6379/1 The database address mounts the file system to each host .

View file system status

Use JuiceFS Client's status The subcommand can view the basic information and connection status of a file system .

$ juicefs status redis://:<your-redis-password>@192.168.5.5:6379/1

2021/07/30 11:51:17.864767 juicefs[44196] <INFO>: Meta address: redis://@192.168.5.5:6379/1
2021/07/30 11:51:17.866619 juicefs[44196] <WARNING>: AOF is not enabled, you may lose data if Redis is not shutdown properly.
2021/07/30 11:51:17.867092 juicefs[44196] <INFO>: Ping redis: 379.391µs
{
  "Setting": {
    "Name": "mystor",
    "UUID": "dbf05314-57af-4a2c-8ac1-19329d73170c",
    "Storage": "cos",
    "Bucket": "https://juice-1250000025.cos.ap-shanghai.myqcloud.com",
    "AccessKey": "AKIDGLxxxxxxxxxxxxxxxxx8QRBdpkOkp",
    "BlockSize": 4096,
    "Compression": "none",
    "Shards": 0,
    "Partitions": 0,
    "Capacity": 0,
    "Inodes": 0
  },
  "Sessions": [
    {
      "Sid": 1,
      "Heartbeat": "2021-07-30T11:49:56+08:00",
      "Version": "0.15.2 (2021-07-07T05:51:36Z 4c16847)",
      "Hostname": "VM-5-6-ubuntu",
      "MountPoint": "/mnt/jfs",
      "ProcessID": 44175
    },
    {
      "Sid": 3,
      "Heartbeat": "2021-07-30T11:50:56+08:00",
      "Version": "0.15.2 (2021-07-07T05:51:36Z 4c16847)",
      "Hostname": "VM-5-6-ubuntu",
      "MountPoint": "/mnt/jfs",
      "ProcessID": 44185
    }
  ]
}

uninstall JuiceFS Storage

Use JuiceFS Provided by the client umount Command to unmount the file system , such as :

$ sudo juicefs umount /mnt/jfs

Be careful : Forced unmounting of an active file system may result in data corruption or loss , Please be careful . Please refer to Official documents .

Power on auto mount

If you don't want to manually mount every time you restart the system JuiceFS Storage , You can set up an auto mount file system .

First , Need to put juicefs Rename client to mount.juicefs And copy it to /sbin/ Catalog :

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

edit /etc/fstab The configuration file , Add a record :

redis://:<your-redis-password>@192.168.5.5:6379/1    /mnt/jfs       juicefs     _netdev,cache-size=20480     0  0

Mounting options cache-size=20480 For distribution 20GB Local disk space as JuiceFS Cache usage of , Please according to your actual CVM Hard disk capacity determines the allocated cache size . Generally speaking , by JuiceFS Allocate more cache space , You can get better performance .

You can adjust the... In the above configuration according to your needs FUSE Mount options , For more information Consult the documentation .

Be careful : Please send the... In the above configuration file Redis Address 、 Mount points and mount options , Replace with your actual information .

summary

JucieFS It is a cloud oriented high-performance enterprise file system , At present, it is mostly used in big data analysis 、 Enterprise data sharing 、Kubernetes Container arrangement 、 Data disaster recovery backup and other business scenarios . Limited by subject and space , The purpose of this paper is , A brief introduction to Tencent cloud CVM And cloud database Redis Version and COS Object store creation JuiceFS The basic method of file system .

You can visit JuiceFS GitHub Warehouse , Learn more about JuiceFS High level theme of .

原网站

版权声明
本文为[Talk and laugh, Herald]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/08/20210802153023157T.html

猜你喜欢

    随机推荐