Centos7.x mounts Alibaba Cloud oss locally

Local environment centos7.6

1. Run the following command to download the ossfs installation package. (note the version of the package)

cd /home;mkdir osstools;cd osstools

wget https://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos7.0_x86_64.rpm

2. Install

yum install --downloadonly --downloaddir=/home/osstools ossfs_1.80.6_centos7.0_x86_64.rpm

yum -y localinstall *

3. Execute the following commands to configure account access information, and store the Bucket name, AccessKey ID and AccessKey Secret information with access rights to this Bucket in the /etc/passwd-ossfs file. You need to replace BucketName, yourAccessKeyId, and yourAccessKeySecret with Bucket Name, AccessKey ID, and AccessKey Secret . (Ask the administrator for these three things)

echo BucketName:yourAccessKeyId:yourAccessKeySecret > /etc/passwd-ossfs

4. Run the following command to grant permissions to the passwd-ossfs file.

chmod 640 /etc/passwd-ossfs

5. Create a mount directory

mkdir -p /home/oss

6. Execute the following command to mount the Bucket to the specified directory oss. You need to replace BucketName, mountfolder, and Endpoint with the bucket name, the created oss ​​folder, and the endpoint of the classic network access (intranet) of ECS of OSS.

Here is the extranet endpoint: oss-cn-beijing.aliyuncs.com

Format: ossfs BucketName mountfolder -o url=Endpoint

Example: ossfs oss-gongyisy /home/oss -o url=oss-cn-beijing.aliyuncs.com

Normally there is no error, if there is an error RequestTimeTooSkewed, the solution is to update the local time (date -s "2022-11-09 15:30")

Check whether the mount is successful: df -h or df -h | grep oss

7. Self-hanging when booting (optional, the content is modified according to the actual situation)

vi /etc/init.d/ossfs

#! /bin/bash

#

# ossfs      Automount Aliyun OSS Bucket in the specified direcotry.

#

# chkconfig: 2345 90 10

# description: Activates/Deactivates ossfs configured to start at boot time.

# ossfs BucketName mountfolder -o url=Endpoint -oallow_other

ossfs oss-gongyisy /home/oss -o url=oss-cn-beijing.aliyuncs.com

After :wq is saved, give permission to chmod a+x /etc/init.d/ossfs, and then set the boot to start chkconfig ossfs on

8. Uninstall (use when needed)

 umount -l /home/oss

9. Use test

It needs to be under the assigned Object path (such as ECSOSS/u-art3cjmk/) to have permission to operate

dd, cp, and rsync are all available. Conclusion: theoretically, it can be used as shared storage (as long as there are no restrictions on the server side)

 

 

Guess you like

Origin blog.csdn.net/tiging/article/details/127770798