看Ceph如何實現原生的ISCSI

今天我們來體驗下Ceph原生的ISCSI,可能會有人說哪來的原生ISCSI啊,相信細心的童鞋在Ceph L版本發佈的時候官網手冊裏面就出現了一個iscsi的字樣。是的,沒錯,這就是原聲版的ISCSI雛形,有好消息就有壞消息,不幸的是,截至到目前爲止還不能使用rpm安裝,因爲紅帽沒有把rpm釋放出來,只能通過git源碼或別人分享的rpm包進行安裝。

 

簡單來說下iscsi的前生今世,分爲兩種一種是tgt實現方式,一種是lio實現方式,那麼在Ceph原生裏面使用的是lio方式,在原生的lio方式出來之前大家普遍採用的是tgt方式來進行Ceph的ISCSI實現。

 

什麼是tgt?

Linux target framework(tgt)是爲創建、維護SCSI target 驅動(包括iSCSI、FC、SRP等)提供支持。它的關鍵目標是簡潔地集成到scsi-mid層,並且實現大部分應用層空間的tgt。以 Linux 2.6.38 爲分界線,此前Linux 中默認的SCSI target是STGT,之後的標準是 Linux-IO Target。

什麼是lio?

Linux-IO Target在Linux內核中(linux 2.6.38後),用軟件實現各種SCSI Target,其支持的SAN技術中所有流行的存儲協議包括Fibre Channel(Qlogic,linux3.5)、FCoE(linux3.0)、iSCSI(linux 3.1)、iSER (Mellanox InfiniBand,linux3.10), SRP (Mellanox InfiniBand,linux3.3), USB等,同時還能爲本機生成模擬的SCSI設備,以及爲虛擬機提供基於virtio的SCSI設備。Linux-IO Target使用戶能夠使用相對廉價的Linux系統實現SCSI、SAN的各種功能,而不用購買昂貴的專業設備。

 

OK,下面進入正題,來看看Ceph ISCSI的架構圖

iscsi-1.png

LIO利用TCMU與Ceph的librbd庫進行交互,並將RBD images映射給iSCSI客戶端。

 

開始安裝之前必須要滿足以下條件:

正在運行的Ceph Luminous版本集羣或更高版本的存儲羣集;(本文我們採用的是M版本)
RHEL/CentOS 7.5或者Linux kernel v4.16或更新;

同時擁有以下幾個包:

  • targetcli-2.1.fb47 or      newer package

  • python-rtslib-2.1.fb64 or      newer package

  • tcmu-runner-1.3.0 or      newer package

  • ceph-iscsi-config-2.4 or      newer package

  • ceph-iscsi-cli-2.5 or      newer package

注意:我們本次安裝ISCSI GW是在OSD 節點上安裝

由於很多童鞋可能獲取不到rpm包,所以我這裏整理了一下所需要的rpm並且分享了出來,以下是鏈接

鏈接: https://pan.baidu.com/s/1piNymp6oWLNHvXKaxBszLg 密碼: 4vag

安裝部分就不說了只要把rpm包下載到本地,安裝很簡單,下面來說下配置部分:

首先創建一個iscsi gw的配置文件

# touch /etc/ceph/iscsi-gateway.cfg

裏面內容如下:

[config]
# Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
# access to the Ceph storage cluster from the gateway node is required, if not
# colocated on an OSD node.
cluster_name = ceph
 
# Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
# drectory and reference the filename here
gateway_keyring = ceph.client.admin.keyring
 
 
# API settings.
# The API supports a number of options that allow you to tailor it to your
# local environment. If you want to run the API under https, you will need to
# create cert/key files that are compatible for each iSCSI gateway node, that is
# not locked to a specific node. SSL cert and key files *must* be called
# 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory
# on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
# to switch to https mode.
 
# To support the API, the bear minimum settings are:
api_secure = false
 
# Additional API configuration options are as follows, defaults shown.
# api_user = admin
# api_password = admin
# api_port = 5001
# trusted_ip_list = 192.168.0.10,192.168.0.11

注意:需要修改的地方就行把trusted_ip_list替換成自己實際場景的節點ip

完事之後重啓iscsi服務

# systemctl daemon-reload
# systemctl enable rbd-target-api
# systemctl start rbd-target-api

OK到此爲止,iscsi gw已經安裝配置完成,下面開始創建iscsi target


1.執行gwcli命令進入iscsi

 

2.創建iscsi target

> /> cd /iscsi-target
> /iscsi-target>  create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw


3.創建iSCSI網關。以下使用的IP是用於iSCSI數據傳輸的IP,它們可以與trusted_ip_list中列出的用於管理操作的IP相同,也可以不同,看有沒有做多網卡分離

> /iscsi-target> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
> /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21 skipchecks=true
> /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22 skipchecks=true


4.創建一個rbd設備disk_1

> /iscsi-target...-igw/gateways> cd /disks
> /disks> create pool=rbd image=disk_1 size=90G


5.創建iqn

> /disks> cd /iscsi-target/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts
> /iscsi-target...eph-igw/hosts>  create iqn.1994-05.com.redhat:rh7-client


6.創建chap的用戶名密碼,並且chap必須設置,否則服務端是禁止連接的

> /iscsi-target...at:rh7-client>  auth chap=myiscsiusername/myiscsipassword


7.增加磁盤到客戶端

> /iscsi-target...at:rh7-client> disk add rbd.disk_1


OK,到這裏就配置完成了,我們看下最終是什麼樣的

iscsi.png


安裝配置完之後就可以掛載使用了,一般也就是windows/Linux,我們先說下Linux下掛載方式


1.安裝iscsi工具

# yum install iscsi-initiator-utils
# yum install device-mapper-multipath


2.配置多路徑

# mpathconf --enable --with_multipathd y
devices {
        device {
                vendor                 "LIO-ORG"
                hardware_handler       "1 alua"
                path_grouping_policy   "failover"
                path_selector          "queue-length 0"
                failback               60
                path_checker           tur
                prio                   alua
                prio_args              exclusive_pref_bit
                fast_io_fail_tmo       25
                no_path_retry          queue
        }
}


3.重啓服務

# systemctl reload multipathd


4.配置chap認證

修改配置客戶端的名稱爲之前設置的名稱

# vi /etc/iscsi/initiatorname.iscsi 
 InitiatorName= iqn.1994-05.com.redhat:rh7-client

修改chap認證配置文件

 # vi /etc/iscsi/iscsid.conf
 node.session.auth.authmethod = CHAP
 node.session.auth.username = myiscsiusername
 node.session.auth.password = myiscsipassword


5.查詢iscsi target

# iscsiadm -m discovery -t -st 10.172.19.21


6.連接target

# iscsiadm -m node -T iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw -l
# multipath –ll



Windows掛載方式


1.修改windows iscsi客戶端的名稱

iscsi2.png


2.如果沒自動出現iscsi門戶的話,需要手動發現門戶

iscsi3.png


3.這個時候目標裏面已經有一個發現的目標了,顯示狀態是不活動的,點擊連接我們來手動連接下

iscsi4.png


4.點擊高級,選擇門戶IP,填寫chap登陸信息,然後chap信息就是之前設置的用戶名/密碼

iscsi5.png

iscsi6.png


5.最後在磁盤管理裏面查看磁盤,分區格式化就可以使用了。

iscsi7.png


最後秀一把M版本的Dashboard V2

iscsi8.png


本文參考鏈接:

http://docs.ceph.com/docs/master/rbd/iscsi-target-cli/

http://www.zphj1987.com/2018/04/11/ceph-ISCSI-GATEWAY/


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章