How to enable support for ceph in CentOS scsi-target-utils package?

2.4k Views Asked by At

I'm going to re-export ceph into iSCSI, but I can't do this. Looks like epel package scsi-target-utils in CentOS 7 compiled without rbd support.

When I run:

$ 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

I don't see any ceph related strings. As noted on ceph site the rbd support patch has been accepted into the mainline of tgt repository.

How to enable rbd support into scsi-target-utils package in CentOS 7?

1

There are 1 best solutions below

0
On

As I investigated, rbd support actually disabled in scsi-target-utils package. You can see it if you install it's SRPM and look at SPEC file of this package.

Here are 7-8 lines of this file:

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

Also there is an additional dependency for this backstore in scsi-target-utils. You will need to install ceph-devel package (could be fetched from ceph repos).

So, to install scsi-target-utils with rbd support you need to do actions below:

  1. Add official ceph repository
  2. Add epel repository
  3. Install build environment
  4. Download and install scsi-target-utils SRPM
  5. Set global flag with_rbd in SRPM's spec file
  6. Build SRPM
  7. Install dependent packages for scsi-target-utils
  8. Install built scsi-target-utils and scsi-target-utils-rbd packages

Or in Bash language:

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

After installation was finished start tgtd daemon and check for available components:

$ 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