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

开发者社区> 问答> 正文

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

梦丫头 2017-02-17 14:01:12 37604
首先你的服务器必须是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了。。。。。。。


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



挂载本地 oss本地 ecs服务器oss 挂载oss oss挂载本地
分享到
取消 提交回答
全部回答(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
  • shanghai90
    2017-06-27 23:36:52
    ERRORHOST is not configuredplease check cloudfs.conf


    如下提示,请问正确的HOST应该怎么设置,用的是华东2的服务器和存储。
    0 0
  • 迷之精灵
    2017-05-18 18:07:51
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    服务一切正常,没有报错为什么我在本地目录新建文件夹 控制台看不到呢。

    -------------------------

    Re回 21楼梦丫头的帖子


    这样是不是正常了呢?
    0 0
  • 烟火2015
    2017-05-13 00:38:11
    你好刚用OSS不是很懂  挂载和SDK连接 有什么区别。那个更改
    0 0
  • 博艺
    2017-05-01 22:13:47
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    能不能出歌ubuntu14.04的教程啊,谢谢大神
    0 0
  • pqpo
    2017-04-18 13:17:00
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    通过ESC(1Mbps 带宽)上的链接访问挂载的文件,上传下载速度是按ESC的带宽还是OSS的带宽。
    0 0
  • 装傻
    2017-04-03 01:55:01
    回 楼主梦丫头的帖子
    你好,请问如何设置自启动?这个是否重启服务器后,又要手动启动?

    -------------------------

    回 12楼梦丫头的帖子
    请问挂载后,走的是外网流量吗?我今天按照大神你说的,成功挂载了OSS,结果今天多了好多外网流量,之前都没有的,之前走的是内网,我的ecs是华东2的,OSS也是华东的,按理说应该走的是内网才对啊,是不是需要在配置文件中设置什么,来指定走内网通道??
    0 0
  • 帅哥tt
    2017-04-01 07:15:58
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    ERROR: HOST is not configured, please check cloudfs.conf
    Starting cloudfs:                                          [FAILED]
    按楼主的方法   提示这个
    0 0
  • 洵云
    2017-03-14 11:55:53
    这样哪些存在oss上的图片链接,直接改到服务器上挂载的链接就可以了吧;

    -------------------------

    嗯,真方便;

    -------------------------

    是的,要在配置里把外网地址改为内网的;

    -------------------------

    按照ECS的带宽;

    0 0
  • hongbai
    2017-03-13 13:49:25
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    问下楼主这样挂上以后能像操作普通硬盘那样操作数据么?我之前用的ossfs那个工具发现无法移动(mv)一个900MB的文件。小文件的话就可以

    也可能是我在移动文件的时候新开了一个终端对oss挂载的目录用了ls命令,最后报错

    # mv ../../hg38.fasta.tgz ./
    mv: cannot move '../../hg38.fasta.tgz' to './hg38.fasta.tgz': Input/output error
    0 0
  • 山鹰seo
    2017-03-06 11:18:12
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    之前挂载过好几次 终于挂着成功了
    0 0
  • 梦丫头
    2017-02-22 19:26:45
    你什么版本的系统?

    -------------------------

    回 1楼(糖醋排骨精) 的帖子
    重启服务器是会自动重启的

    -------------------------

    回 4楼(山鹰seo) 的帖子
    恭喜了

    -------------------------

    回 6楼(hongbai) 的帖子
    大的文件我没试过。小的文件是可以的

    -------------------------

    回 8楼(jesuiszb) 的帖子
    是的

    -------------------------

    回 11楼(帅哥tt) 的帖子
    cloudfs.conf配置不对

    -------------------------

    回 20楼(迷之精灵) 的帖子
    确定正常吗?

    -------------------------

    回 22楼(迷之精灵) 的帖子
    你上传看看就知道了

    -------------------------

    回 24楼(shanghai90) 的帖子
    去掉相应OSS前#号

    -------------------------

    回 27楼(zzhello) 的帖子
    不支持
    0 0
  • 糖醋排骨精
    2017-02-21 10:56:44
    Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
    求助。。。昨天晚上装的时候好好的,今天重启之后就变这样了。。。


    [root@izbp19k8xfd8robtenchg8z ~]# service cloudfs start
    Starting cloudfs (via systemctl):  Job for cloudfs.service failed because the control process exited with error code. See "systemctl status cloudfs.service" and "journalctl -xe" for details.
                                                               [FAILED]
    [root@izbp19k8xfd8robtenchg8z ~]# systemctl status cloudfs.service
    ● cloudfs.service - SYSV: cloudfs is a virtual file system that could convert OSS bucket to a directory of ECS
       Loaded: loaded (/etc/rc.d/init.d/cloudfs; bad; vendor preset: disabled)
       Active: failed (Result: exit-code) since Tue 2017-02-21 10:54:07 CST; 9s ago
         Docs: man:systemd-sysv-generator(8)
      Process: 1443 ExecStart=/etc/rc.d/init.d/cloudfs start (code=exited, status=1/FAILURE)


    Feb 21 10:53:32 izbp19k8xfd8robtenchg8z cloudfs[1443]: ACCESS_MODE=0666
    Feb 21 10:53:32 izbp19k8xfd8robtenchg8z cloudfs[1443]: MAX_UPLOAD_THREADS=1
    Feb 21 10:53:32 izbp19k8xfd8robtenchg8z cloudfs[1443]: Configuration Information End
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z cloudfs[1443]: Start to load object from oss:
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z cloudfs[1443]: Load File basic info from [bjf] failed
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z cloudfs[1443]: [26B blob data]
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: cloudfs.service: control process exited, code=exited status=1
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: Failed to start SYSV: cloudfs is a virtual file system that could convert OSS bucket to a dire... of ECS.
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: Unit cloudfs.service entered failed state.
    Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: cloudfs.service failed.
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@izbp19k8xfd8robtenchg8z ~]#

    0 0
滑动查看更多
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

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

相似问题
最新问题
推荐课程