发表主题 回复主题
  • 2649阅读
  • 10回复

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

级别: 总版主
发帖
6366
云币
14356

— 本帖被 不靠谱贝贝 设置为精华(2017-02-20) —
首先你的服务必须是CentOS 6.5 或者Ubuntu 14.04 系统,否则不能安装和挂载!! eRVY.E<  
Lv3XYZgW~  
Rd vn)K  
登入你的服务器先依赖软件安装 59K}  
*k!(ti[  
RCCv>o  
5Fr;  
CentOS 6.5 CX.SYr&!R  
yum install libcurl libcurl-devel openssl-devel fuse fuse-libs fuse-devel libxml2-devel git gcc g++ make Vbo5`+NAis  
B MY>a  
?Oqzd$-  
Ubuntu 14.04 UIz:=DJ  
apt-get update {Wa~}1`Kl  
apt-get install libcurl4-openssl-dev libssl-dev pkg-config libxml2 libxml2-dev libfuse-dev git gcc g++ make   #_{0Ndp2  
以下我用CentOS 6.5 做示范! quY "  
输入:yum install libcurl libcurl-devel openssl-devel fuse fuse-libs fuse-devel libxml2-devel git gcc g++ make ]2LXUYB  
遇到确认请输入Y ;Na^]32  
%`eJ66T  
b h*^{  
JxnuGkE0[#  
T G_bje  
出现下图说明安装依赖软件成功 p %L1uwLG  
rNZO.qij z  
^DzL$BX  
yAAG2c4(  
rAM *\=  
3;y_qwA  
|.Em_*VG  
接下来下载安装cloudfs: :Jjw"}SfK#  
输入:git clone https://git.oschina.net/weiweibaba2007/cloudfs.git >dyhox2*"  
Xthtw*  
Q js2hj-$  
sr;:Dvx~  
Q!YF!WoBX  
L+8=P<]  
;i.I&*t  
进入:cloudfs_src目录 ~:T3|  
输入:cd cloudfs/cloudfs_src/ )@!~8<_"  
MF&3e#mdB  
|3S'8Oe CI  
$p jf#P8U  
&S<? 07Z  
xIM8  
{%=S+89l  
输入:make pack M8\G>0Hc6  
{5U1`>  
UHr {  
ok%EqO  
1po"gVot  
这样就安装完毕了 9!5b2!JL  
KLG6QBkj  
:-$cdZ3E  
接下来挂载OSS  bucke |.y>[+Qb*  
CentOS 6.5 或 Ubuntu 14.04 安装 挂载 Km[]^;6  
B"7$!Co  
{`+bW"9  
\k|_&hG  
cloudfs 在 CentOS 6.5 和 Ubuntu 14.04发行版上已经有一键式的动安装脚本,安装相对简单。 $/NGNkl[  
cd pack/ d|>9rX+f  
./CloudFS_Install.sh INSTALL_DIR=安装目录 MOUNT_POINT=挂载目录 按照命令行提示,即可完成安装。 (会有两个提示确定输入y回车就可以了) I h5/=_n  
如下图: X QI.0L"  
[Xs}FJ  
UN,<6D3\b  
./CloudFS_Install.sh INSTALL_DIR=/usr/local/cloudfs_download MOUNT_POINT=/home/ftp/x/xj030/wwwroot 1f+*Tmc5]Q  
命令说明: MOUNT_POINT=/home/ftp/x/xj030/wwwroot(/home/ftp/x/xj030/wwwroot这个是你网站的目录,比如附件目录什么的) uOyLC<I/  
"g x5XW&  
+`Q PBj^  
{[l'S  
# rh0r`  
vs5 D:cZ}  
F?}m8ZRv  
3{.9O$  
出现下图就说明安装完成了 6&i[g  
Ytl:YzXCi  
9`ri J4zl  
~|X99?P  
^AovkK(p  
ZkJY.H-F  
~*66 3pA  
接下来修改配置文件 XS}Zq4H  
进入:cd /usr/local/cloudfs_download/conf >xxXPvM<`  
修改目录下的cloudfs.con文件 nG&w0de<>  
[VfL v.8w  
uKLOh<oio  
  1. #This is the configuration for the OSS related
  2. [OSS Configuration]
  3. # OSS data center url configuration, uncomment the one your bucket resides on.
  4. # If you run cloudfs on aliyun ECS, then use the internal URL. Otherwise, use the public URL.
  5. # ECS
  6. #HOST=oss-cn-qingdao-internal.aliyuncs.com
  7. #HOST=oss-cn-beijing-internal.aliyuncs.com
  8. #HOST=oss-cn-shenzhen-internal.aliyuncs.com
  9. #HOST=oss-cn-hangzhou-internal.aliyuncs.com
  10. #HOST=oss-cn-hongkong-internal.aliyuncs.com
  11. # NOT ECS, but user's server
  12. #HOST=oss-cn-qingdao.aliyuncs.com
  13. #HOST=oss-cn-beijing.aliyuncs.com
  14. #HOST=oss-cn-shenzhen.aliyuncs.com
  15. #HOST=oss-cn-hangzhou.aliyuncs.com
  16. #HOST=oss-cn-hongkong.aliyuncs.com
  17. # OSS Access Id and Access Key configuration, uncommet it and change the value
  18. # to your own id/key.
  19. #ID=your_access_id
  20. #KEY=your_access_key
  21. # OSS bucket configuraion, uncommet it and change the value to you own bucket name
  22. #BUCKET=your_bucket_name
  23. #this is the configuration for the FS related
  24. [FS Configuration]
  25. # The minimal sync interval from oss to cloudfs
  26. # This configuration is only needed when your system will directly
  27. # add/delete oss object from oss web control console or other system.
  28. # 0 means never sync object from oss to cloudfs after booting.
  29. # For most cases, the default value 0 is OK. If you are not sure, just make the default value 0 here.
  30. ONLINE_SYNC_CYCLE=3
  31. # The file data cache block size when upload/download object from oss to cloudfs.
  32. # For most cases, the default value is OK.
  33. BLOCK_SIZE=1048576
  34. # The file data cache limit size when upload/download object from oss to cloudfs.
  35. # For most cases, the default value is OK.
  36. MAX_CACHE_LIMITS=10485760
  37. # LOG output level
  38. # The debug.log file is under the cloudfs running directory.
  39. # When LOG_LEVEL is 1, only error log will output to debug.log file;
  40. # When LOG_LEVEL is 0, both debug and error log will output to debug.log file;
  41. LOG_LEVEL=1
  42. # Postfix for soft link
  43. # OSS does not support unix style softlink file, so cloudfs uses a special postfix for softlink to identify
  44. # it is a soft link file.
  45. # Default value is "s1l2k3", you could change it as you wish.
  46. # But do keep in mind that this postfix should not conflict with any postfix in real world
  47. SYMLINK_POSTFIX=s1l2k3
  48. # The parameter is used to control whether the system need to synchronize data from Aliyun OSS
  49. # when you access a file or dircetory.
  50. # When IMMEDIATE_SYNC=0, indicate no need to synchronize data;
  51. # When IMMEDIATE_SYNC=1, indicate need to synchronize data;
  52. # Default value is 0;
  53. IMMEDIATE_SYNC=1
  54. # mode
  55. ACCESS_MODE=0666
  56. # set the max number of upload threads,
  57. # default value is 1
  58. MAX_UPLOAD_THREADS=1
rC=p;BC@dD  
根据你的OSS地区去掉前面的#如: eLHa9R{)B  
|_Naun=+~  
f)&`mqeE  
  1. # ECS
  2. #HOST=oss-cn-qingdao-internal.aliyuncs.com
  3. #HOST=oss-cn-beijing-internal.aliyuncs.com
  4. #HOST=oss-cn-shenzhen-internal.aliyuncs.com
  5. HOST=oss-cn-hangzhou-internal.aliyuncs.com
  6. #HOST=oss-cn-hongkong-internal.aliyuncs.com
  7. # NOT ECS, but user's server
  8. #HOST=oss-cn-qingdao.aliyuncs.com
  9. #HOST=oss-cn-beijing.aliyuncs.com
  10. #HOST=oss-cn-shenzhen.aliyuncs.com
  11. HOST=oss-cn-hangzhou.aliyuncs.com
  12. #HOST=oss-cn-hongkong.aliyuncs.com
  13. # OSS Access Id and Access Key configuration, uncommet it and change the value
!nP8ysB  
填写Access Key并去掉# S&4w`hdD>~  
  1. # to your own id/key.
  2. ID=your_access_id(你的Access Key ID)
  3. KEY=your_access_key(你的Access Key Secret)
  4. [backcolor=#ffffff][color=#008ef1]# OSS bucket configuraion, uncommet it and change the value to you own bucket name[/color][/backcolor]
  5. BUCKET=your_bucket_name(你的OSS_bucket名称 )
~G|{q VO7A  
启动CloudFS,执行命令: 9*G L@_c  
|R_xY=z?  
:kf3_?9rc  
service cloudfs start u;l6sdo  
pAPQi|CN  
\K4CbZ,.  
停止CloudFS,执行命令: ^)eessZ  
mCEKEX  
n@ yd{Rc  
service cloudfs stop Y(Z(dV!Po  
37ri b  
skmDsZzw  
查看cloudfs运行状态,执行命令: [nhLhl4S  
*aSRKY  
IdC k  
service cloudfs status H)?" 8 s  
RY'\mt"W2  
N2S!.H!Wz  
.{Eg(1At  
v J,xz*rc`  
注意事项启动挂载的目录必须是空目录 ['9OGV\  
;M(ehX  
&bOodkOb  
启动: !513rNO  
EC\rh](d 1  
|L~gNC  
bj* v'  
K\%"RgF@&  
这样说明已经将OSS挂载到ECS了。。。。。。。 H 29 _ /  
jrMGc=KL  
2Dwt4V  
如果有问题可以回复,或者联系我! >f9]Nj  
c9_4 ohB  
5xn0U5U  
^ _#gIT\  
[ 此帖被梦丫头在2017-02-20 18:40重新编辑 ]
级别: 新人
发帖
1
云币
1
只看该作者 沙发  发表于: 02-21
Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
求助。。。昨天晚上装的时候好好的,今天重启之后就变这样了。。。 '1T v1  
MyR\_)P?  
ZI:d&~1i1  
[root@izbp19k8xfd8robtenchg8z ~]# service cloudfs start 6b 5{  
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. ="PywZ  
                                                           [FAILED] !"qEB2r  
[root@izbp19k8xfd8robtenchg8z ~]# systemctl status cloudfs.service BqJrL/(  
● cloudfs.service - SYSV: cloudfs is a virtual file system that could convert OSS bucket to a directory of ECS jI pcMN<  
   Loaded: loaded (/etc/rc.d/init.d/cloudfs; bad; vendor preset: disabled) Dl!'_u  
   Active: failed (Result: exit-code) since Tue 2017-02-21 10:54:07 CST; 9s ago HrcnyQ`Q0  
     Docs: man:systemd-sysv-generator(8) \>CBam8d  
  Process: 1443 ExecStart=/etc/rc.d/init.d/cloudfs start (code=exited, status=1/FAILURE) ,PtR^" Mf4  
(IWd?,H,n  
X!'Xx8  
Feb 21 10:53:32 izbp19k8xfd8robtenchg8z cloudfs[1443]: ACCESS_MODE=0666 <L[)P{jn?p  
Feb 21 10:53:32 izbp19k8xfd8robtenchg8z cloudfs[1443]: MAX_UPLOAD_THREADS=1 ]$X=~>w  
Feb 21 10:53:32 izbp19k8xfd8robtenchg8z cloudfs[1443]: Configuration Information End ntUVhIE0  
Feb 21 10:54:07 izbp19k8xfd8robtenchg8z cloudfs[1443]: Start to load object from oss: [+2^n7R  
Feb 21 10:54:07 izbp19k8xfd8robtenchg8z cloudfs[1443]: Load File basic info from [bjf] failed A=>6$L];'  
Feb 21 10:54:07 izbp19k8xfd8robtenchg8z cloudfs[1443]: [26B blob data] f;I"tugO  
Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: cloudfs.service: control process exited, code=exited status=1 +.Ukzu~s  
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. Lgw@y!Llij  
Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: Unit cloudfs.service entered failed state. (W6\%H2u  
Feb 21 10:54:07 izbp19k8xfd8robtenchg8z systemd[1]: cloudfs.service failed. '<j p.sZQ  
Hint: Some lines were ellipsized, use -l to show in full. B,qZwc|  
[root@izbp19k8xfd8robtenchg8z ~]#  o?x|y   
SVeU7Q6-  
[ 此帖被糖醋排骨精在2017-02-21 10:58重新编辑 ]
级别: 总版主
发帖
6366
云币
14356

只看该作者 板凳  发表于: 02-22
你什么版本的系统?
级别: 总版主
发帖
6366
云币
14356

只看该作者 地板  发表于: 02-22
回 1楼(糖醋排骨精) 的帖子
重启服务器是会自动重启的
级别: 新人
发帖
6
云币
7
只看该作者 4楼 发表于: 03-06
Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
之前挂载过好几次 终于挂着成功了
级别: 总版主
发帖
6366
云币
14356

只看该作者 5楼 发表于: 03-06
回 4楼(山鹰seo) 的帖子
恭喜了
级别: 新人
发帖
1
云币
1
只看该作者 6楼 发表于: 03-13
Re教你如何简单将OSS bucket挂载成为阿里云ECS服务器本地盘
问下楼主这样挂上以后能像操作普通硬盘那样操作数据么?我之前用的ossfs那个工具发现无法移动(mv)一个900MB的文件。小文件的话就可以 lgC|3]  
t 7D2k2x9  
也可能是我在移动文件的时候新开了一个终端对oss挂载的目录用了ls命令,最后报错 jV^Dj  
C'ZF#Z  
# mv ../../hg38.fasta.tgz ./ dA<PQKm  
mv: cannot move '../../hg38.fasta.tgz' to './hg38.fasta.tgz': Input/output error
级别: 总版主
发帖
6366
云币
14356

只看该作者 7楼 发表于: 03-13
回 6楼(hongbai) 的帖子
大的文件我没试过。小的文件是可以的
级别: 论坛版主
发帖
229
云币
278
只看该作者 8楼 发表于: 03-14
这样哪些存在oss上的图片链接,直接改到服务器上挂载的链接就可以了吧;
级别: 总版主
发帖
6366
云币
14356

只看该作者 9楼 发表于: 03-14
回 8楼(jesuiszb) 的帖子
是的
级别: 论坛版主
发帖
229
云币
278
只看该作者 10楼 发表于: 03-15
嗯,真方便;
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
验证问题: 12 - 6 = ?
上一个 下一个