Linux mounts Alibaba Cloud Object Storage OSS as a local disk to expand space backup website

After ps is mounted on oss, rsync can be used to synchronize image data, which is very convenient.

Official tutorial:  https://bbs.aliyun.com/read/307212.html
Source of this article:  http://www.xxorg.com/archives/4450

  Wake Awake server VPS tossing a small site using Aliyun's VPS to install Linux CentOS, sadly, the minimum bandwidth, only 1M bandwidth, it is too difficult to send something from ECS, it is said that backing up the website data requires a lot of For a long time, in order to solve this problem, using Alibaba Cloud's OSS can be solved at the first cost, using ossfs to mount the OSS to the VPS local, and only need to store it in the mounted directory when backing up, which is exactly the same as the local operation, safe and convenient. You only need to pay storage fees when you go to the intranet, and no traffic fees are required. ossfs allows you to mount Alibaba Cloud's OSS buckets to the local file system in Linux systems. You can easily operate objects on the OSS through the local file system to share data.

1. Installation method

The installation package of each version of centos Download
CentOS 7.0 (x64) 
http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32196/cn_zh/1481699572723/ossfs_1.80.0_centos7 .0_x86_64.rpm
CentOS 6.5 (x64) 
http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32196/cn_zh/1481699605023/ossfs_1.80.0_centos6.5_x86_64.rpm
CentOS 5.11 (x64) 
http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32196/cn_zh/1481699644192/ossfs_1.80.0_centos5.11_x86_64.rpm

For CentOS6.5 and above, The installation command is:

code
sudo yum localinstall your_ossfs_package.rpm


For CentOS5, the installation command is:

code
sudo yum localinstall your_ossfs_package.rpm --nogpgcheck


2. How to use Alibaba Cloud OSS
Set the bucket name and AccessKeyId/Secret information, and store them in the /etc/passwd-ossfs file. The permissions of this file must be set correctly. It is recommended to set it to 640.

code
echo bucket-xxorg:xxorg-access-key-id:xxorg-access-key-secret > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs



To mount the Alibaba Cloud OSS bucket
to the specified directory, you need to pay attention to the following ourl parameters. If the intranet domain name does not charge upload and download traffic fees, if it is an external network IP, upload and download traffic fees will not be charged, but download traffic fees will be charged.

code
mkdir /yun-ossfs 
ossfs bucket-yun /yun-ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com


Now check if there is a /yun-ossfs directory in the ECS file system. What needs to be done is like a local operation. On the surface, it is stored locally, but it is actually stored in Alibaba Cloud's OSS, even if it is a VPS. After reinstalling the system, the data stored in the Alibaba Cloud OSS will not be lost. Because the storage cost is not expensive, I will use it as backup space when I wake up. Finally, the charging standard of Alibaba Cloud OSS is attached. Although it is not the cheapest in the field of object storage on the Internet, it is also considered powerful in China, and the Chinese data is mostly

uninstalled from the bucket:

code
umount /yun-ossfs # root user
fusermount -u /yun-ossfs # non-root user


********************************************
RELATED QUESTIONS
***** ****************************************
When ps executes the ossfs mount command, the error message is as follows , process reference: http://blog.csdn.net/kane_canpower/article/details/70242160

code
ossfs: Check OSS service failed. Run with -f option for more details.


Turn on the debug switch of the ossfs command

code
ossfs bucket-yun /yun-ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com -o dbglevel=debug -f -d > /tmp/fs.log 2>&1


Check the log and find the following words, which means that the requested time is too different from the current time

code
The difference between the request time and the current time is too large.


try to check local time

code
[root@storm1 tmp]# date
Wed Apr 19 16:47:47 CST 2017


Sure enough, the gap is one hour, just update the synchronization time.

code
ntpdate cn.pool.ntp.org
19 Apr 15:52:39 ntpdate[71442]: step time server 51.15.41.135 offset -3357.358058 sec


The mount is successful again, and you can directly access /yun-ossfs

code
ossfs bucket-yun /yun-ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com


Compared with the local file system, the functions and performance provided by ossfs have some limitations. Specifically, it includes:
        random or additionally writing the file will cause the entire file to be rewritten.
        Metadata operations, such as list directory, have poor performance because when multiple clients that need to remotely access
        files/folders on the oss server are not atomic to
        mount the same oss bucket, they rely on the user to coordinate the behavior of each client. For example to avoid multiple clients writing the same file and so on.
        Hard links are not supported.
        Not suitable for high concurrent read/write scenarios, which will increase the system load

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326390158&siteId=291194637