如何使用 fstab 自动挂载 ceph-fuse?

如何使用 fstab 自动挂载 ceph-fuse?
# ceph -v
ceph version 0.56.3 (6eb7e15a4783b122e9b0c85ea9ba064145958aa5)

# repoquery -i ceph

Name        : ceph
Version     : 0.56.3
Release     : 1.el6
Architecture: x86_64
Size        : 26734691
Packager    : Fedora Project
Group       : System Environment/Base
URL         : http://ceph.com/
Repository  : epel
Summary     : User space components of the Ceph file system
Source      : ceph-0.56.3-1.el6.src.rpm
Description :
Ceph is a distributed network file system designed to provide excellent
performance, reliability, and scalability.

从命令行手动安装工作正常:

# ceph-fuse /mnt/ceph/
ceph-fuse[28617]: starting ceph client
ceph-fuse[28617]: starting fuse

# df -h
Filesystem            Size  Used Avail Use% Mounted on
ceph-fuse              72T  2.9T   70T   4% /mnt/ceph

但我想在启动时自动执行此操作。Google 向我指出页。

/usr/sbin/mount.fuse.ceph

#!/bin/sh
#
# Helper to mount ceph-fuse from /etc/fstab.  To use, add an entry
# like:
#
# # DEVICE                           PATH         TYPE        OPTIONS
# id=admin                           /mnt/ceph    fuse.ceph   defaults   0 0
# id=myuser,conf=/etc/ceph/foo.conf  /mnt/ceph2   fuse.ceph   defaults   0 0
#
# where the device field is a comma-separated list of options to pass on
# the command line.  The examples above, for example, specify that
# ceph-fuse will authenticated as client.admin and client.myuser
# (respectively), and the second example also sets the 'conf' option to
# '/etc/ceph/foo.conf' via the ceph-fuse command line.  Any valid
# ceph-fuse can be passed in this way.

set -e

# convert device string to options
cephargs='--'`echo $1 | sed 's/,/ --/g'`

# strip out 'noauto' option; libfuse doesn't like it
opts=`echo $4 | sed 's/,noauto//' | sed 's/noauto,//'`

# go
exec ceph-fuse $cephargs $2 $3 $opts

因此我尝试添加以下内容/etc/fstab

id=admin,conf=/etc/ceph/ceph.conf   /mnt/ceph       fuse.ceph   defaults    0 0

mount -a给我:

# mount -a
unrecognized command

因为据我了解,实际上,上述条目将按如下方式运行:

# mount -t fuse.ceph id=admin,conf=/etc/ceph/ceph.conf /mnt/ceph/
unrecognized command

我做错什么了吗?

答案1

我认为正确的语法应该是:

/usr/sbin/mount.fuse.ceph#      /mnt/ceph       fuse        defaults    0 0

那么它将被运行为:

# mount -t fuse /usr/sbin/mount.fuse.ceph# /mnt/ceph/
ceph-fuse[14811]: starting ceph client
ceph-fuse[14811]: starting fuse

验证挂载点是否已启动并正在运行:

# df /mnt/ceph/
Filesystem           1K-blocks      Used Available Use% Mounted on
ceph-fuse            77189145600 3011411968 74177733632   4% /mnt/ceph

参考:http://tracker.ceph.com/issues/3229

答案2

哦,好像这个版本和那个版本有些不同EPEL 仓库以及来自官方仓库

# ceph -v
ceph version 0.56.6 (95a0bda7f007a33b0dc7adf4b330778fa1e5d70c)

# rpmquery -i ceph
Name        : ceph                         Relocations: (not relocatable)
Version     : 0.56.6                            Vendor: (none)
Release     : 0.el6                         Build Date: Sat 04 May 2013 09:29:00 AM ICT
Install Date: Fri 10 May 2013 11:39:11 AM ICT      Build Host: gitbuilder-centos6-amd64.front.sepia.ceph.com
Group       : System Environment/Base       Source RPM: ceph-0.56.6-0.el6.src.rpm
Size        : 27854806                         License: GPL-2.0
Signature   : RSA/SHA1, Sat 04 May 2013 07:25:37 AM ICT, Key ID 7ebfdd5d17ed316d
URL         : http://ceph.com/
Summary     : User space components of the Ceph file system
Description :
Ceph is a distributed network file system designed to provide excellent
performance, reliability, and scalability.

/etc/fstab

conf=/etc/ceph/ceph.conf      /mnt/ceph       fuse.ceph        defaults    0 0

并且fuse.ceph可以指定为文件系统类型:

# mount -t fuse.ceph conf=/etc/ceph/ceph.conf /mnt/ceph/
ceph-fuse[17665]: starting ceph client
ceph-fuse[17665]: starting fuse

更新时间:2013 年 5 月 12 日星期日 13:43:09 ICT

我想我找到了这个问题的根本原因。

来自安装手册页

NOTES
   The syntax of external mount helpers is:

      /sbin/mount.<suffix> spec dir [-sfnv] [-o options] [-t type.subtype]

   where the <type> is filesystem type and -sfnvo options have same meaning like 
   standard mount options.  The  -t option is used  for filesystems with subtypes 
   support (for example /sbin/mount.fuse -t fuse.sshfs).

因此,如果您将类型设置为fuse.ceph,它将使用通常的参数运行,并且如果您从 EPEL repo/sbin/mount.fuse.ceph安装,则此辅助程序不存在:ceph

# rpm -ql ceph-fuse
/usr/bin/ceph-fuse
/usr/sbin/mount.fuse.ceph
/usr/share/doc/ceph-fuse-0.56.3
/usr/share/doc/ceph-fuse-0.56.3/COPYING
/usr/share/man/man8/ceph-fuse.8.gz

这就是您收到错误的原因unrecognized command

快速解决方法是创建一个具有名称/sbin/mount.fuse.ceph和目标的符号链接/usr/sbin/mount.fuse.ceph

ln -s /usr/sbin/mount.fuse.ceph /sbin/mount.fuse.ceph

答案3

Debian以下适用于 ceph-fuse_0.72.2-1:

/etc/fstab

mount.fuse.ceph#conf=/etc/ceph/ceph.conf,id=admin    /mnt/ceph    fuse   noatime,allow_other    0  0

相关内容