【实践】RGW+Ganesha环境部署

          目前,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


1  何为RGW

          参见文章《[Ceph]RGW基本原理

          RGW为Rados Gateway的缩写,ceph通过RGW为互联网云服务提供商提供对象存储服务。RGW在librados之上向应用提供访问ceph集群的RestAPI,支持Amazon S3和OpenStack Swift两种接口。对RGW最直接的理解就是一个协议转换层,把从上层应用符合S3或swift协议的请求转换成rados的请求,将数据保存在rados集群中。

 

2  编译安装Ganesha

采用最新代码:

# 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

 

3  Export Ganesha

Conf文件存放在/etc/ganesha/ganesha.conf

创建RGW,参见文章《[Ceph]创建RGW

3.1   配置

依照实例修改共享配置:

###################################################
#
# 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依据具体环境修改

 

3.2   启动ganesha

命令如下:

ganesha.nfsd -f<location_of_nfs-ganesha.conf_file> -L<location_of_log_file> -N <log_level>

本例中

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,即可正常运行。

 

3.3   检查是否成功Export

命令格式:

[root@node0 v2.3_stable]# showmount -e
Export list for node0:
/ (everyone)
/ (everyone)

 

4  挂载

通过NFS客户端挂载

mount -t nfs4{$ganesha-server-ip}:/  <local_mountpoint>

本例中

[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的根目录一一对应即可。

 

5  RGW+NFS测试

我将 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



  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在 Linux 环境下,您可以通过以下步骤来安装 Ceph 对象网关 (Rados Gateway, RGW): 1. 安装 Ceph 首先,您需要在 Linux 系统上安装 CephCeph 是一个分布式存储系统,RGWCeph 的一部分。您可以从 Ceph 的官方网站下载最新版本的 Ceph 软件包,并按照其文档进行安装。或者,如果您使用的是 Ubuntu 或 Debian 等基于 Debian 的 Linux 发行版,可以通过以下命令安装 Ceph: ``` sudo apt-get update sudo apt-get install ceph ``` 2. 创建 RGW 用户 在安装 RGW 之前,您需要创建一个 Ceph 用户,用于管理 RGW。您可以使用以下命令创建一个名为 rgw-admin 的 Ceph 用户: ``` sudo radosgw-admin user create --uid=rgw-admin --display-name="RGW Administrator" ``` 这将会创建一个具有管理员特权的 RGW 用户。请注意,您需要记住创建用户时生成的访问密钥,后面安装 RGW 时需要使用。 3. 安装 RGW 安装 RGW 之前,您需要确认 Ceph 集群已经正确地配置和运行。然后,您可以使用以下命令安装 RGW: ``` sudo apt-get install radosgw ``` 安装完成后,您需要修改 RGW 配置文件 `/etc/ceph/ceph.conf`,以指定 RGW 的配置参数。以下是一个示例配置文件: ``` [client.rgw.gateway] rgw frontends = "civetweb port=80" # RGW 使用 civetweb 作为 Web 服务器,并监听 80 端口 rgw dns name = <RGW 主机名> # RGW 主机名 rgw keystone url = http://<keystone 主机名>:5000 # OpenStack Keystone 的 URL,用于身份验证 rgw keystone admin user = <管理员用户名> # OpenStack Keystone 管理员用户名 rgw keystone admin password = <管理员密码> # OpenStack Keystone 管理员密码 rgw keystone admin tenant = <管理员租户> # OpenStack Keystone 管理员所在租户名称 rgw keystone api version = 3 # OpenStack Keystone API 版本 rgw s3 auth use keystone = true # 使用 OpenStack Keystone 进行身份验证 rgw enable usage log = true # 启用 RGW 的使用日志 rgw usage log tick interval = 15 # 使用日志的时间间隔 [client.rgw.gateway.civetweb] port = 80 # civetweb 监听的端口 ``` 在修改完成 RGW 配置文件后,您需要启动 RGW 服务,以便它可以监听来自客户端的请求: ``` sudo systemctl start radosgw ``` 此外,您还可以通过以下命令检查 RGW 服务是否正在运行: ``` sudo systemctl status radosgw ``` 如果 RGW 服务已经成功启动,您应该能够看到类似于以下的输出: ``` ● radosgw.service - LSB: radosgw RESTful rados gateway Loaded: loaded (/etc/init.d/radosgw; generated) Active: active (running) since Thu 2021-10-07 15:24:07 CST; 5s ago Docs: man:systemd-sysv-generator(8) Process: 18589 ExecStart=/etc/init.d/radosgw start (code=exited, status=0/SUCCESS) Tasks: 35 (limit: 4915) CGroup: /system.slice/radosgw.service ├─18598 /usr/bin/radosgw --foreground --conf /etc/ceph/ceph.conf --rgw-frontends=civetweb port=80 ├─18599 /usr/bin/radosgw --foreground --conf /etc/ceph/ceph.conf --rgw-frontends=civetweb port=80 └─18600 /usr/bin/radosgw --foreground --conf /etc/ceph/ceph.conf --rgw-frontends=civetweb port=80 ``` 4. 配置 RGW 安装和启动 RGW 后,您需要为 RGW 配置用户访问权限。您可以使用以下命令创建一个名为 test-bucket 的 S3 存储桶: ``` sudo s3cmd mb s3://test-bucket ``` 此外,您还可以使用以下命令在 test-bucket 存储桶中上传一个名为 test-object 的对象: ``` sudo s3cmd put <本地文件路径> s3://test-bucket/test-object ``` 然后,您可以使用以下命令从 test-bucket 存储桶中下载 test-object 对象: ``` sudo s3cmd get s3://test-bucket/test-object <本地文件路径> ``` 这些命令应该可以帮助您在 Linux 环境下安装和配置 Ceph 对象网关 (RGW)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YoungerChina

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值