今天咱們來體驗下Ceph原生的ISCSI,可能會有人說哪來的原生ISCSI啊,相信細心的童鞋在Ceph L版本發佈的時候官網手冊裏面就出現了一個iscsi的字樣。是的,沒錯,這就是原聲版的ISCSI雛形,有好消息就有壞消息,不幸的是,截至到目前爲止還不能使用rpm安裝,由於紅帽沒有把rpm釋放出來,只能經過git源碼或別人分享的rpm包進行安裝。node
簡單來講下iscsi的前生今世,分爲兩種一種是tgt實現方式,一種是lio實現方式,那麼在Ceph原生裏面使用的是lio方式,在原生的lio方式出來以前你們廣泛採用的是tgt方式來進行Ceph的ISCSI實現。python
什麼是tgt?linux
Linux target framework(tgt)是爲建立、維護SCSI target 驅動(包括iSCSI、FC、SRP等)提供支持。它的關鍵目標是簡潔地集成到scsi-mid層,而且實現大部分應用層空間的tgt。以 Linux 2.6.38 爲分界線,此前Linux 中默認的SCSI target是STGT,以後的標準是 Linux-IO Target。git
什麼是lio?windows
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的各類功能,而不用購買昂貴的專業設備。api
OK,下面進入正題,來看看Ceph ISCSI的架構圖bash
LIO利用TCMU與Ceph的librbd庫進行交互,並將RBD images映射給iSCSI客戶端。session
開始安裝以前必需要知足如下條件:架構
正在運行的Ceph Luminous版本集羣或更高版本的存儲羣集;(本文咱們採用的是M版本)
RHEL/CentOS 7.5或者Linux kernel v4.16或更新;app
同時擁有如下幾個包:
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,到這裏就配置完成了,咱們看下最終是什麼樣的
安裝配置完以後就能夠掛載使用了,通常也就是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客戶端的名稱
2.若是沒自動出現iscsi門戶的話,須要手動發現門戶
3.這個時候目標裏面已經有一個發現的目標了,顯示狀態是不活動的,點擊鏈接咱們來手動鏈接下
4.點擊高級,選擇門戶IP,填寫chap登錄信息,而後chap信息就是以前設置的用戶名/密碼
5.最後在磁盤管理裏面查看磁盤,分區格式化就可使用了。
最後秀一把M版本的Dashboard V2
本文參考連接: