ossfs能让您在Linux系统中,将对象存储OSS的存储空间(Bucket)挂载到本地文件系统中,您能够像操作本地文件一样操作OSS的对象(Object),实现数据的共享。
运行环境:Rocky Linux release 9.2 (Blue Onyx)
一、依赖包
dnf install gcc-c++ autoconf automake libtool libcurl-devel gettext-devel
二、源码编译libfuse
编译ossfs无法使用系统自带的libfuse,需要下载源码包自行编译,方法如下:
wget https://github.com/libfuse/libfuse/archive/refs/tags/fuse-2.9.9.tar.gz tar zxvf fuse-2.9.9.tar.gz cd libfuse-fuse-2.9.9 ./makeconf.sh ./configure makemake install
make时可能会报如下错误:
make[2]: Entering directory '/root/libfuse-fuse-2.9.9/util' CC fusermount-fusermount.o CC fusermount-mount_util.o CCLD fusermount CC ulockmgr_server-ulockmgr_server.o ulockmgr_server.c:127:12: error: conflicting types for ‘closefrom’; have ‘int(int)’ 127 | static int closefrom(int minfd) | ^~~~~~~~~ In file included from ulockmgr_server.c:14: /usr/include/unistd.h:363:13: note: previous declaration of ‘closefrom’ with type ‘void(int)’ 363 | extern void closefrom (int __lowfd) __THROW; | ^~~~~~~~~ make[2]: *** [Makefile:509: ulockmgr_server-ulockmgr_server.o] Error 1make[2]: Leaving directory '/root/libfuse-fuse-2.9.9/util'make[1]: *** [Makefile:338: all] Error 2make[1]: Leaving directory '/root/libfuse-fuse-2.9.9/util'make: *** [Makefile:450: all-recursive] Error 1
原因是ulockmgr_server.c第127行定义的函数static int closefrom(int minfd)与/usr/include/unistd.h中的定义冲突了,给ulockmgr_server.c中的函数改个名字就好了。
编译安装好libfuse后,需要修改/etc/ld.so.conf,加入:
vim /etc/ld.so.conf /usr/local/lib # 自己编译的libfuse安装目录修改后执行ldconfig -v
三、编译ossfs
git clone https://github.com/aliyun/ossfs.git cd ossfs # 下面这两步很重要exportPKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/:/usr/local/lib/pkgconfig pkg-config --modversion fuse ./configure makemake install
执行configure时可能会报下面的错误:
checking pkg-config is at least version 0.9.0... yeschecking for common_lib_checking... no configure: error: Package requirements (fuse >=2.8.4 libcurl >=7.0 libxml-2.0 >=2.6 ) were not met: Package 'fuse', required by 'virtual:world', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.
原因就是libfuse不兼容,按上面的方法重新编译libfuse即可。