如何在CentOS scsi-target-utils包中启用对ceph的支持?

时间:2016-02-17 09:50:52

标签: centos iscsi ceph

我要将ceph重新导出到iSCSI,但我无法做到这一点。看起来在没有rbd支持的情况下编译的CentOS 7中的epel包 scsi-target-utils

当我跑步时:

$ sudo tgtadm --lld iscsi --mode system --op show
System:
    State: ready
    debug: off
LLDs:
    iscsi: ready
    iser: error
Backing stores:
    sheepdog
    bsg
    sg
    null
    ssc
    smc (bsoflags sync:direct)
    mmc (bsoflags sync:direct)
    rdwr (bsoflags sync:direct)
    aio
Device types:
    disk
    cd/dvd
    osd
    controller
    changer
    tape
    passthrough
iSNS:
    iSNS=Off
    iSNSServerIP=
    iSNSServerPort=3205
    iSNSAccessControl=Off

我没有看到任何与ceph相关的字符串。作为noted on ceph site,rbd支持补丁已被接受到tgt存储库的主线。

如何在CentOS 7中将rbd支持启用到scsi-target-utils包中?

1 个答案:

答案 0 :(得分:0)

正如我调查的那样,在scsi-target-utils包中实际禁用了rbd支持。如果您安装它的SRPM并查看此软件包的SPEC文件,您可以看到它。

以下是此文件的7-8行:

# Disable rbd on epel7 b/c deps are not present
%{!?rhel:%global with_rbd 1}

此外,scsi-target-utils中的此backstore还有一个附加依赖项。您需要安装ceph-devel软件包(可以从ceph repos中获取)。

因此,要使用rbd支持安装scsi-target-utils,您需要执行以下操作:

  1. 添加官方ceph存储库
  2. 添加epel存储库
  3. 安装构建环境
  4. 下载并安装scsi-target-utils SRPM
  5. 在SRPM的规范文件中设置全局标志with_rbd
  6. 构建SRPM
  7. 为scsi-target-utils安装依赖包
  8. 安装内置的scsi-target-utils和scsi-target-utils-rbd软件包
  9. 或者用Bash语言:

    cd /tmp
    sudo yum install -y epel-release
    sudo rpm --import 'https://download.ceph.com/keys/release.asc'
    sudo yum install -y http://download.ceph.com/rpm/rhel7/noarch/ceph-release-1-1.el7.noarch.rpm
    sudo yum install -y yum-utils rpm-build redhat-rpm-config make gcc
    yumdownloader --source scsi-target-utils
    rpm -i scsi-target-utils*.src.rpm
    cd ~/rpmbuild
    sed -ie 's/%{!?rhel:%global with_rbd 1}/%global with_rbd 1/' SPECS/scsi-target-utils.spec
    sudo yum install -y libxslt docbook-style-xsl libaio-devel systemd-devel libibverbs-devel librdmacm-devel ceph-devel glusterfs-api-devel
    rpmbuild -ba SPECS/scsi-target-utils.spec
    sudo yum install -y ./RPMS/x86_64/scsi-target-utils-1.*.rpm ./RPMS/x86_64/scsi-target-utils-rbd-1.*.rpm
    

    安装完成后启动tgtd守护程序并检查可用组件:

    $ sudo systemctl enable tgtd.service
    $ sudo systemctl start tgtd.service
    $ sudo tgtadm --lld iscsi --mode system --op show
        System:
        State: ready
        debug: off
    LLDs:
        iscsi: ready
        iser: error
    Backing stores:
        rbd (bsoflags sync:direct)
        sheepdog
        bsg
        sg
        null
        ssc
        smc (bsoflags sync:direct)
        mmc (bsoflags sync:direct)
        rdwr (bsoflags sync:direct)
        aio
    Device types:
        disk
        cd/dvd
        osd
        controller
        changer
        tape
        passthrough
    iSNS:
        iSNS=Off
        iSNSServerIP=
        iSNSServerPort=3205
        iSNSAccessControl=Off