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

ceph luminous 提供iscsi服务

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-7-10 17:41:02 | 显示全部楼层 |阅读模式
开始安装之前必须要满足以下条件:
5 _; ]" ]* N# ^) x6 \. H7 s+ L正在运行的Ceph Luminous版本集群或更高版本的存储群集;(本文我们采用的是M版本)/ r; I- B+ e) c* }& E4 j
RHEL/CentOS 7.5或者Linux kernel v4.16或更新;1 O1 S" ]6 m! A% z/ y  Z( _* g- \
同时拥有以下几个包:
9 B9 ?! ]$ k: m0 `2 t+ U' stargetcli-2.1.fb47 or      newer package
( z/ l7 w" n5 bpython-rtslib-2.1.fb64 or      newer package$ c& ]& H* v: }# o  _" Y
tcmu-runner-1.3.0 or      newer package" Z) n0 F) |; k( w; _! E3 p
ceph-iscsi-config-2.4 or      newer package
: F, `: C3 G7 ^) c/ r, t) \0 Y! ]ceph-iscsi-cli-2.5 or      newer package
+ x. M% B8 W# {! ^$ j  x; v8 Q注意:我们本次安装ISCSI GW是在OSD 节点上安装
6 d" N: k# [( g* J6 f由于很多童鞋可能获取不到rpm包,所以我这里整理了一下所需要的rpm并且分享了出来,以下是链接
5 K, b$ k" U, O链接: https://pan.baidu.com/s/1piNymp6oWLNHvXKaxBszLg 密码: 4vag7 T: I) q, M( G" W
安装部分就不说了只要把rpm包下载到本地,安装很简单,下面来说下配置部分:' N8 ~/ W, o: @+ M. B" J
首先创建一个iscsi gw的配置文件# }& P) q0 t6 u! b! E  Q' A4 [
# touch /etc/ceph/iscsi-gateway.cfg: n; ^' k# N/ ^) ]9 f
里面内容如下:, c3 s% s3 d* _1 n
[config]
! p# g( z- O2 H4 G9 g# Name of the Ceph storage cluster. A suitable Ceph configuration file allowing, F- E" w$ L5 H" f
# access to the Ceph storage cluster from the gateway node is required, if not2 [# R: B$ B5 @
# colocated on an OSD node.
: x% y& S' A5 S; O4 h# icluster_name = ceph9 p) d! o4 I% g' g% g
3 e6 a4 z* R7 ]% ^
# Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
6 @3 `- @2 E1 h5 S6 p- Z7 Y& L# drectory and reference the filename here
/ q. a& M2 A4 h, g% x( Ggateway_keyring = ceph.client.admin.keyring
- u2 o- D' p! ^, V
& n* g! @$ \4 k2 o3 S) a
( e/ [; }& c' L2 y# API settings.
4 b) l% X$ \+ r  N# The API supports a number of options that allow you to tailor it to your
+ r' x, T# V8 ^5 g3 R# local environment. If you want to run the API under https, you will need to. O6 t0 }8 U  _) s5 r6 _  [
# create cert/key files that are compatible for each iSCSI gateway node, that is
  y& E( H% [' m* V# not locked to a specific node. SSL cert and key files *must* be called5 ?* `4 `  B. N# p2 g/ @7 s
# 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory
- I# V4 ~4 A( k4 d' b. {; u# on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
7 i5 @$ h, T) u6 Q  H  p# to switch to https mode.# B2 _* v6 x" t2 ^9 {

: C1 w( z7 a- I% \# To support the API, the bear minimum settings are:! D3 S( n2 r2 e  \  |# I6 L
api_secure = false8 W* B# ?7 L8 f
# s1 ?( N0 z2 ]( [2 A
# Additional API configuration options are as follows, defaults shown.
& j, {$ q1 n2 M' m# api_user = admin
' E: I8 N1 _' T5 D% u4 Y# api_password = admin
$ T" {4 A8 S% y4 X  c# api_port = 5001
+ W3 d. E1 h" G# trusted_ip_list = 192.168.0.10,192.168.0.11  l, |' y3 b9 m: l  X! n) S
注意:需要修改的地方就行把trusted_ip_list替换成自己实际场景的节点ip
) u# K, n# V6 h完事之后重启iscsi服务
: Z1 _$ v8 v; x# systemctl daemon-reload
$ P" t4 X) i" o8 a: O. i# systemctl enable rbd-target-api
2 D" J: a1 P, i0 C( j5 X. H8 o4 Z# systemctl start rbd-target-api
% y7 L9 l- Y9 y+ }OK到此为止,iscsi gw已经安装配置完成,下面开始创建iscsi target
0 o+ a0 Y( N0 u. B# _- Q3 X" n" q; S4 j1 \' }! ?7 n
1.执行gwcli命令进入iscsi! q, P, W" t8 q. P  n" l7 R/ s! a
3 D; Z9 M; F) o: N2 x/ e
2.创建iscsi target
) _7 N: H7 A- A. r. ?> /> cd /iscsi-target
* u4 Q3 F0 k+ c+ B# R; t: u3 Q> /iscsi-target>  create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw' c  S8 S( a2 I8 V( F$ u
9 f$ ^) G2 Q, W* j% `0 ?2 B
3.创建iSCSI网关。以下使用的IP是用于iSCSI数据传输的IP,它们可以与trusted_ip_list中列出的用于管理操作的IP相同,也可以不同,看有没有做多网卡分离( W- ^2 F* V1 ~, N/ n% i0 R
> /iscsi-target> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
8 M2 q9 Y. z& x- u3 B* G> /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21 skipchecks=true
: Z! Z) _2 w: i6 m9 R% m> /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22 skipchecks=true
+ l9 P# a* }* Q  A% n  n) I* `0 y8 _ + m' _' C: D1 I6 e; w
4.创建一个rbd设备disk_1
+ @- |5 O1 Q0 t> /iscsi-target...-igw/gateways> cd /disks
0 Y* S! A' C: l  X/ Q3 b/ M> /disks> create pool=rbd image=disk_1 size=90G
; v2 Z7 `/ Z$ ?2 w5 S6 v
$ l& Q/ L) s  {3 @% ?# R4 ]; g5.创建iqn
: N# c5 ^9 e/ D5 `$ H: A; Y> /disks> cd /iscsi-target/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts! p' A$ g0 t6 X  x
> /iscsi-target...eph-igw/hosts>  create iqn.1994-05.com.redhat:rh7-client& b; w' s; k( \$ D
5 p# u3 J/ \) e! [- p
6.创建chap的用户名密码,并且chap必须设置,否则服务端是禁止连接的
) V+ t3 Q# `+ y% Q> /iscsi-target...at:rh7-client>  auth chap=myiscsiusername/myiscsipassword9 O1 ?1 o7 s( _

1 K4 f- @) l# J9 h4 ^7.增加磁盘到客户端/ Q; V8 z% ^5 a3 O+ s! p8 w# x
> /iscsi-target...at:rh7-client> disk add rbd.disk_1
5 J: ~& A1 i  N2 S2 Y/ F4 k* t8 e
9 _$ ?: {$ j7 M  V$ ^2 w' [9 I% S, ]OK,到这里就配置完成了,我们看下最终是什么样的
) k7 c" i/ Z  @0 M: `. I/ F' Liscsi.png
# ]& E% c5 v& T; L* @" m) m! Q& Z. i# n+ E$ y" }1 o4 Q" w
安装配置完之后就可以挂载使用了,一般也就是windows/Linux,我们先说下Linux下挂载方式
1 z8 b' i5 h) A$ [+ R
0 l4 Z& v/ i" {8 Y# o8 P1.安装iscsi工具
9 A3 m5 I  f/ w' v7 F' O* N# yum install iscsi-initiator-utils
. m* U! p! M! t' o2 ^$ N# yum install device-mapper-multipath
- }* C$ ?+ n9 ]9 d% n3 X  K
! S4 h" S" F- u- T& n- Z2 P2.配置多路径
; \/ ]3 d* ?. n; e# mpathconf --enable --with_multipathd y
; x3 n- o2 c' K( i# l# d1 }devices {9 p6 v' L- b1 v$ C! E
        device {
6 X) ?& V4 E5 j% v) y                vendor                 "LIO-ORG") g( u: m5 B- d3 y# r5 {
                hardware_handler       "1 alua"  ~" ~6 f3 \& I7 U
                path_grouping_policy   "failover"
; \: _( Q* W* }* b1 v  e                path_selector          "queue-length 0"
& i8 u0 i1 W8 u) A                failback               60
) e) L: |# P3 l( w, D                path_checker           tur
7 c0 X8 p4 M& ]' l; B+ n                prio                   alua
" f" P$ }8 f  O- D$ V. I# x                prio_args              exclusive_pref_bit2 g7 k3 @8 `! @' e; U; _* Z
                fast_io_fail_tmo       25
% ^9 L$ i8 O4 S                no_path_retry          queue
' Y% _  d5 x9 K! i0 M        }, F! s0 [- R. C) O" U% y/ T3 d
}
# O+ h6 r4 ]8 o& D; f5 ~
. U/ M# I$ M$ H0 B/ ^3.重启服务2 M; [2 y, L0 V6 ?! y1 D6 m+ Q# `
# systemctl reload multipathd
" P' H2 d  `8 J& Y2 }3 o
4 c. d7 W7 O, s: ?& Q. w+ w0 O; ?4.配置chap认证% c& z; C3 _& B8 _2 L2 }# K, H
修改配置客户端的名称为之前设置的名称. S/ H9 s, F- \2 N% C, Y2 a
# vi /etc/iscsi/initiatorname.iscsi
1 ~* a9 c) s% _8 R! Y& Z/ \) } InitiatorName= iqn.1994-05.com.redhat:rh7-client
" U- N/ d; J1 I1 l! k修改chap认证配置文件
, _2 f1 ^9 K. n: n # vi /etc/iscsi/iscsid.conf
7 X  \" Z! Q0 V8 P# n node.session.auth.authmethod = CHAP+ \+ f% Z# \% o7 o1 b6 B; q; M. K
node.session.auth.username = myiscsiusername
  C  H/ O( p6 ]. i/ `! M node.session.auth.password = myiscsipassword" E3 x7 U6 f9 \6 M1 c; X6 {1 M
2 v8 [$ j8 J# S  H. `" D
5.查询iscsi target7 ]" ~* k0 s( x" J
# iscsiadm -m discovery -t -st 10.172.19.21
  B8 o1 _3 r" N% t : n: ]3 ~# ^# o6 O
6.连接target3 Q  X; T: {1 \& U4 J% n
# iscsiadm -m node -T iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw -l1 u5 U# ~0 F+ a. m' H  m, ~
# multipath –ll
) }. I2 s0 b7 ~3 ?5 K
' G! {. p- W/ l) F8 g, Z. ]% q

1

主题

0

回帖

12

积分

管理员

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

配置yum文件ceph-iscsi

[root@ceph01 ~]# vi /etc/yum.repos.d/CentOS-Base.repo
) g6 p9 |! ^, y& o; l3 e

, z& e0 ?- W+ {[Storage]

$ c0 J: q4 }& P6 |
name=CentOS-$releasever - Storage: @3 p% L: K5 G, j  ?  f4 D
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64
/ceph-nautilus/
7 @* O3 e& v' ~& f9 ~( v0 S  L" C7 D: N
gpgcheck=0

5 Q7 T1 E  V7 P' J1 c! @
enabled=1
, l3 v; K& q) a
( @2 m1 S* N- k$ A0 I8 V
[Gluster]
6 W3 u! y* ~; q* L2 h# |
name=CentOS-$releasever - Storage" D7 ~9 S4 s: y  D4 j
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64/gluster-5
/
( A8 U5 y; B& b" c5 ]2 C  K) z
gpgcheck=0

" q" L9 t" q3 I2 H* V! y
enabled=1' l% G- _# V6 A( R8 u  `
. m9 L9 l& S( M1 a1 I
[ceph-iscsi]

  s% K. L2 O7 {5 K7 [2 s: G# h
name=CentOS-$releasever - Storage
0 e" B2 k- V( m- j- P1 A- e# s
baseurl=https://mirrors.huaweicloud.com/ceph/ceph-iscsi/3
/rpm/el7/noarch/' I7 P5 L" _0 X$ P
gpgcheck=0
  w" V8 V) F' g0 V! R6 G" Z+ i1 K
enabled=1& o' U# ]/ ]7 B! r( B) j& x5 K
. Y/ z% a% u$ x- B1 {1 s% t5 N
[epel]

6 B, L7 n" A8 T9 J" R: Z
name=CentOS-$releasever - Storage
5 j. C) O3 Q. e% I1 m8 o4 U. r
baseurl=https://mirrors.huaweicloud.com/epel/7Server/x86_64
/1 _9 k" P- C7 q/ o9 x  [  _# b
gpgcheck=0

5 s7 e! P; L4 w  l; g- A
enabled=1
9 ~* c( |0 i: c

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-7-10 21:37:05 | 显示全部楼层
直接yum install试试可以发现,只有targetcli和python-rtslib能装上,而且版本都比官网说的要低,好吧,麻烦来了。
4 C/ {4 J$ a0 x$ i
: m: e. ?% c8 z经过一段几个小时*的搜索……从下面链接中找到了rpm包:
% e( K3 ?- X- \0 D& x9 l) J' r
Build new RPM for 3.0
; `% Q7 k" Y, ^, R* X% u3 O" ?Missing ceph-iscsi-cli package
3 D5 h9 J( ^; N新建repo文件:& Z% R6 R6 x4 g5 D) P% U7 F& b

0 u  Q( _. d7 a# ]  m: M sudo vim /etc/yum.repo.d/iscsi.repo% D2 P( i3 C, v
cat /etc/yum.repo.d/iscsi.repo
/ `8 v) x4 {6 |7 F8 |' c2 ]3 Q: n6 K1 Q, ~7 F& K
[ceph-iscsi]3 L, Q( T9 V; v3 J: {/ Z6 m/ x
name=Ceph-iscsi
; R0 t$ x+ n( i" M  I! Fbaseurl=https://4.chacra.ceph.com/r/ceph-iscsi/master/88f3f67981c7da15448f140f711a1a8413d450b0/centos/7/flavors/default/noarch/
3 i! R; R. U( dpriority=1
& `% j3 e( u+ z) i* N, P& K& P6 vgpgcheck=0; q+ [0 `2 a( T& i. w; y: N5 m' ?
/ O- a/ s& Q' y3 B5 s( ~4 c
[tcmu-runner]( A  h& z3 D. p$ I" X' e" w: k0 F
name=tcmu-runner
  C" N5 I  g% X" A% J  [9 l2 T% qbaseurl=https://3.chacra.ceph.com/r/tcmu-runner/master/eef511565078fb4e2ed52caaff16e6c7e75ed6c3/centos/7/flavors/default/x86_64/( {2 p2 K0 i: l; e% |- w9 [
priority=19 l+ D! H" q) a: c
gpgcheck=0% B* D, k) [" l7 T1 I* Z

7 U0 ^. j- _/ O9 G: R0 P- l$ s  [[python-rtslib]
7 T$ x7 k& x" G$ p  z+ X- Z  K" @name=python-rtslib) V3 ?" l* z& M
baseurl=https://2.chacra.ceph.com/r/python-rtslib/master/67eb1605c697b6307d8083b2962f5170db13d306/centos/7/flavors/default/noarch/4 z, l% C" |7 u" ^
priority=1
5 l6 n$ g  x- I: J0 tgpgcheck=0, [0 J2 u" w- O2 _7 @
这里我使用的是本地源,将上面的包下载到本地源:
: F. h2 N- g( v4 o! |2 @! q% x% G0 x" ]3 G0 y
sudo yum install --downloadonly --downloaddir=yum/ceph-iscsi/ targetcli python-rtslib tcmu-runner ceph-iscsi
1 s: d) q+ C! Y. B9 U createrepo -p -d -o yum/ yum/
4 f7 Y# p# M& y$ ~9 B: J注意到这里没有包含targetcli的repo,因为没有找到,使用yum基础的Base源或者是Ceph源可以安装targetcli-2.1.fb46-7.el7.noarch.rpm, 虽然官网需要的是targetcli-2.1.fb47 or newer package,但在后续使用中发现没有影响,所以这里就不用管targetcli了。
7 T. ~& o& A  B, a% Q" x; n7 H
9 e- S% @' a' c/ R那么这里下载下来的就是:9 J! D6 Y( t* \8 m8 B5 b
; v& A4 D7 g* D( S$ o) C, X7 w
targetcli-2.1.fb46-7.el7.noarch.rpm% h; L% G! H& h& b5 [7 n/ Y
python-rtslib-2.1.fb68-1.noarch.rpm
5 Q- J+ ]; V5 }tcmu-runner-1.4.0-0.1.51.geef5115.el7.x86_64.rpm
1 G) {  q, y& n7 mceph-iscsi-3.2-8.g88f3f67.el7.noarch.rpm$ ^5 N2 l6 q4 d/ m4 {: g& g
ceph-iscsi网关初始配置
9 C9 y2 j5 m5 k& W如果使用的不是集群内的节点作为ceph-iscsi网关,那就需要进行一些初始的配置。
; }( |. D) ]" E% {+ Q1 X2 K( ~# L3 A2 u; b
安装ceph。- n3 h/ \7 h7 ^8 _
从集群中的一台机器上拷贝/etc/ceph/ceph.conf到本机的/etc/ceph/ceph.conf。: a1 w3 [7 r0 F
从集群中的一台机器上拷贝/etc/ceph/ceph.client.admin.keyring到本机的/etc/ceph/ceph.client.admin.keyring。
9 h0 C8 O! Y6 A' Q" W2 l当然第2和3步可以直接在deploy节点使用ceph-deploy admin {node-gateway},{node-gateway}就表示网关节点的名字。6 y5 V4 o3 m6 r6 l6 q/ ]& i

1 M+ H. d8 Z5 ?& M0 f( k: W$ \% |. M2 t可见这里就是为了将ceph-iscsi网关节点变成一个admin节点。. P. c0 w/ K1 F# e

/ Q' a4 r6 q( |5 Z% D, s这时在网关节点上应该可以执行相关命令操作ceph集群,例如sudo ceph -s查询当前集群的状态。
+ {  y( \! a6 j4 W: `# E% I# M" v  n1 O* z$ \2 E
安装配置iscsi7 f$ H- E5 x. ?! q. A
这里官网建议先切换到root用户,方便一点:5 ]- G, _8 q9 a' @; Y! N9 i1 t9 Y

0 p/ V) d+ D1 R9 n' h  d su root6 p" U2 Y1 k1 X" B. N7 K- f5 w
在两个网关节点上都安装iscsi(注意到上面已经将相关包下载到了本地源,所以可以直接yum安装):
3 j$ Z# E. ?' s' {, Y
) N  |; I( b+ T# c' Z' U7 C yum install -y ceph-iscsi! ~8 N( B3 g# I; j
服务启动:# G; I2 X" h8 e+ e

' w. ~) R# r! r. Z先创建rbd pool,如果没有的话。! l" g( S2 ?+ ?7 U& V& M
. ]( @. T6 e/ ?4 G7 |4 _
ceph osd lspools
- {: }+ T/ Q- g$ h
: \; m0 s" A/ H2 T1 cephfs_data
- r( p+ G/ f  }3 ?- O' D: F2 cephfs_metadata2 Y' K2 J/ @$ V. c, A. l

5 i4 B) M9 J; I' u ceph osd pool create rbd 128+ S. [9 ~, ~$ Y7 Q7 Z0 f' O
# w9 N5 d! j' a% N1 ?* m
pool 'rbd' created
; o) q- i. H  ~3 P- k3 ]# V创建并修改/etc/ceph/iscsi-gateway.cfg文件:
5 J5 y5 R3 Z2 t9 ?& \* {  p+ L0 r3 H# k: g0 g; r
vim /etc/ceph/iscsi-gateway.cfg
% C+ E4 _- N1 o. L( p$ T: K cat /etc/ceph/iscsi-gateway.cfg: ]4 i. Y8 e/ H# F: {
# G# t  z1 ~8 r3 Y8 ]
[config]
: C: F: ]( e  |# j+ x7 S' N Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
* R  q0 w: C! z+ W# Z; |6 T8 l access to the Ceph storage cluster from the gateway node is required, if not7 r" q1 Q. z- x; t
colocated on an OSD node.
. Y* P' x) A4 l/ hcluster_name = ceph
5 c, Q- ]  }0 w
4 x+ t1 ~( f% h3 h$ h7 e+ O Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
4 ~' |, z" x: Y  j drectory and reference the filename here. Z6 b6 C/ y# c
gateway_keyring = ceph.client.admin.keyring1 o& m1 t, Z: d
- i, B5 M5 N* G) y5 f" h

/ G* g. H" B2 Q& ]4 l) h/ E* | API settings.( l; ~4 L$ X: N
The API supports a number of options that allow you to tailor it to your
& d1 n4 U2 Z+ d2 j! M! R) |$ ? local environment. If you want to run the API under https, you will need to3 n8 V2 `: r! ?' s1 [+ ~$ T
create cert/key files that are compatible for each iSCSI gateway node, that is
- E( N* Y1 n! p+ ~+ \ not locked to a specific node. SSL cert and key files *must* be called
" |, R9 u, C5 I% P1 B; S* ]/ e 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory0 c6 d0 s5 _  R9 @$ q& i
on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'4 }7 w6 ~( E$ Q, B( H+ {1 Z( S+ ?
to switch to https mode.
/ j7 _. B1 V7 K" f
8 Y* E7 [: n5 a6 e" V0 [ To support the API, the bear minimum settings are:6 X# N! k, M/ K2 @) N
api_secure = false
9 @/ [/ I# k6 d- E7 F( p
3 ~2 h& s; S6 M1 O Additional API configuration options are as follows, defaults shown.. o5 z, z  d2 o6 t! {! d
api_user = admin
7 s" d4 y& Y! v: r+ h+ T( A/ C api_password = admin
9 i- F9 P! |9 P& T: D( J& g9 o api_port = 5001) w. |( Q8 J* a
trusted_ip_list = 192.168.90.234,192.168.90.235, o) G' h: |! q: h3 d
上面trusted_ip_list填写的就是两台网关的ip(这里不讨论多网卡的情况)。5 `' b6 \0 w/ d/ J$ F1 s

+ o# J4 B, a* l, G8 a& d  H; A在另外一台网关上复制这个文件:1 P) b$ x7 S; D2 I1 d, _; @
, b# [6 {1 `0 R
sudo scp cluster@node2:/etc/ceph/iscsi-gateway.cfg /etc/ceph/iscsi-gateway.cfg. l. n, P' w' s: N4 W- b! m4 x
在两台网关上都开启rbd-target-api服务:$ J9 a4 O% M0 N# N% h: L% {9 d9 p) R
9 M3 l1 ~4 c, @- w
systemctl daemon-reload; ~, o9 A; k0 B5 r9 j) |
systemctl enable rbd-target-api) b  _, C3 Z: Y+ @, X3 Q# m4 H: I
systemctl start rbd-target-api$ Y# m% D" \4 V8 D+ a# n
配置:(在其中一台网关配置就行)
, @0 @1 m( f5 s
. w& A; ^0 ^4 F& Q gwcli; \3 E+ {: O" Y* H- Y1 w
cd /iscsi-targets$ C0 N5 P% L% Z; _
1 Y  i' n; r2 q% S, Q0 t* e
create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
% D, p9 I* p4 l; o% y! a, k4 X/ T" Rok1 O+ s- H# d2 b1 @3 }0 m
7 T! B" |9 c' b1 E
cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
% }9 z6 U6 u2 W, d- C: V7 A. ]' y1 k
/iscsi-target...-igw/gateways> create node2 192.168.90.234+ z  g8 e. @2 h$ l
Adding gateway, sync'ing 0 disk(s) and 0 client(s)
9 B0 e- W% `4 Wok2 q/ d) \8 \& ^
% [0 e' E' ~. [0 a. V! u
/iscsi-target...-igw/gateways> create node3 192.168.90.235! n# r6 S8 O* }( [4 n. }
Adding gateway, sync'ing 0 disk(s) and 0 client(s), S) P4 T% q6 J. l" J
ok' U3 h, e1 ?5 i9 ~) C7 ~
8 b. b+ l) l: j% r: k$ q7 _
/iscsi-target...-igw/gateways> cd /disks
9 X/ F# F) C/ s/ X1 p
. F3 r1 |2 _) o! ]4 b0 c create pool=rbd image=disk_1 size=200G
0 P# t$ u1 N$ r, T$ T' eok" q* L6 x% L( G3 l+ t9 E

1 g' Y3 o9 a: ^" G' [- \ cd /iscsi-targets/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts+ W7 `; U! h/ r; P6 W1 s

, \4 k: e  o: ^0 C+ q: \# z* `/iscsi-target...csi-igw/hosts> create iqn.1994-05.com.redhat:rh7-client6 n  X9 i8 e' ^( p7 n4 u  D1 [2 x
ok
; M) W9 A8 _, o8 ^5 e. }+ e1 G4 }9 |7 q* X
/iscsi-target...at:rh7-client> auth username=myiscsiusername password=myiscsipassword2 P$ e% \! q9 s+ g( D# {. n* B/ m& a
ok
( p; |4 K" p: s0 E. d
) o1 Y( J+ J& z6 O- O/iscsi-target...at:rh7-client> disk add rbd/disk_1
, A  M' z' `" i8 u8 |' P( v8 yok3 H1 P8 Y+ s$ _% P
配置完成,可以看到我当前的目录结构:
; n6 m2 V, g. `# U- e$ @! ^2 V9 ?* f+ u  J3 c8 x
ls" E1 ]5 R  J9 m
o- / ......................................................................... [...]" H1 o- _5 j& K* L
  o- cluster ......................................................... [Clusters: 1]
/ u3 n3 b! Y; c, L& Y3 {  | o- ceph .......................................................... [HEALTH_WARN], T( g3 m* {9 O4 ^/ {+ e
  |   o- pools .......................................................... [Pools: 3]
' t8 V" ?% K% \; F7 h  |   | o- cephfs_data ... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 2029431878b]8 P4 [8 \* w, ^. s8 b
  |   | o- cephfs_metadata .... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 77834b]" z: l, u$ v/ r$ o! D
  |   | o- rbd ................ [(x3), Commit: 200G/2028052096K (10%), Used: 15352b]
( Z* f1 p1 F! n9 ?# C  |   o- topology ................................................ [OSDs: 6,MONs: 3]/ U. u: k5 w. W* s! c
  o- disks ........................................................ [200G, Disks: 1]
" I" |% C6 Y* ?5 o& X  | o- rbd ............................................................ [rbd (200G)]& n' p0 t9 k5 m, `% U* m5 U
  |   o- disk_1 ................................................ [rbd/disk_1 (200G)]
. Y/ S8 N: b$ e: \! N  o- iscsi-targets ............................... [DiscoveryAuth: None, Targets: 1]' C2 x6 u$ L$ V6 J& Z$ ~" J5 I: [
    o- iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw ..................... [Gateways: 2]
; u; G* C$ y* t% d      o- disks .......................................................... [Disks: 1]
5 R& S) S* {" A* X$ i; E6 `      | o- rbd/disk_1 ............................................... [Owner: node3]# O/ O8 _3 L) j3 T. _
      o- gateways ............................................ [Up: 2/2, Portals: 2]$ p6 t) z' {  p3 A
      | o- node2 ............................................. [192.168.90.234 (UP)]1 Z& {3 v) F( d- d* j1 K) }; \4 [
      | o- node3 ............................................. [192.168.90.235 (UP)]
7 x( t5 E! h5 D& Z0 U      o- host-groups .................................................. [Groups : 0]. Q5 o$ c& d: Y5 {8 y
      o- hosts .............................................. [Hosts: 1: Auth: CHAP]9 z& z7 }- i+ e* R* F; A; c& Q* ]
        o- iqn.1994-05.com.redhat:rh7-client .......... [Auth: CHAP, Disks: 1(200G)]
% b2 [5 H& M; e: b+ z% t; x4 C          o- lun 0 ................................ [rbd/disk_1(200G), Owner: node3]6 e2 E$ p; V) f+ k  Z
linux客户端配置( I2 c" Y9 u" ~9 e
在作为客户端的linux主机上。, }. o$ Y- J* Y
! j: l% Q. ~& b
安装相关组件:
7 U, N; n7 h; p% n0 ^. i3 Q, O8 S5 a+ E0 n
sudo yum install -y iscsi-initiator-utils% b, Z+ q" G, t8 e0 A7 d( x
sudo yum install -y device-mapper-multipath
. Y! q2 ^0 J  y% K" g$ Y开启multipathd服务并进行配置:+ x: x. q; r6 M# w, r

* W0 s. x6 S# \% |; p sudo mpathconf --enable --with_multipathd y
8 J  B( {( s! i3 S! N: ^9 U
- e- j$ R! e8 r8 Q2 @  y& r sudo vim /etc/multipath.conf
. y2 Q& A  z$ T2 O6 x sudo cat /etc/multipath.conf# @/ _5 a: O% g- y

; C8 c/ u) J& s) ^, }( k* wdevices {
/ [; U! p" e, J; N, A) ?        device {
: x8 e. L3 P3 l0 i: j: ]- }                vendor                 "LIO-ORG"
" D: R0 x" N' G  O4 A                hardware_handler       "1 alua"
. Z4 e  K2 H5 ]5 z                path_grouping_policy   "failover", R4 d1 }7 }2 M% S
                path_selector          "queue-length 0"
! s& J" b8 b9 h5 o3 Q- a                failback               60! c7 s/ x/ J5 f+ j* ]$ ]
                path_checker           tur4 q% A/ i; j5 C6 J0 i) U
                prio                   alua6 N! U; k7 n% a" }5 R
                prio_args              exclusive_pref_bit2 K: M2 Q+ E( O# l
                fast_io_fail_tmo       25
1 }8 |. f0 z! {! I' P                no_path_retry          queue
' s. [4 `) x* ?! K0 w, m( Q* b1 r        }
9 m! G1 L; i* V: ~}
6 h: G/ d9 P, J修改客户端名称:
0 n+ t% b" [+ n4 c& R* z" N5 L
+ ^  c$ e+ F; m  x7 c" b9 c sudo vim /etc/iscsi/initiatorname.iscsi
! X# Y5 E$ a) k7 w; L sudo cat /etc/iscsi/initiatorname.iscsi8 J8 H. o0 Y/ f- v  F
) v1 `  e8 }4 s) O$ q0 L  Z& N/ _( w- I
InitiatorName=iqn.1994-05.com.redhat:rh7-client0 O) G; Y2 D' P( b) q
修改chap认证配置文件:
0 P: H( r' v; n, L
6 O- C# H- p2 `( E* T' r  Q9 `2 E sudo vim /etc/iscsi/iscsid.conf
6 A" @& \5 E, k9 V% O+ x9 `5 X3 Y sudo cat /etc/iscsi/iscsid.conf0 N, C6 R; Z; V% c* D
" C, I! z# m2 A# e  F1 [# |
...1 i5 W4 ?* Q6 {0 j* Y
*************
9 v# k% {. k- g& t/ M# f3 q CHAP Settings4 a9 h! o+ t7 i  `) f7 k2 M
*************
7 y* d5 N* c6 {5 n6 q: a$ U) Y' d
To enable CHAP authentication set node.session.auth.authmethod
6 N$ Z+ E4 V3 a8 v7 S% ] to CHAP. The default is None.0 F$ s" b0 u1 S' m# z
node.session.auth.authmethod = CHAP7 K* I/ M# B2 U+ ]
. w' j; S. F5 T; f  W, x& m
To set a CHAP username and password for initiator
8 h8 D: o1 t9 A% T+ X authentication by the target(s), uncomment the following lines:  n, A5 R# x: E1 ?% ]
node.session.auth.username = myiscsiusername- \+ n6 ]3 }$ L3 Y& t- g7 I
node.session.auth.password = myiscsipassword: A4 F4 Q9 Q- q6 z, `; G
...
- q. c7 s3 t. k% m" B/ u
, s7 A' Q  o) K  t  m" \1 w发现target:
/ Y1 {) H( g. b# H, w+ y+ O6 K; N/ [3 Q* k! V9 F7 Y) T4 v
sudo iscsiadm -m discovery -t st -p 192.168.90.234
; p- l: D% ]6 f8 s- S3 d) y# c- l8 N2 u
192.168.90.234:3260,1 iqn.2003-01.org.linux-iscsi.rheln19 A& p+ [, P" m3 M$ G7 C; ^4 G
192.168.90.235:3260,2 iqn.2003-01.org.linux-iscsi.rheln11 z9 R& d0 x8 h4 M' I) Z
登入target:6 o7 d- x) U1 {* n' s
. g0 M1 ~5 n# ~; E! m
sudo iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rheln1 -l
( c' j4 J4 X, S. d& P4 v7 S, u8 i2 f查看是否成功:
2 f6 e  s( _% m1 |) j2 o( [" g8 r! v1 }1 G) N
sudo multipath -ll
+ B9 z- v- d) ?7 F0 X0 xmpatha (360014050fedd563975249adb2e84e978) dm-2 LIO-ORG ,TCMU device     5 ?3 g7 W3 b$ y" }
size=200G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
: A+ L0 {- N# K7 L& D' r6 ~|-+- policy='queue-length 0' prio=50 status=active
9 l9 b. l& G8 j1 F/ x5 o| `- 3:0:0:0 sdc 8:32 active ready running. y2 X& J& W4 L0 `3 ~! h6 U
`-+- policy='queue-length 0' prio=10 status=enabled( F* {) Z8 K* X6 x' `
  `- 2:0:0:0 sdb 8:16 active ready running2 C0 }1 }3 D* f# ^) ^
在fdisk中就可以直接看到这个“硬盘”:) Z1 s8 Y$ i; R

7 B/ X0 W1 m9 ?' |) Y7 }9 e/ o sudo fdisk -l( l. ?3 y. ?: Q2 M& z/ l9 Y, F
, G5 g9 I+ c, t; S2 H
...
, N0 t4 v3 d  |% \' U% kDisk /dev/mapper/mpatha: 10.7 GB, 10737418240 bytes, 20971520 sectors+ _' g* g8 a$ Z- P: w1 W% c
Units = sectors of 1 * 512 = 512 bytes
" v' @/ |, R6 f- C! ESector size (logical/physical): 512 bytes / 512 bytes5 N$ ]7 M0 p7 G- D& U, H3 K  |' v0 W
I/O size (minimum/optimal): 512 bytes / 524288 bytes
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 03:22 , Processed in 0.021365 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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