找回密码
 注册
查看: 3152|回复: 2

ceph luminous 提供iscsi服务

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-7-10 17:41:02 | 显示全部楼层 |阅读模式
开始安装之前必须要满足以下条件:
! x: I6 P" F6 r6 L* T正在运行的Ceph Luminous版本集群或更高版本的存储群集;(本文我们采用的是M版本)
# k6 z) Q7 i/ uRHEL/CentOS 7.5或者Linux kernel v4.16或更新;0 ^$ m7 R- s' ^# k& ^. Z/ V
同时拥有以下几个包:2 K7 A/ Z- C5 |4 l; N
targetcli-2.1.fb47 or      newer package- u4 D3 }1 J  H/ ^5 @: G& s  F
python-rtslib-2.1.fb64 or      newer package
$ l% l+ }# v2 ?7 z2 b: E! btcmu-runner-1.3.0 or      newer package
# H. ~3 G/ H! Y* \! e0 Z8 [% a  t* pceph-iscsi-config-2.4 or      newer package
3 e. I' q. N$ i* iceph-iscsi-cli-2.5 or      newer package
9 k* s- n& G, c% w注意:我们本次安装ISCSI GW是在OSD 节点上安装
* H1 S$ z9 M5 H* I# R% ?, b" s/ L由于很多童鞋可能获取不到rpm包,所以我这里整理了一下所需要的rpm并且分享了出来,以下是链接
5 z( i  z$ X6 F$ o: i& g链接: https://pan.baidu.com/s/1piNymp6oWLNHvXKaxBszLg 密码: 4vag
9 E" r) E" r: k: `; ~安装部分就不说了只要把rpm包下载到本地,安装很简单,下面来说下配置部分:! R. r6 `9 i9 M4 S% V9 G
首先创建一个iscsi gw的配置文件; E0 s* j* I& {, T0 }, k' e9 z
# touch /etc/ceph/iscsi-gateway.cfg6 p+ x4 h/ F( s1 ]; b9 N
里面内容如下:
! n5 B  f5 X# Z3 n+ g[config]
# b" J- }5 P( m. T9 s# Name of the Ceph storage cluster. A suitable Ceph configuration file allowing4 ~; k) f+ u3 N: d  a- Y; e
# access to the Ceph storage cluster from the gateway node is required, if not* ]) _$ \; D6 q; v
# colocated on an OSD node.
; S( I4 ?$ M# \$ D' C  J9 }cluster_name = ceph
4 c0 a6 x3 ?  B. b- t1 J" d5 n5 }
( H! w6 p( t" f  `  j# Y/ m# Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph9 V* ]' H( j$ I( }1 z
# drectory and reference the filename here
6 y) @/ S- b, u" u0 xgateway_keyring = ceph.client.admin.keyring$ ?7 D4 J3 S$ Y' H+ {
$ a! O/ Y. |3 b3 ?
$ F! H& n5 r, A. ]4 G
# API settings.
( g  \" _# l; g1 w7 D# The API supports a number of options that allow you to tailor it to your  s, \. _* _- K  |7 O/ @
# local environment. If you want to run the API under https, you will need to
$ |, X, i2 u' S# y+ z# create cert/key files that are compatible for each iSCSI gateway node, that is* p3 V6 E/ Q' ~2 K8 ?
# not locked to a specific node. SSL cert and key files *must* be called
% s3 ~5 @" b; v0 N2 V- N# 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory) e1 e1 U# F  _: l1 B
# on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
2 k/ I# j* F, r0 h* j, D, o# z& A; [# to switch to https mode.! Q; U: L6 I/ {' ?9 o$ J

2 z# y' v- C. {0 f. S# To support the API, the bear minimum settings are:0 H; b2 w6 S/ ]
api_secure = false; o6 E6 s3 ]; n8 h' C& S/ ]

8 i# G7 q( `1 [% O# Additional API configuration options are as follows, defaults shown.3 S2 {% s! b" D  X% S
# api_user = admin
/ f/ V( ~3 |& ^! i( ]; T, n8 }* e# api_password = admin; i1 l% m) \1 |
# api_port = 5001
. }$ l. x* H5 |2 z; R; C# trusted_ip_list = 192.168.0.10,192.168.0.11$ o* F( R1 D! g& h4 n7 s
注意:需要修改的地方就行把trusted_ip_list替换成自己实际场景的节点ip
0 {" l" k; Y' \/ v) R& i完事之后重启iscsi服务
! q# k7 @: Z. a4 ^/ Z+ \  R* K# systemctl daemon-reload
; e8 o8 }; L( D4 e" B- }6 ]# systemctl enable rbd-target-api' P0 ]6 @6 T9 l* k: m6 g. \
# systemctl start rbd-target-api0 D) @1 g* B5 j9 B# `
OK到此为止,iscsi gw已经安装配置完成,下面开始创建iscsi target
! p0 H& [" l! I# p# o
$ B) v* a1 }2 }# s1.执行gwcli命令进入iscsi4 e# |" y1 X$ m5 z
2 ?: r6 g' N; Y; J
2.创建iscsi target
5 F/ ]# Y5 Z/ d- c> /> cd /iscsi-target. a4 Q5 n! _- x0 H! }( \' N
> /iscsi-target>  create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
8 T/ ^9 A& o' C0 f3 X
# z  W0 p, W% F3 \7 F, B3 V3.创建iSCSI网关。以下使用的IP是用于iSCSI数据传输的IP,它们可以与trusted_ip_list中列出的用于管理操作的IP相同,也可以不同,看有没有做多网卡分离( W1 Y; L" W: b, q1 k& x' Y
> /iscsi-target> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways2 ]; r$ H9 g3 [" L# k3 n! p
> /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21 skipchecks=true# h! g! X' o# y* h
> /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22 skipchecks=true
7 T: A9 q1 c- o! t# ^' \  d
/ g7 y7 Q7 g4 J) k4.创建一个rbd设备disk_1
6 L% q' T/ Z4 A* w  [) r% o> /iscsi-target...-igw/gateways> cd /disks
! T7 }0 o2 O! v5 q5 R( l' L7 X4 P> /disks> create pool=rbd image=disk_1 size=90G
  J) N( \4 z+ d  H7 y6 I " ]- _$ c; ]  q  A& G- v* a
5.创建iqn+ X% i, D4 \5 F! i2 k! }6 B
> /disks> cd /iscsi-target/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts
" @- L% K* ]& \> /iscsi-target...eph-igw/hosts>  create iqn.1994-05.com.redhat:rh7-client
( O4 ]4 J6 y1 M0 R
# z/ I8 j. y8 k$ q! W3 h6.创建chap的用户名密码,并且chap必须设置,否则服务端是禁止连接的
/ j6 }% j5 ~, Q4 T$ C9 P( X> /iscsi-target...at:rh7-client>  auth chap=myiscsiusername/myiscsipassword
' i& F  \. l- c9 D
# ?1 m# y2 F( l" I% n1 W7.增加磁盘到客户端
  |7 a. F8 g, ^7 i> /iscsi-target...at:rh7-client> disk add rbd.disk_12 _( e. A' H, O. @1 C

4 {/ z* S+ e' G3 W: i7 tOK,到这里就配置完成了,我们看下最终是什么样的
* z3 @/ d5 K2 r' y3 e; a+ {' u4 ]" E* Iiscsi.png7 W3 S: }. `+ d1 O8 R

/ E1 R" T/ e# {- S8 |3 s安装配置完之后就可以挂载使用了,一般也就是windows/Linux,我们先说下Linux下挂载方式
4 n4 o2 ^$ o( a1 z  O) w% |$ \; i7 y+ x, A
1.安装iscsi工具
! `1 U- x/ t, c$ I/ j, h  R# yum install iscsi-initiator-utils
, t7 }' g3 o- e* [2 d& a# yum install device-mapper-multipath* X( [0 s; n* S' S1 p3 X" i

' e" ^: l7 v% V9 l2.配置多路径! c. {5 J* c+ q8 I; B
# mpathconf --enable --with_multipathd y
$ |6 d% h- }, p$ n/ s# ~devices {+ M) H9 ~. Q/ Z2 c$ _/ l3 a
        device {3 h2 c0 ]- g+ X9 L# v( J3 M
                vendor                 "LIO-ORG"
. z6 R8 J# V4 m  Q, \7 u) K                hardware_handler       "1 alua"
* |! ]$ b" d3 a) j* y. T                path_grouping_policy   "failover"
5 w4 E5 P& m$ @- ]                path_selector          "queue-length 0"; ^1 b( c9 v5 ]6 \9 r& B2 q+ K, u
                failback               60
1 @( ^) d) p; h9 ^+ A" J; i                path_checker           tur" w. k5 E  R( X4 [" _
                prio                   alua1 m9 J$ I: d2 y
                prio_args              exclusive_pref_bit9 J& H# Q# Z7 y3 y" p
                fast_io_fail_tmo       25+ k& h5 Y) [9 }1 `+ Y: ~( u) U  f
                no_path_retry          queue- i, w1 B, e6 V  c- P. o7 C; X0 \+ B
        }! m$ ?4 t. R" K6 h
}3 U& h1 Z7 v6 h

; `5 ]+ o8 \" ?2 I3.重启服务
1 V, ^, W; B+ [$ o" O/ p* [# systemctl reload multipathd8 ^. `/ J- |4 A; g4 g/ _: A" W+ g
0 \0 R5 Z9 o8 o0 V
4.配置chap认证, [# X, b& G* M( O1 m# ~
修改配置客户端的名称为之前设置的名称$ ]( G" n& Y/ f( F  R
# vi /etc/iscsi/initiatorname.iscsi ; S) V2 }5 r+ J( p
InitiatorName= iqn.1994-05.com.redhat:rh7-client
& Y+ F7 J5 E6 q修改chap认证配置文件- d: G) D, M% F8 z# D; S: _3 Q
# vi /etc/iscsi/iscsid.conf8 |+ _7 n9 u1 ]7 k9 `. o
node.session.auth.authmethod = CHAP
. J7 k. A! a- a# o% k' r node.session.auth.username = myiscsiusername
0 b# s- S2 e# q* t% Y node.session.auth.password = myiscsipassword% ?- Z) l) b, J
2 J1 c8 p5 ~. M2 t& P
5.查询iscsi target+ e3 G/ {+ l9 r6 B* d4 D0 F% Z0 [7 \
# iscsiadm -m discovery -t -st 10.172.19.21
" d$ |3 c2 F# M6 K9 S2 V $ J. l1 V. `8 h5 n3 O( ^
6.连接target% ~; R! ~$ B& x8 S# e
# iscsiadm -m node -T iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw -l
9 ?# K  x3 h4 O5 A0 o# multipath –ll
/ g0 C. j2 X3 s& g% C : ^, s1 M- b; M* Z) l

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-7-10 21:21:50 | 显示全部楼层

配置yum文件ceph-iscsi

[root@ceph01 ~]# vi /etc/yum.repos.d/CentOS-Base.repo 2 U9 O0 B6 a) O3 {5 ^5 M4 k

5 s1 w$ U0 J  a5 F[Storage]

1 a; G# U. H5 j$ g& a
name=CentOS-$releasever - Storage
) a0 I$ k! X4 E* C. N+ _) o$ o9 n
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64
/ceph-nautilus/
6 k' e$ [( e7 e
gpgcheck=0
. x7 Y5 D2 E8 w! s3 b8 c5 T
enabled=1
8 a% I5 @3 U+ i

1 v, r; c% H  i+ h. z, u[Gluster]
- F1 q! R2 j3 |% b3 H+ {. |5 {) D9 n0 X
name=CentOS-$releasever - Storage4 S9 o/ m, u! `6 r: Q) L
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64/gluster-5
/
/ o% d% a; e5 x; _4 B- M7 s+ D7 q
gpgcheck=0

) m* g# w9 D! |' ]
enabled=1
: j+ d! K, H* D" ~
0 }" f1 D5 t& u, \1 u9 U
[ceph-iscsi]

1 c5 b$ Y5 ]6 C6 Q
name=CentOS-$releasever - Storage: H+ \3 n9 }7 x* ?8 p' A
baseurl=https://mirrors.huaweicloud.com/ceph/ceph-iscsi/3
/rpm/el7/noarch/' E! q8 F+ z: A( X- B
gpgcheck=0
$ j, k/ k9 {) r4 S+ E( [- _4 t' W
enabled=1# H3 w4 r/ d# t: a3 Z
( ~0 e) @1 R6 k, k
[epel]

8 b+ M3 o+ n0 N3 b+ H
name=CentOS-$releasever - Storage: l# d3 _# Z3 r' B3 t
baseurl=https://mirrors.huaweicloud.com/epel/7Server/x86_64
/5 _: t9 [$ u; O' I: D6 f, \; J2 S2 w3 {" x
gpgcheck=0

: k2 s: U6 g" X% e
enabled=1
2 }( n: w5 g7 P% p8 Q4 X$ }3 a

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-7-10 21:37:05 | 显示全部楼层
直接yum install试试可以发现,只有targetcli和python-rtslib能装上,而且版本都比官网说的要低,好吧,麻烦来了。
* j! p. R- q' i1 W8 l6 W& ^8 s. q6 |" Y" E- L1 g' u2 r9 Y& l
经过一段几个小时*的搜索……从下面链接中找到了rpm包:
! p/ f0 u- H- i: X3 h6 C8 F1 n6 z3 o
Build new RPM for 3.0
, p- }' }; `! z- `Missing ceph-iscsi-cli package4 k$ b- m4 W2 E' P
新建repo文件:
! h% c# b7 M; `6 J: q& F5 _6 P1 A. r+ c8 b; N4 Q0 ~& j2 Y
sudo vim /etc/yum.repo.d/iscsi.repo4 l+ ~' y6 o4 t6 d
cat /etc/yum.repo.d/iscsi.repo
# {4 u) s1 \# [- C# I
  \3 E$ T* W$ H( q[ceph-iscsi]
7 `: O1 W+ ?. i/ e' M5 H' tname=Ceph-iscsi
2 u7 D8 }: C: Mbaseurl=https://4.chacra.ceph.com/r/ceph-iscsi/master/88f3f67981c7da15448f140f711a1a8413d450b0/centos/7/flavors/default/noarch/
9 o. D: f' _' }# w$ x5 bpriority=1; n8 x3 v% ?2 R8 {
gpgcheck=0& r: y2 w6 H6 G
. W- c8 ?9 j+ U8 o: R1 F& f/ N
[tcmu-runner]
) i8 ?0 i5 a+ U$ _9 a$ gname=tcmu-runner9 G& G2 K; b1 j0 B; T/ n+ g$ \
baseurl=https://3.chacra.ceph.com/r/tcmu-runner/master/eef511565078fb4e2ed52caaff16e6c7e75ed6c3/centos/7/flavors/default/x86_64/  z* V% n; k+ B- ^
priority=1
- j4 l, t( q, sgpgcheck=0' a4 C! f0 L+ z/ E1 T1 z$ W* Q: B8 x

1 R# J9 z6 n2 t5 G: x[python-rtslib]4 h5 B6 \9 U; [3 _
name=python-rtslib
- v) P4 t$ m9 F( Y+ }8 tbaseurl=https://2.chacra.ceph.com/r/python-rtslib/master/67eb1605c697b6307d8083b2962f5170db13d306/centos/7/flavors/default/noarch/. S5 [: _9 z' \6 T, m$ F, T
priority=1
4 `9 A6 K) `/ a5 ?- h# ]1 d6 S  xgpgcheck=05 u) `% o, n: \8 K% |
这里我使用的是本地源,将上面的包下载到本地源:
; }; g% P# y" h: `- a8 a3 ^& a# X) J, o+ k7 i1 P  @) t! ?
sudo yum install --downloadonly --downloaddir=yum/ceph-iscsi/ targetcli python-rtslib tcmu-runner ceph-iscsi
+ Q, p2 O- q* |; |3 P$ k6 U createrepo -p -d -o yum/ yum/
# v& d- ~2 U  g. v' v+ H* L5 ?; R6 q注意到这里没有包含targetcli的repo,因为没有找到,使用yum基础的Base源或者是Ceph源可以安装targetcli-2.1.fb46-7.el7.noarch.rpm, 虽然官网需要的是targetcli-2.1.fb47 or newer package,但在后续使用中发现没有影响,所以这里就不用管targetcli了。4 D% {3 s9 b% N5 U9 ?
  C8 T7 w( `+ Z8 [9 O
那么这里下载下来的就是:
4 K1 Y' s! ]) o' N9 i3 E& D9 l2 f; i: ]+ c
targetcli-2.1.fb46-7.el7.noarch.rpm% @. |" ~" [$ `! M
python-rtslib-2.1.fb68-1.noarch.rpm* Y  p/ h  y1 q% w! _
tcmu-runner-1.4.0-0.1.51.geef5115.el7.x86_64.rpm8 t9 K) C; L  J8 w
ceph-iscsi-3.2-8.g88f3f67.el7.noarch.rpm
6 U. ?" E* I7 {ceph-iscsi网关初始配置2 a& J. T4 q4 G; z! k7 v7 P
如果使用的不是集群内的节点作为ceph-iscsi网关,那就需要进行一些初始的配置。
; }# `8 }7 I  g% i8 C  L/ u) z" V  f! w  X
安装ceph。
$ p* b8 Y8 o3 s& _3 p2 v) U从集群中的一台机器上拷贝/etc/ceph/ceph.conf到本机的/etc/ceph/ceph.conf。  W$ ]5 F- E8 V' x7 m
从集群中的一台机器上拷贝/etc/ceph/ceph.client.admin.keyring到本机的/etc/ceph/ceph.client.admin.keyring。
. q& D4 p; N  ~3 C5 f* q当然第2和3步可以直接在deploy节点使用ceph-deploy admin {node-gateway},{node-gateway}就表示网关节点的名字。
5 E' {% d# u3 C! ?0 ]( b$ v' _
& e; x( d" k, e/ n* Y7 `可见这里就是为了将ceph-iscsi网关节点变成一个admin节点。  S+ T. C0 e: H0 ^9 f

) O: t8 ]3 ^6 [! H" F/ m这时在网关节点上应该可以执行相关命令操作ceph集群,例如sudo ceph -s查询当前集群的状态。% Q# a0 w- f& r% \( J# V
( B' i9 h& M' ^; u  W
安装配置iscsi1 x) T( _$ o- K% B; K( `1 Q3 h
这里官网建议先切换到root用户,方便一点:
' L+ ]/ k3 z- I( [+ w4 k- F: l4 f3 j% n5 g& ~
su root
0 `1 E) M2 G2 n/ t; h6 _' q: g在两个网关节点上都安装iscsi(注意到上面已经将相关包下载到了本地源,所以可以直接yum安装):. a7 G/ ]! R6 Y" I0 g

0 ^2 T3 i6 }) E. f2 y9 n- K2 } yum install -y ceph-iscsi& [4 b9 d  l( }& z! D- M
服务启动:
4 y+ W6 L! O2 g. N0 t2 F/ l) a
' w# x8 Q/ d. |4 @) h* {先创建rbd pool,如果没有的话。. D- [& W6 E  Y* [  x2 J2 Q
" g4 S3 i( H! K: G& ?" |  \( V
ceph osd lspools5 n+ V' C2 x) s  ^

# g( b- A" S9 G% ^- S* b3 V9 X1 cephfs_data2 t  d2 {8 i0 Z! @; q3 c; @
2 cephfs_metadata
+ W+ w: s4 G$ [  Q5 w& v3 \  }# L5 J( K9 `7 C
ceph osd pool create rbd 128
/ s  n9 |0 P8 e& s0 v/ J: n& e* A* [! P4 q  f; b3 \
pool 'rbd' created
2 o  D6 d* E$ _创建并修改/etc/ceph/iscsi-gateway.cfg文件:5 K3 i$ [6 S+ o: B, ~: u7 ?
0 t+ w. o8 G" S. x' @8 O' M& @
vim /etc/ceph/iscsi-gateway.cfg
4 c9 ~8 \" G. z/ |8 L# I cat /etc/ceph/iscsi-gateway.cfg
/ h! Y; y& a/ f) Y* A( B
7 f8 {/ t0 O6 T+ U' r" H; ?) t- V/ R, t[config]
8 A) @5 v6 I$ d2 ?5 w' M Name of the Ceph storage cluster. A suitable Ceph configuration file allowing7 h% J9 M$ Z2 z5 t9 G8 I3 f/ K
access to the Ceph storage cluster from the gateway node is required, if not% @# M9 [9 J' t/ A  h
colocated on an OSD node.
9 @7 X, I% {$ Ucluster_name = ceph
9 c# F3 M' k6 e! D
; p/ v6 z, `, q/ O3 e Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
' z/ [  Y9 @! I3 I- y! [/ F drectory and reference the filename here8 F7 `- Q9 z3 Q- G- L( s
gateway_keyring = ceph.client.admin.keyring
, r# u( y' C0 U, A9 j& W' k( V/ H- P
) R5 {9 @4 ]9 g  |3 z* r4 {
API settings.7 n+ b* p+ Q2 A1 H- I7 d' L  K
The API supports a number of options that allow you to tailor it to your
( q# I# r+ A( ?4 @6 f4 j local environment. If you want to run the API under https, you will need to* Q+ g& C" h- g+ F: n
create cert/key files that are compatible for each iSCSI gateway node, that is
- X. H3 A# c6 u* a& u& r" @* a- x; S% ~ not locked to a specific node. SSL cert and key files *must* be called, h$ f% }9 O' e# U- i
'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory$ V! T2 J' w) I
on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
) y3 w- b$ Z: ], E# X: n: N7 i to switch to https mode.
% G7 N& D6 f7 t
5 c& S: h6 ^3 M# y; h5 L$ v- [ To support the API, the bear minimum settings are:
% T. S3 f" [' [3 L8 `api_secure = false
+ y! ^& p+ U6 S' _
+ i( x/ l. I* X0 ?2 q: h# {4 h2 M9 ` Additional API configuration options are as follows, defaults shown.1 `' |, F) @0 i' }) T' G
api_user = admin
" V- m8 x5 }6 h api_password = admin
( L: ?" P1 T) b5 [+ j2 n  C api_port = 50014 J/ ?0 }+ c8 [, O( _: V( }) f
trusted_ip_list = 192.168.90.234,192.168.90.2358 g2 l2 O7 g  y& Z4 F- O- \, x
上面trusted_ip_list填写的就是两台网关的ip(这里不讨论多网卡的情况)。
5 e9 L, C6 F8 }- _+ K  w; [0 b# s7 d2 G% V1 L# J9 Z4 L
在另外一台网关上复制这个文件:- ?+ a) Z( _7 p

* K1 v' n7 `$ z+ K, b% B4 O sudo scp cluster@node2:/etc/ceph/iscsi-gateway.cfg /etc/ceph/iscsi-gateway.cfg
7 u- k" @9 l9 O# f8 e  f在两台网关上都开启rbd-target-api服务:
& S9 P; T$ F5 P1 m
4 X4 _* r% p: e( x systemctl daemon-reload
+ S3 Y  [3 [* W: \  W: B systemctl enable rbd-target-api4 i% `: |& A! t7 U) j, N
systemctl start rbd-target-api0 p9 }* n! I7 w( F. e  F
配置:(在其中一台网关配置就行), U2 b/ H1 A9 b) M
7 E" Y) K: B6 X) K$ _, l
gwcli- Y* F* L! X& ]  d5 D& I7 k! H/ F
cd /iscsi-targets7 Q. o/ N) @$ j1 X& g# r9 G6 e; }

1 ~+ z6 S! q8 d* m% h( q create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
( Y" ^7 e8 Q; Pok
$ Y) b) }1 H) q0 v5 X. `1 R# @6 \) m! k* r( ~& ?
cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
- O/ D6 X1 Y3 j$ o5 Q8 p1 R, w
7 Y3 N2 B5 G  Q0 D* m. l) H& ?/iscsi-target...-igw/gateways> create node2 192.168.90.234
; B0 A( H/ d2 U4 h+ W+ V& z/ i( AAdding gateway, sync'ing 0 disk(s) and 0 client(s)* V6 n) [9 S3 G6 F# G
ok( T$ i5 f" f2 K2 e1 o

: w  }& N! u; G$ @# p/iscsi-target...-igw/gateways> create node3 192.168.90.235' L) ?' U: o4 i! y( H
Adding gateway, sync'ing 0 disk(s) and 0 client(s)" j" R6 p* F6 E+ @+ D
ok2 j& ]4 m: e/ L: [
( T9 S. k2 ~, m( Y
/iscsi-target...-igw/gateways> cd /disks2 U6 Z- j; @4 `. z+ G9 g

& {- J9 c  r# [; T create pool=rbd image=disk_1 size=200G$ O! k# P( N3 z' x- Y+ n7 m% W
ok+ d2 m8 L* H# A) r. `

* T; L/ V! G! i cd /iscsi-targets/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts
% i. y5 h3 `7 Z
1 R+ e2 Z! D9 f/iscsi-target...csi-igw/hosts> create iqn.1994-05.com.redhat:rh7-client
9 \* r3 s* ?; V+ Q* o8 `ok
) C( F, a. x+ @9 ]; e
3 [: K- Z' p$ ?* S" F/ `/iscsi-target...at:rh7-client> auth username=myiscsiusername password=myiscsipassword
6 P. u: R8 d5 zok
9 y, T4 n6 k9 h% X, _& s8 R
, c, {; A. i: Q2 I( _$ D" ?6 W/iscsi-target...at:rh7-client> disk add rbd/disk_1
, O! R1 P5 |# I1 mok$ |- U) t/ n8 t! c! |% k" M
配置完成,可以看到我当前的目录结构:- Q* p! m2 c! E% C
7 f, j; M9 F  i7 C) G9 ~
ls3 Y- @( R$ k1 X
o- / ......................................................................... [...]# p2 a& X! ~$ f& N
  o- cluster ......................................................... [Clusters: 1]  ~4 B% l. D% V! l/ Z
  | o- ceph .......................................................... [HEALTH_WARN], c3 e2 ?2 m# G8 W
  |   o- pools .......................................................... [Pools: 3]
5 c2 z. w. {, ?! V  |   | o- cephfs_data ... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 2029431878b]
( Z; M' ~# h. D/ Y; ]  |   | o- cephfs_metadata .... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 77834b]3 n! L5 d9 @( F# c2 r2 w
  |   | o- rbd ................ [(x3), Commit: 200G/2028052096K (10%), Used: 15352b]6 r0 l3 x2 C, ?3 B' a7 [5 F
  |   o- topology ................................................ [OSDs: 6,MONs: 3]
+ R1 J! o; |9 p2 a5 l  o- disks ........................................................ [200G, Disks: 1]
, C1 s: ?$ V) P3 p# e1 N  g2 x  | o- rbd ............................................................ [rbd (200G)]
# ]2 w/ n- x. |4 _- \3 Y) F$ d  |   o- disk_1 ................................................ [rbd/disk_1 (200G)]
$ O4 O/ {+ `$ r0 m1 g5 I. q  o- iscsi-targets ............................... [DiscoveryAuth: None, Targets: 1]
# y! ^. r/ n' U6 n7 m2 O( Q$ W7 `; F    o- iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw ..................... [Gateways: 2]
0 x+ ~& k1 R( G! g+ [      o- disks .......................................................... [Disks: 1]
# R7 b5 t; g" _      | o- rbd/disk_1 ............................................... [Owner: node3]
! z! [. c! o$ h1 H      o- gateways ............................................ [Up: 2/2, Portals: 2]  t9 k5 `9 Z) W( W
      | o- node2 ............................................. [192.168.90.234 (UP)]
4 W  k9 }5 w. `0 `      | o- node3 ............................................. [192.168.90.235 (UP)]
4 C! U1 H* _9 {! Y- L* Z      o- host-groups .................................................. [Groups : 0]* A0 y; J* \% r# M6 P. h1 d
      o- hosts .............................................. [Hosts: 1: Auth: CHAP]" N& Q" x( [$ P) D
        o- iqn.1994-05.com.redhat:rh7-client .......... [Auth: CHAP, Disks: 1(200G)]
* S4 X1 T8 o1 m$ C$ q% p# r. Y          o- lun 0 ................................ [rbd/disk_1(200G), Owner: node3]
/ M! i3 `& E- y* k2 clinux客户端配置$ O% Z" t, L+ m9 R' ^
在作为客户端的linux主机上。; `& l+ y7 Q3 ?- l

3 u9 O$ R' W+ X+ n安装相关组件:
  N, R1 Q$ |. ~6 _% }9 K- M7 O: `% l* P9 G7 l0 D9 S
sudo yum install -y iscsi-initiator-utils* u8 l0 B5 ]( X
sudo yum install -y device-mapper-multipath
6 P) e. D: w4 g( B( D开启multipathd服务并进行配置:
# y9 @0 H1 H( b4 P& }+ H1 ^4 Q
# t: {2 Z% L- ?! `1 w9 Z/ y sudo mpathconf --enable --with_multipathd y% j7 _# H/ ?2 [

; }1 a* b; Z5 S/ K+ @/ u5 v sudo vim /etc/multipath.conf
) q2 j: j! Z3 W4 X- z. G, W5 O9 Z sudo cat /etc/multipath.conf
! @' L2 x/ B( D6 O( @% {4 {2 [2 J) l5 x" L9 G9 c2 o
devices {
: N( R% H  u1 {  i$ l        device {
" W/ c' s' |3 O6 C) f5 }' P9 G                vendor                 "LIO-ORG"( J, c& q3 u' R7 v# e% ]
                hardware_handler       "1 alua"$ Q9 q  h  m( s3 M
                path_grouping_policy   "failover"
- F7 [' |( G8 e                path_selector          "queue-length 0"! I& p# ~  {, z" p0 Y
                failback               60" g5 d: _; P3 q5 P# l
                path_checker           tur
0 S% W+ Z' \' B& `$ f0 A                prio                   alua
/ Z) O  t( B' L6 D0 X- j                prio_args              exclusive_pref_bit3 ^+ E2 s- |& ?
                fast_io_fail_tmo       252 Z7 L% T8 j( f; Z) D
                no_path_retry          queue
* Z3 D# J; ?: p1 T) Q4 f        }7 r% D. e+ B4 ~1 c! n$ M
}9 g; Y) N9 L4 r$ ~
修改客户端名称:. X6 k8 v/ w2 i6 c
$ e4 Q# A# t- r7 K. j( K+ }
sudo vim /etc/iscsi/initiatorname.iscsi# Q$ D1 ~5 F" ^# u& c. {+ V+ |
sudo cat /etc/iscsi/initiatorname.iscsi( c. {: v; D$ }7 W

' p3 B2 R4 J$ e9 n  uInitiatorName=iqn.1994-05.com.redhat:rh7-client
; N+ H/ {$ \- n修改chap认证配置文件:7 K- H0 {7 F) j+ }

' k& e6 m' X) a" A0 v sudo vim /etc/iscsi/iscsid.conf
2 D& d; r* }( z1 B& p2 Z" \! b sudo cat /etc/iscsi/iscsid.conf1 w0 j# W1 k2 T

5 M' }' B8 q$ V...
( o+ `, h: g4 u *************7 _' _4 ^$ J4 X, y! D' W
CHAP Settings
- L4 ^: b, @8 W  {2 T *************
1 i  }) ~. w& y% F$ X1 }" N
  M. ^9 Y. C* _ To enable CHAP authentication set node.session.auth.authmethod
8 ]2 N  ]% Z$ H2 m5 q" A to CHAP. The default is None.9 }2 Y- S" g* h4 ^% ^
node.session.auth.authmethod = CHAP1 }5 Y. f, _- q# N5 O( R/ R

( r+ v  g% c- V To set a CHAP username and password for initiator
* O' P" i/ f6 n2 m0 ~/ c: c authentication by the target(s), uncomment the following lines:9 D2 \5 }9 I, d; f0 V2 w' F
node.session.auth.username = myiscsiusername
! ^! B4 Y4 {8 |2 t5 A. O( X; mnode.session.auth.password = myiscsipassword
1 _. j9 x# l! g3 A6 [...
' F9 v2 v  M/ Q4 m; i  r
5 X4 v3 ?6 |* F发现target:6 Q; z5 @! _3 i' X' \/ V8 N0 H
0 h2 V& W- y7 |$ d7 ?
sudo iscsiadm -m discovery -t st -p 192.168.90.234/ _7 |! O2 M' S# w
8 T4 D8 {$ D$ f6 K5 L
192.168.90.234:3260,1 iqn.2003-01.org.linux-iscsi.rheln1/ X: E* h4 Q: P( L
192.168.90.235:3260,2 iqn.2003-01.org.linux-iscsi.rheln1# w/ z% ^# E6 F+ k: L$ N
登入target:4 U4 m$ W5 K+ S+ O% A

2 t! x( i0 R0 \: q: d& F, q3 g2 e sudo iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rheln1 -l! v* z6 B0 E* v0 ?" F
查看是否成功:
: {" z* l6 v3 q& @2 w( v6 R7 E1 p! l; h$ i" [! B4 ?6 `2 z& M
sudo multipath -ll
5 x. ]1 u5 J, \; a5 S4 smpatha (360014050fedd563975249adb2e84e978) dm-2 LIO-ORG ,TCMU device     
5 ~' V! a5 Y7 i  v8 zsize=200G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
) w# H6 A* C: N3 R. N) ~|-+- policy='queue-length 0' prio=50 status=active
1 ^& u9 T% R: H% O1 W7 \! c& Z| `- 3:0:0:0 sdc 8:32 active ready running& X; g+ W* |8 y* [
`-+- policy='queue-length 0' prio=10 status=enabled- A7 i. A2 s& ]: E
  `- 2:0:0:0 sdb 8:16 active ready running- l# A/ {0 D7 m% B
在fdisk中就可以直接看到这个“硬盘”:
( m0 `! k, {; P: H! r! I" E: g! L) D5 L
sudo fdisk -l
* b2 g  u2 d; t4 A4 e
- }7 k4 u1 u  x1 {0 |& Z...
+ U0 t4 B- n& YDisk /dev/mapper/mpatha: 10.7 GB, 10737418240 bytes, 20971520 sectors, M9 `3 p  C+ {- Q/ }  n; ^
Units = sectors of 1 * 512 = 512 bytes* E0 b, N/ b- R. I# |
Sector size (logical/physical): 512 bytes / 512 bytes/ S$ [$ h$ [" o% @9 \4 i
I/O size (minimum/optimal): 512 bytes / 524288 bytes
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:58 , Processed in 0.022362 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表