Search Posts

挂载阿里云oss到centos6 7服务器文件夹

内容纲要

centos7 ubuntu等官方教程

安装ossfs :https://help.aliyun.com/zh/oss/developer-reference/use-ossfs-to-mount-an-oss-bucket-to-the-local-directories-of-an-ecs-instance
开机启动:https://help.aliyun.com/zh/oss/developer-reference/advanced-configurations
oss定价:https://www.aliyun.com/price/detail/oss

注意点

个人测试centos6 7 安装后直接输入ossfs
-bash: ossfs: command not found
可执行文件在 /usr/local/bin/ossfs
所以可以/usr/local/bin/ossfs 加命令运行
或者

ln -s /usr/local/bin/ossfs /usr/bin/ossfs

就可以单独使用ossfs不用输入路径了

centos6 挂载oss

官方文档是不支持的
参考教程 https://blog.csdn.net/gaoshanliushui131/article/details/104779009/
但是教程安装完fuse没有ldconfig
所以提示

/usr/local/bin/ossfs: error while loading shared libraries: libfuse.so.2: cannot open shared object file: No such file or directory

完整安装挂载开机启动命令

# 安装依赖
yum install automake  gcc-c++ git libcurl-devel libxml2-devel make openssl-devel

# 安装 fuse
wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz
tar -zxvf fuse-2.9.9.tar.gz
cd fuse-2.9.9
./configure
make
make install

# 添加环境变量
vi /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

source /etc/profile
#刷新共享库缓存
ldconfig

# 查看版本
pkg-config --modversion fuse
#创建验证文件
sudo sh -c 'echo bucket-test:LTAIbZcdVCmQ****:MOk8x0y9hxQ31coh7A5e2MZEUz**** > /etc/passwd-ossfs'
sudo chmod 640 /etc/passwd-ossfs
#根据自己的地域  内网 外网 选择地址
sudo mkdir /tmp/ossfs
sudo ossfs bucket-test /tmp/ossfs -o url=http://oss-cn-hangzhou-internal.aliyuncs.com
#创建开机启动
 vim /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 bucket-test /tmp/ossfs -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com -oallow_other

 chmod a+x /etc/init.d/ossfs
 chkconfig ossfs on

English

Mount Alibaba Cloud OSS to CentOS 6/7 Server Directory

  1. Install ossfs:

  2. Startup Configuration:

  3. oss Pricing:

Notes:

During personal testing on CentOS 6 and 7, after installation, directly entering ossfs resulted in -bash: ossfs: command not found. The executable file is located at /usr/local/bin/ossfs. Therefore, you can run /usr/local/bin/ossfs followed by the command. Alternatively, you can create a symbolic link as follows:

ln -s /usr/local/bin/ossfs /usr/bin/ossfs

This allows using ossfs standalone without specifying the full path.

Mounting OSS on CentOS 6:

Official documentation does not support CentOS 6. However, you can refer to this tutorial. Note that after installation, the tutorial lacks the ldconfig command, resulting in the following error:

/usr/local/bin/ossfs: error while loading shared libraries: libfuse.so.2: cannot open shared object file: No such file or directory

Complete Installation, Mounting, and Startup Command:

# Install dependencies
yum install automake gcc-c++ git libcurl-devel libxml2-devel make openssl-devel

# Install fuse
wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz
tar -zxvf fuse-2.9.9.tar.gz
cd fuse-2.9.9
./configure
make
make install

# Add environment variables
vi /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

source /etc/profile
# Refresh shared library cache
ldconfig

# Check version
pkg-config --modversion fuse

# Create authentication file
sudo sh -c 'echo bucket-test:LTAIbZcdVCmQ****:MOk8x0y9hxQ31coh7A5e2MZEUz**** > /etc/passwd-ossfs'
sudo chmod 640 /etc/passwd-ossfs

# Depending on your region (internal, external), choose the address
sudo mkdir /tmp/ossfs
sudo ossfs bucket-test /tmp/ossfs -o url=http://oss-cn-hangzhou-internal.aliyuncs.com

# Create startup script
vim /etc/init.d/ossfs

#! /bin/bash
#
# ossfs      Automount Aliyun OSS Bucket in the specified directory.
#
# chkconfig: 2345 90 10
# description: Activates/Deactivates ossfs configured to start at boot time.

ossfs bucket-test /tmp/ossfs -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com -oallow_other

chmod a+x /etc/init.d/ossfs
chkconfig ossfs on

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注