目前,Ganesha支持两种方式将Ceph导出为NFS,一种是基于CephFS——Ganesha通过FSAL-CEPH模块连接到CephFS,另一种是基于RGW——Ganesha通过FSAL-RGW模块连接到RGW。
其中,FSAL_RGW 调用 librgw2 将 NFS 协议转义为 S3 协议再通过 RGW 存入到 Ceph 中,FSAL_CEPH 调用 libcephfs1 将 NFS 转义为 Cephfs 协议再存入到 Ceph 中。
关于Ganesha,参见文章《Ganesha详解》
关于CephFS + Ganesha NFS,参见文章《[Ceph]cephfs + Ganesha调研》
本文,主要是对RGW + Ganesha进行调研和分析。
作者:Younger Liu,
本作品采用知识共享署名-非商业性使用-相同方式共享 3.0 未本地化版本许可协议进行许可。
原文地址:http://blog.csdn.net/younger_china/article/details/73432726
参见文章《[Ceph]RGW基本原理》
RGW为Rados Gateway的缩写,ceph通过RGW为互联网云服务提供商提供对象存储服务。RGW在librados之上向应用提供访问ceph集群的RestAPI,支持Amazon S3和OpenStack Swift两种接口。对RGW最直接的理解就是一个协议转换层,把从上层应用符合S3或swift协议的请求转换成rados的请求,将数据保存在rados集群中。
采用最新代码:
# git clone -b V2.3-stablehttps://github.com/nfs-ganesha/nfs-ganesha.git --recursive v2.3_stable
安装依赖:
# yum install -y gcc cmake autoconf gcc-c++ krb5-libs krb5-devellibtool bison flex doxygen openssl-devel gcc-c++ libuuid-devel nfs-utils
执行编译:
[root@node0 v2.3_stable]# mkdir build
[root@node0 v2.3_stable]# cd build/
[root@node0 build]# cmake -DUSE_FSAL_RGW=ON-DUSE_FSAL_CEPH=ON ../src/
[root@node0 build]# make
[root@node0 build]# make install
如果如初如下错误
-- Compilation from within a git repository. Using git rev-parseHEAD
-- found krb5-config here /usr/bin/krb5-config
-- Found kerberos 5 headers: /include
-- Found kerberos 5 libs: /usr/lib64/libkrb5.so;/usr/lib64/libk5crypto.so;/usr/lib64/libcom_err.so;/usr/lib64/libgssapi_krb5.so
CMake Error at CMakeLists.txt:495 (message):
Cannot find GSS libraries
此错误时是因为没有安装依赖包krb5-devel,请安装krb5-devel,然后删除build目录,重新执行cmake
如果重新如下标识:
-- -------------------------------------------------------
-- USE_FSAL_PROXY = ON
-- USE_FSAL_VFS = ON
-- USE_FSAL_CEPH = OFF
-- USE_FSAL_CEPH_MKNOD =
-- USE_FSAL_CEPH_SETLK =
-- USE_FSAL_CEPH_LL_LOOKUP_ROOT =
-- USE_FSAL_RGW = OFF
-- USE_FSAL_XFS = OFF
请安装相关软件。
如果出现如下错误:
-- Found cephfs libraries: /usr/lib64/libcephfs.so
-- Found rgw libraries: /usr/lib64/librgw.so
-- Could NOT find RGW: Found unsuitable version "..", butrequired is at least "1.1.2" (found /usr)
CMake Warning at CMakeLists.txt:577 (message):
Cannot find supported RGWruntime. Disabling RGW fsal build
与版本有关,建议采用ganesha v2.3 stable版本
确保,确保,确保: -- USE_FSAL_CEPH 为 ON,以及 -- USE_FSAL_RGW 为 ON
-- -------------------------------------------------------
-- PLATFORM = LINUX
-- VERSION = 2.3.3
-- BUILD HOST = node0
-- -------------------------------------------------------
-- USE_FSAL_PROXY = ON
-- USE_FSAL_VFS = ON
-- USE_FSAL_CEPH = ON
-- USE_FSAL_RGW = ON
如果是 OFF,请检查下librgw2-devel或者libcephfs1-devel是否有安装,如果这两个包都已经安装了,还显示为 OFF,可以尝试下清空编译目录:rm-rf /tmp/build/*,再进行编译,如果依旧为 OFF,可以尝试下删除所有的 Ceph 包,再重新 yum install ceph librgw2-devel libcephfs1-devel -y。
如果报出如下错误:
Scanning dependencies of target rpcal
[ 34%] Building C object RPCAL/CMakeFiles/rpcal.dir/nfs_dupreq.c.o
[ 34%] Building C object RPCAL/CMakeFiles/rpcal.dir/rpc_tools.c.o
/root/ganesha/v2.3_stable/src/RPCAL/rpc_tools.c: In function‘xprt_type_to_str’:
/root/ganesha/v2.3_stable/src/RPCAL/rpc_tools.c:106:2: error:enumeration value ‘XPRT_VSOCK’ not handled in switch [-Werror=switch]
switch (type) {
^
/root/ganesha/v2.3_stable/src/RPCAL/rpc_tools.c:106:2: error:enumeration value ‘XPRT_VSOCK_RENDEZVOUS’ not handled in switch[-Werror=switch]
cc1: all warnings being treated as errors
make[2]: *** [RPCAL/CMakeFiles/rpcal.dir/rpc_tools.c.o] Error 1
make[1]: *** [RPCAL/CMakeFiles/rpcal.dir/all] Error 2
make: *** [all] Error 2
原因在于子模块的libntirpc的版本不对,对应2.3 stable版本应该是 @ e9cefd2,通过如下命令处理:
[root@node0 libntirpc]# git submodule update –init
[root@node0 libntirpc]# git reset –hard e9cefd2
从make install的输出信息可以得知配置实例:
-- Install configuration: "Debug"
-- Installing: /etc/ganesha/ganesha.conf
-- Installing: /usr/share/doc/ganesha/config_samples
-- Installing: /usr/share/doc/ganesha/config_samples/ceph.conf
-- Installing: /usr/share/doc/ganesha/config_samples/ds.conf
-- Installing: /usr/share/doc/ganesha/config_samples/gluster.conf
-- Installing: /usr/share/doc/ganesha/config_samples/gpfs.conf
-- Installing:/usr/share/doc/ganesha/config_samples/gpfs.ganesha.exports.conf
-- Installing:/usr/share/doc/ganesha/config_samples/gpfs.ganesha.log.conf
-- Installing:/usr/share/doc/ganesha/config_samples/gpfs.ganesha.main.conf
-- Installing: /usr/share/doc/ganesha/config_samples/gpfs.ganesha.nfsd.conf
-- Installing: /usr/share/doc/ganesha/config_samples/vfs.conf
-- Installing: /usr/share/doc/ganesha/config_samples/xfs.conf
-- Installing: /usr/share/doc/ganesha/config_samples/README
-- Installing: /usr/share/doc/ganesha/config_samples/config.txt
-- Installing: /usr/share/doc/ganesha/config_samples/export.txt
-- Installing: /usr/share/doc/ganesha/config_samples/hpss.conf
-- Installing: /usr/share/doc/ganesha/config_samples/logging..txt
-- Installing:/usr/share/doc/ganesha/config_samples/logrotate_fsal_gluster
-- Installing:/usr/share/doc/ganesha/config_samples/logrotate_ganesha
-- Installing: /usr/share/doc/ganesha/config_samples/lustre.conf
-- Installing: /usr/share/doc/ganesha/config_samples/pt.conf
-- Installing: /usr/share/doc/ganesha/config_samples/rgw.conf
-- Installing: /usr/share/doc/ganesha/config_samples/zfs.conf
Conf文件存放在/etc/ganesha/ganesha.conf
创建RGW,参见文章《[Ceph]创建RGW》
依照实例修改共享配置:
###################################################
#
# EXPORT
#
# To function, all that is required is an EXPORT
#
# Define the absolute minimal export
#
###################################################
EXPORT
{
Export_ID=1;
Path = "/";
Pseudo = /cephfs;
Access_Type = RW;
NFS_Protocols = 4;
Transport_Protocols = TCP;
FSAL {
Name = CEPH;
}
}
EXPORT
{
Export_ID=2;
Path = "/";
Pseudo = /rgw;
Access_Type = RW;
Squash = No_root_squash;
NFS_Protocols = 4;
Transport_Protocols = TCP;
FSAL {
Name = RGW;
User_Id ="testuser";
Access_Key_Id="YUXJRPRS5JEHYV53LVZA";
Secret_Access_Key ="qLKQRj71IvBVrovGRJ4USL70vCCbiFfhPxHC8Hn5";
}
}
RGW {
ceph_conf ="/etc/ceph/ceph.conf";
}
请将User_Id、Access_Key_Id、Secret_Access_Key依据具体环境修改
命令如下:
ganesha.nfsd -f -L -N
本例中
ganesha.nfsd -f /etc/ganesha/ganesha.conf -L /var/log/nfs-ganesha.log -N NIV_DEBUG
如果报出如下错误:(错误日志)
18/06/2017 14:54:09 : epoch 59462391 : node0 : nfs-ganesha-32837[main]main :NFS STARTUP :CRIT :Error (token scan) while parsing (/etc/ganesha/g anesha.conf)
18/06/2017 14:54:09 : epoch 59462391 : node0 :nfs-ganesha-32837[main] config_errs_to_log :CONFIG :CRIT :Config File(/etc/ganesha/ganesha.conf: 13): Unexpectedcharacter (/)
…
原因是路径没有双加引号””.
如果报出如下错误:
18/06/2017 14:57:58 : epoch 59462475 : node0 :nfs-ganesha-33015[main] create_export :FSAL :CRIT :RGW module: librgw initfailed (-5)
解决方法:
经过多次尝试,包括在ganesha.conf内添加init_args 指定秘钥和Ceph的用户,ganesha-nfs 均无法启动,报的错如标题,解决方法就是关闭CephX,将/etc/ceph/ceph.conf内的三个 cephx改为none,然后重启 ceph-mon,ceph-osd,ceph-radosgw, ceph-mds 进程,再启动ganesha-nfs,即可正常运行。
命令格式:
[root@node0 v2.3_stable]# showmount -e
Export list for node0:
/ (everyone)
/ (everyone)
通过NFS客户端挂载
mount -t nfs4{$ganesha-server-ip}:/
本例中
[root@younger mnt]# mount -t nfs4192.168.192.90:/ /mnt/ceph/
root@younger mnt]# ls ceph/*
ceph/cephfs:
test
ceph/rgw:
my-new-bucket
[root@younger mnt]#
说明 CephFS 和 RGW 都已经正常对接。
如果,你所使用的admin用户名下有很多的桶,那么这些桶都会以/mnt/rgw/xxbucket的结构显示出来,如果你在/mnt/rgw/下建立的一个目录,那么就相当于通过 RGW 建立了一个桶,所以,你执行touch /mnt/rgw/123 是会报错的,因为不符合S3的对象必须位于桶内的规定,简单点说,就是把/mnt/rgw/和S3的根目录一一对应即可。
我将 ganesha-nfs 部署到一个较大的集群中去,然后挂载NFS,对挂载目录进行压力测试,测试指令如下:
for i in {0..1000} ;do dd if=/dev/zero of=./$i bs=4k count=$i; done;
目的是,快速写入4KB~4MB不同大小的对象,@徐小胖文章所属出现IOERROR,但是在我的测试中,并未出现IOERROR
for i in {1024..1536} ;do dd if=/dev/zero of=./$i bs=4k count=$i;done;
也未出现IO ERROR
作者:Younger Liu,
本作品采用知识共享署名-非商业性使用-相同方式共享 3.0 未本地化版本许可协议进行许可。
原文地址:http://blog.csdn.net/younger_china/article/details/73432726