OSSFS就以把OSS做爲文件系統的一部分,能讓你在linux系統中把OSS bucket掛載到本地文件系統中,實現數據的共享。linux
ossfs 基於s3fs 構建,具備s3fs 的所有功能。主要功能包括:web
ossfs提供的功能和性能和本地文件系統相比,具備一些侷限性。具體包括:centos
centos 7安全
ossfs_1.80.2_centos7.0_x86_64.rpm服務器
centos 6.5 併發
ossfs_1.80.2_centos6.5_x86_64.rpm高併發
先看一下有沒有安裝fuse,若是有先刪除了性能
yum remove fuse -y
把安裝包傳的服務器而後直接安裝,以centos 7爲例ui
yum -y localinstall ossfs_1.80.2_centos7.0_x86_64.rpm
設置bucket name 和 AccessKeyId/Secret信息,將其存放在/etc/passwd-ossfs 文件中,注意這個文件的權限必須正確設置,建議設爲640。this
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs chmod 640 /etc/passwd-ossfs
這裏涉及到阿里的accessKeyId/Secret的知識。爲了安全咱們應該去新建一個RAM而後生成這個key。並對這個RAM進行限制。這樣即便這個key被泄露,也不會對其它bucket形成危險。
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
能夠把這句加到/etc/rc.local中
fusermount -u /tmp/ossfs
這裏出現的信息均不是真實。
[root@myhost ~]# yum remove fuse Loaded plugins: fastestmirror No Match for argument: fuse No Packages marked for removal [root@myhost ~]# yum localinstall ossfs_1.80.2_centos7.0_x86_64.rpm Loaded plugins: fastestmirror Examining ossfs_1.80.2_centos7.0_x86_64.rpm: ossfs-1.80.2-1.x86_64 Marking ossfs_1.80.2_centos7.0_x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package ossfs.x86_64 0:1.80.2-1 will be installed --> Processing Dependency: fuse >= 2.8.4 for package: ossfs-1.80.2-1.x86_64 Loading mirror speeds from cached hostfile --> Processing Dependency: fuse-libs >= 2.8.4 for package: ossfs-1.80.2-1.x86_64 --> Running transaction check ---> Package fuse.x86_64 0:2.9.2-7.el7 will be installed ---> Package fuse-libs.x86_64 0:2.9.2-7.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================================================== Installing: ossfs x86_64 1.80.2-1 /ossfs_1.80.2_centos7.0_x86_64 4.0 M Installing for dependencies: fuse x86_64 2.9.2-7.el7 base 85 k fuse-libs x86_64 2.9.2-7.el7 base 93 k Transaction Summary =========================================================================================================================================================================================== Install 1 Package (+2 Dependent packages) Total size: 4.2 M Total download size: 178 k Installed size: 4.5 M Is this ok [y/d/N]: y Downloading packages: (1/2): fuse-2.9.2-7.el7.x86_64.rpm | 85 kB 00:00:00 (2/2): fuse-libs-2.9.2-7.el7.x86_64.rpm | 93 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 304 kB/s | 178 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : fuse-libs-2.9.2-7.el7.x86_64 1/3 Installing : fuse-2.9.2-7.el7.x86_64 2/3 Installing : ossfs-1.80.2-1.x86_64 3/3 Verifying : ossfs-1.80.2-1.x86_64 1/3 Verifying : fuse-2.9.2-7.el7.x86_64 2/3 Verifying : fuse-libs-2.9.2-7.el7.x86_64 3/3 Installed: ossfs.x86_64 0:1.80.2-1 Dependency Installed: fuse.x86_64 0:2.9.2-7.el7 fuse-libs.x86_64 0:2.9.2-7.el7 Complete! [root@myhost ~]# echo mybuckey:JMIdhjrtutkGtjjr:eFAC8jinzajflsietagv6JoOwfXbFN > /etc/passwd-ossfs [root@myhost ~]# chmod 640 /etc/passwd-ossfs [root@myhost ~]# ossfs mybuckey /data1 -ourl=oss-cn-shenzhen-internal.aliyuncs.com [root@myhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 40G 2.0G 36G 6% / ossfs 256T 0 256T 0% /data1