The original link of this article: wangfanggang.com/ Tencent Cloud /cosfs/

In this paper, the target

This paper aims to map the object storage of Tencent Cloud to the local disk directory of cloud server by using COSFS tool provided by Tencent Cloud.

The premise condition

Assume that we have created the object storage (COS) of Tencent Cloud, the information is as follows: bucket name (bucket_name) : kenny-hexo replace with your own bucket APPID (bucket_appID) : 1256238228

Bucket access domain (bucket_region) : https://kenny-hexo-1256238228.cos.ap-beijing.myqcloud.com replace it with your own

API secret key id (SecretId) : AKIDXXXXXXXXXXXXXXXXXXXXXXBM951 replace your API key and the secret key (SecretKey) : 8 iugxxxxxxxxxxxxxxxxxxxxxweb replaced with your own

COSFS tools

Functional specifications

COSFS allows you to mount COS buckets to a local host and directly operate Tencent Cloud object storage as if using a local file system. The main features of COSFS include:

  • Supports most functions of POSIX file systems, such as file read/write, directory operation, link operation, permission management, and UID/GID management.
  • Large file transfer function;
  • MD5 data verification function.

Using the environment

  • CentOS 7 64bit

CentOS installation environment dependency package

sudo yum install automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel make openssl-devel
Copy the code

Obtain the COSFS toolkit

Suppose we want to place the toolkit in the /u01/cosfs/ directory

cd /u01
git clone https://github.com/tencentyun/cosfs.git
Copy the code

After cloning is complete, go to the downloaded directory to complete the compilation and installation of the source code:

cd /u01/cosfs
./autogen.sh
./configure
make
sudo make install
Copy the code

The configuration file

The command is as follows:

echo kenny-hexo-1256238228:AKIDXXXXXXXXXXXXXXXXXXXXXXBM951:8IUgXXXXXXXXXXXXXXXXXXXXXweB > /etc/passwd-cosfs
chmod 640 /etc/passwd-cosfs
Copy the code

Replace your real bucket_appID, secretId, and secredKey

To mount

The command is as follows:

cosfs 1256238228:kenny-hexo /u01/docker/kenny_hexo/public -ourl=kenny-hexo-1256238228.cos.ap-beijing.myqcloud.com -odbglevel=info
Copy the code

Among them:

  • 1256238228:kenny-hexoIs your bucket_appID and bucket_name, which need to be replaced with the user’s real information;
  • /u01/docker/kenny_hexo/publicWhether to mount to the local directory;
  • kenny-hexo-1256238228.cos.ap-beijing.myqcloud.comIs your bucket_region
  • -odbglevelThe parameter indicates the information level.

Test whether the mount is successful

Let’s create a new file named test.txt in the mount path

cd /u01/docker/kenny_hexo/public
echo "hello world" > test.txt
Copy the code

Switch to console refresh, files have been synchronized.

So far, we have successfully used COSFA tool to complete the local mapping of Tencent cloud object storage.

Other problems

The following command is used to uninstall the mapping:

umount -l /u01/docker/kenny_hexo/public
Copy the code

Reference documentation

Official document of COSFS tool