教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘

梦丫头 2017-02-17 14:01:12 35561
首先你的服务器必须是CentOS 6.5 或者 Ubuntu 14.04 系统,否则不能安装和挂载!!


登入你的服务器先 依赖软件安装



CentOS 6.5
yum install libcurl libcurl-devel openssl-devel fuse fuse-libs fuse-devel libxml2-devel git gcc g++ make


Ubuntu 14.04
apt-get update
apt-get install libcurl4-openssl-dev libssl-dev pkg-config libxml2 libxml2-dev libfuse-dev git gcc g++ make  
以下我用 CentOS 6.5 做示范!
输入:yum install libcurl libcurl-devel openssl-devel fuse fuse-libs fuse-devel libxml2-devel git gcc g++ make
遇到确认请输入Y




出现下图说明安装 依赖软件成功






接下来下载安装 cloudfs:
输入:git clone https://git.oschina.net/weiweibaba2007/cloudfs.git






进入:cloudfs_src目录
输入:cd cloudfs/cloudfs_src/






输入:make pack




这样就安装完毕了


接下来挂载OSS  bucke
CentOS 6.5 或 Ubuntu 14.04 安装 挂载



cloudfs 在 CentOS 6.5 和 Ubuntu 14.04发行版上已经有一键式的自动安装脚本,安装相对简单。
cd pack/
./CloudFS_Install.sh INSTALL_DIR=安装目录 MOUNT_POINT=挂载目录 按照命令行提示,即可完成安装。 (会有两个提示确定输入y回车就可以了)
如下图:


./CloudFS_Install.sh INSTALL_DIR=/usr/local/cloudfs_download MOUNT_POINT=/home/ftp/x/xj030/wwwroot
命令说明: MOUNT_POINT=/home/ftp/x/xj030/wwwroot(/home/ftp/x/xj030/wwwroot这个是你网站的目录,比如附件目录什么的)







出现下图就说明安装完成了






接下来修改配置文件
进入:cd /usr/local/cloudfs_download/conf
修改目录下的cloudfs.con文件


#This is the configuration for the OSS related
[OSS Configuration]
# OSS data center url configuration, uncomment the one your bucket resides on.
# If you run cloudfs on aliyun ECS, then use the internal URL. Otherwise, use the public URL.
# ECS
#HOST=oss-cn-qingdao-internal.aliyuncs.com
#HOST=oss-cn-beijing-internal.aliyuncs.com
#HOST=oss-cn-shenzhen-internal.aliyuncs.com
#HOST=oss-cn-hangzhou-internal.aliyuncs.com
#HOST=oss-cn-hongkong-internal.aliyuncs.com
# NOT ECS, but user's server
#HOST=oss-cn-qingdao.aliyuncs.com
#HOST=oss-cn-beijing.aliyuncs.com
#HOST=oss-cn-shenzhen.aliyuncs.com
#HOST=oss-cn-hangzhou.aliyuncs.com
#HOST=oss-cn-hongkong.aliyuncs.com

# OSS Access Id and Access Key configuration, uncommet it and change the value
# to your own id/key.
#ID=your_access_id
#KEY=your_access_key

# OSS bucket configuraion, uncommet it and change the value to you own bucket name
#BUCKET=your_bucket_name

#this is the configuration for the FS related
[FS Configuration]
# The minimal sync interval from oss to cloudfs
# This configuration is only needed when your system will directly
# add/delete oss object from oss web control console or other system.
# 0 means never sync object from oss to cloudfs after booting.
# For most cases, the default value 0 is OK. If you are not sure, just make the default value 0 here.
ONLINE_SYNC_CYCLE=3

# The file data cache block size when upload/download object from oss to cloudfs.
# For most cases, the default value is OK.
BLOCK_SIZE=1048576


# The file data cache limit size when upload/download object from oss to cloudfs.
# For most cases, the default value is OK.
MAX_CACHE_LIMITS=10485760

# LOG output level
# The debug.log file is under the cloudfs running directory.
# When LOG_LEVEL is 1, only error log will output to debug.log file;
# When LOG_LEVEL is 0, both debug and error log will output to debug.log file;
LOG_LEVEL=1

# Postfix for soft link
# OSS does not support unix style softlink file, so cloudfs uses a special postfix for softlink to identify
# it is a soft link file.
# Default value is "s1l2k3", you could change it as you wish.
# But do keep in mind that this postfix should not conflict with any postfix in real world
SYMLINK_POSTFIX=s1l2k3

# The parameter is used to control whether the system need to synchronize data from Aliyun OSS
# when you access a file or dircetory.
# When IMMEDIATE_SYNC=0, indicate no need to synchronize data;
# When IMMEDIATE_SYNC=1, indicate need to synchronize data;
# Default value is 0;
IMMEDIATE_SYNC=1

# mode
ACCESS_MODE=0666

# set the max number of upload threads,
# default value is 1
MAX_UPLOAD_THREADS=1

根据你的OSS地区去掉前面的#如:


# ECS
#HOST=oss-cn-qingdao-internal.aliyuncs.com
#HOST=oss-cn-beijing-internal.aliyuncs.com
#HOST=oss-cn-shenzhen-internal.aliyuncs.com
HOST=oss-cn-hangzhou-internal.aliyuncs.com
#HOST=oss-cn-hongkong-internal.aliyuncs.com
# NOT ECS, but user's server
#HOST=oss-cn-qingdao.aliyuncs.com
#HOST=oss-cn-beijing.aliyuncs.com
#HOST=oss-cn-shenzhen.aliyuncs.com
HOST=oss-cn-hangzhou.aliyuncs.com
#HOST=oss-cn-hongkong.aliyuncs.com
# OSS Access Id and Access Key configuration, uncommet it and change the value

填写Access Key并去掉#
# to your own id/key.
ID=your_access_id(你的Access Key ID)
KEY=your_access_key(你的Access Key Secret)
# OSS bucket configuraion, uncommet it and change the value to you own bucket name
BUCKET=your_bucket_name(你的OSS_bucket名称 )

启动CloudFS,执行命令:


service cloudfs start


停止CloudFS,执行命令:


service cloudfs stop


查看cloudfs运行状态,执行命令:


service cloudfs status




注意事项启动挂载的目录必须是空目录


启动:




这样说明已经将OSS挂载到ECS了。。。。。。。


如果有问题可以回复,或者联系我!



弹性计算 Ubuntu Unix Linux 开发工具 对象存储 C语言 git
分享到
取消 提交回答
全部回答(17)
  • xxjsc5885
    2017-12-06 22:01:58
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    centos 支持6.5版本吗?
    0 0
  • 秋的悲哀
    2017-11-12 11:08:32
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
      感谢分享
    0 0
  • 恬淡人生
    2017-11-10 12:15:49
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    我想说centos 7.2可以装吗?还是只能6.5的版本可以装?其他的版本都装不了?
    0 0
  • zzhello
    2017-10-30 15:02:14
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    centos7 还不支持吗
    0 0
  • 笑武林
    2017-07-28 22:44:59
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    windows 2008 咋办
    0 0
滑动查看更多
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题