Use ECS and OSS to build a personal network disk

1. Environment preparation
Alibaba Cloud, apply for an ECS server, OS: CentOS 7.9
root/RedHat@123
IP: 139.196.174.156
Cloudreve

 https://developer.aliyun.com/article/855141?spm=a2c6h.13813017.content3.7.1d614151NeJLpx

On the right side of the page, click Switch to Web Terminal, and switch the interface to Web Terminal to automatically connect to the ECS server.

insert image description here

2. Service installation
**

(1) Install Cloudreve

**

1. Execute the following command to download the cloudreve installation package.

wget https://labfileapp.oss-cn-hangzhou.aliyuncs.com/cloudreve_3.3.1_linux_amd64.tar.gz

  1. After the download is complete, execute the following command to decompress the cloudreve installation package.
tar -zxvf cloudreve_3.3.1_linux_amd64.tar.gz
  1. Run the following command to grant permission to cloudreve.
chmod +x ./cloudreve
  1. Execute the following command to run cloudreve
./cloudreve

The returned results are as follows, and you can see the administrator account and password.
insert image description here
5. Open the browser, visit http://<ECS public network address>:5212, enter the administrator account and password in sequence, and click Login.
insert image description here
6. Press Ctrl+C in the terminal to stop cloudreve.

**

(2) install ossfs

**

  1. Run the following command to download the ossfs installation package.
wget https://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos8.0_x86_64.rpm
  1. After the download is complete, execute the following command to install ossfs.

2.1 Replace the yum source first (Centos8 yum official source is offline)

#1.先删除系统内过期的.repo文件
rm -f /etc/yum.repos.d/*

#2.载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

#3.运行 yum makecache 生成缓存
yum clean all && yum makecache

insert image description here

2.2 install ossfs

yum install -y ./ossfs_1.80.6_centos8.0_x86_64.rpm

The returned result is as follows, which means that ossfs is installed successfully.
insert image description here
3. Execute the following command to configure account access information, and store the Bucket name, AccessKey ID and AccessKey Secret information with this Bucket access permission in the /etc/passwd-ossfs file. You need to replace BucketName, yourAccessKeyId, and yourAccessKeySecret with Bucket Name, AccessKey ID, and AccessKey Secret.

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

insert image description here
Parameter Description:

BucketName: The name of the bucket created in the Alibaba Cloud OSS console, which can be viewed in the drop-down list of cloud product resources in the first section.
yourAccessKeyId: The AccessKey ID with access rights to this Bucket, which can be viewed in the AK ID in the drop-down list of cloud product resources in the first section.
yourAccessKeySecret: The AccessKey Secret with access rights to this Bucket, which can be viewed in the AK Secret in the drop-down list of cloud product resources in the first section.

  1. Run the following command to grant permissions to the passwd-ossfs file.
chmod 640 /etc/passwd-ossfs

**

(3) Mount OSS

**

  1. In the terminal, execute the following command to create a folder named oss.
mkdir oss
  1. 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.
ossfs BucketName mountfolder -o url=Endpoint

For example: ossfs adc-oss-labs01070 oss -o url=oss-cn-shanghai-internal.aliyuncs.com
3. Check whether the mount is successful

在这里插入代码片
df -h

insert image description here
4. Execute the following command to create the file ossfs in the /etc/init.d/ directory, and set the automatic startup script for OSS mounting

vim /etc/init.d/ossfs

After entering the Vim editor, press the i key to enter the editing mode, add the following content, press the Esc key to exit the editing mode after adding, and finally enter :wq and press the Enter key to save and exit the Vim editor.

#! /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

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.
insert image description here
5. Execute the following command to grant executable permission to the newly created ossfs script.

chmod a+x /etc/init.d/ossfs
  1. Execute the following command to use the ossfs startup script as another service and start it automatically after booting.
chkconfig ossfs on

(4) Configure personal network disk

  1. Execute the following command to run cloudreve
./cloudreve

insert image description here

  1. Open a browser, visit http://<ECS public network address>:5212, enter the administrator account and password in sequence, and click Login.

  2. In the upper right corner of the cloudreve main interface, click Management Panel.

  3. In the Determine Site URL Settings dialog box, click Change.
    insert image description here

  4. In the left navigation bar, click Storage Policies

  5. On the Storage Policies page, click Add Storage Policy.

  6. In the Select Storage Method dialog box, select Local Storage.
    insert image description here

  7. On the upload path page of adding a local storage policy, change the storage directory to oss/Object path/{uid}/{path}, and click Next.

Object路径:


insert image description here

  1. On the Direct Link Settings page for adding a native storage policy, click Next.

  2. On the Add Native Storage Policy Upload Restrictions page, click Next.

  3. On the completion page of adding a local storage policy, enter the storage policy name OSS, and click Finish.
    insert image description here

  4. In the left navigation bar, click User Groups.

  5. On the User Group page, click the Edit icon in Admin Actions.
    insert image description here

  6. In the storage policy on the edit admin page, select oss and click save.

  7. In the upper right corner of the user group, click Back to Home.

  8. On the personal network disk page, drag and drop any file to the web page, and close the upload queue after the file is uploaded.
    insert image description here

  9. Open the FireFox ESR browser on the virtual desktop and open the oss console. In the left navigation bar, click the corresponding Bucket name through the Bucket list, and then click File Management.

  10. On the file management page, click the folder named 1.

  11. In the 1 folder, you can see the files uploaded on the personal network disk.
    insert image description here

Guess you like

Origin blog.csdn.net/balanceone/article/details/125726864