1 创建 go-hello-fs项目
2 下载 Go 的 FUSE 库:bazil/fuse
go get bazil.org/fuse
在Linux上创建一个空目录
> mkdir /mnt/myfs
挂载运行
./go-hello-fs --mountpoint=/mnt/myfs --fuse.debug=true
参数说明:
- mountpoint :指定挂载点目录,也就是上面创建的空目录
/mnt/myfs/ ;
- fuse.debug :为了更好的理解用户文件系统,可以把这个开关设置成
true ,这样用户发送的请求对应了后端什么逻辑就一目了然了;
测试跑起来之后,如果没有任何异常,helloworld就是作为一个守护进程,卡主执行,没有任何日志。直到收到请求。
这个时候,我们这个终端窗口就不要动了(待会可以看日志),再新开一个终端用来测试。
df -aTh|grep hello
[root@N01 ~]# df -aTh|grep helloworld
helloworld fuse.go-hello-fs 0.0K 0.0K 0.0K - /mnt/myfs
分布式文件系统