[NOTE] Updated June 27, 2016. This article may have outdated content or subject matter.
用 s3fs 挂载云储存服务器
s3fs 是把 Amazon S3 存储服务挂载到本地硬盘或者服务器上的程序,大部分云存储和 S3 兼容,
只需要修改 s3fs 一行代码,它就能挂载到服务器上。
服务器操作系统是 Centos 6.4 64 位,自带的 fuse 版本比较老,用不了新的 s3fs,所以第一件事就是:
yum remove fuse fuse* fuse-devel
安装 s3fs 过程中可能需要的包:
gcc libstdc++-devel gcc-c++ curl curl* curl-devel libxml2 libxml2* libxml2-devel openssl-devel mailcap
开始安装新版本 fuse:
1
2
3
4
5
6
7
8
9
10
| wget http://sourceforge.net/projects/fuse/files/latest/download?source=files
tar -xzvf fuse-2.9.3.tar.gz
cd fuse-2.9.3
./configure --prefix=/usr
make
make install
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
ldconfig
modprobe fuse #可能提示有错误,不管
pkg-config --modversion fuse
|
接着在服务器上装 s3fs:
1
2
3
4
5
6
| wget https://code.google.com/p/s3fs/downloads/detail?name=s3fs-1.74.tar.gz
tar -xvf s3fs-1.74.tar.gz
cd s3fs-1.74
vim src/s3fs.cpp
|
在这个 src/s3fs.cpp
中查找下面那行的内容:
1
| std::string host = "http://s3.amazonaws.com";
|
把 s3.amazonaws.com
替换成 你需要的地址,然后再编译:
1
2
3
| ./configure --prefix=/usr
make
make install
|
建立密匙文件:
1
2
3
4
| vim ~/.passwd-s3fs
#文件中内容如下:
AccessKeyID:AccessSecretKey
|
保存后,设置其权限:
1
| chmod 600 ~/.passwd-s3fs
|
万事俱备,挂载命令如下:
1
| s3fs bucket 要挂的目录 -ouse_cache=/tmp
|
如果想开机自动挂载,那就修改 / etc/fstab,最下面加一行:
1
| s3fs bucket 要挂的目录 fuse allow_other 0 0
|
挂载以后的好处就是方便,cp mv 之类的命令总比 s3cmd 来的简单。
Author
Atman
LastMod
2016-06-27
License
CC BY-NC-ND 4.0 | 本文不带任何官方色彩,最终解释权归本站所有