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

ceph luminous 提供iscsi服务

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-7-10 17:41:02 | 显示全部楼层 |阅读模式
开始安装之前必须要满足以下条件:
) Q) Y  i3 n; ]% O8 n正在运行的Ceph Luminous版本集群或更高版本的存储群集;(本文我们采用的是M版本)
7 J. T/ _6 h% A' w0 H& L+ hRHEL/CentOS 7.5或者Linux kernel v4.16或更新;
! ?; R* a1 z9 \4 Z0 T$ d* W1 Z同时拥有以下几个包:
7 N& h3 f4 P% I  M8 L9 x4 Atargetcli-2.1.fb47 or      newer package
! ^, p' P2 p- _2 k( R. p% D/ O5 mpython-rtslib-2.1.fb64 or      newer package3 I% D% K/ @) ~* i1 u5 u3 }, }
tcmu-runner-1.3.0 or      newer package
! }6 S, `" L( B6 F7 jceph-iscsi-config-2.4 or      newer package
3 ~8 g1 t% M4 k1 [. tceph-iscsi-cli-2.5 or      newer package
% ^; c# d! T' T" l; z  [注意:我们本次安装ISCSI GW是在OSD 节点上安装) T& K5 w2 Z! {% C% Y# x1 ~
由于很多童鞋可能获取不到rpm包,所以我这里整理了一下所需要的rpm并且分享了出来,以下是链接9 Y. u# A+ t% s- |
链接: https://pan.baidu.com/s/1piNymp6oWLNHvXKaxBszLg 密码: 4vag
; [8 [0 v/ r7 @9 W7 \2 p  ]7 ~安装部分就不说了只要把rpm包下载到本地,安装很简单,下面来说下配置部分:6 W1 q( U! J0 N4 H, A" ?, p( q
首先创建一个iscsi gw的配置文件
  @" {6 }! u; P3 k, [# touch /etc/ceph/iscsi-gateway.cfg
/ I$ R. R" c+ Y$ ^* m1 E里面内容如下:
  z8 D  r0 K4 @+ ?[config]$ I+ W8 |5 P3 Q" [( a
# Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
2 E8 Q/ z& X% t5 x. H# access to the Ceph storage cluster from the gateway node is required, if not
9 E, L5 E; d/ @1 t# colocated on an OSD node.
) p5 A) g7 P, l$ @6 scluster_name = ceph
0 V: ?% m* {! q* S6 B$ m
$ ]8 @" A; A1 @( V* k1 v# Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph! R' o1 Q- N, U( a  x
# drectory and reference the filename here
; L5 ~% m. `" ggateway_keyring = ceph.client.admin.keyring
' Z8 V/ b) u9 D& N8 W; y . \; u5 p& M5 E' C% ]6 K
' J8 h& {; S* {, r9 Y6 l3 W; t
# API settings.
$ i# T; v7 l( u, |  z- l  E4 ^) ~# The API supports a number of options that allow you to tailor it to your3 v. A4 ]; r* e$ L; L3 }
# local environment. If you want to run the API under https, you will need to
3 ?2 E: N8 o( R# P1 M  A# create cert/key files that are compatible for each iSCSI gateway node, that is% h: b9 w6 `* D% {. {
# not locked to a specific node. SSL cert and key files *must* be called
4 b! z# N& f# z! P: [9 W' I# 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory9 v7 z9 s0 ?4 U1 C  J- [
# on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
: ^2 p1 H0 K3 r# to switch to https mode." @+ D3 {8 D4 o) Q4 j6 Q( D) q- V2 t1 s

- U+ Y- P! D# _# To support the API, the bear minimum settings are:
- P7 @$ D! E3 ~# ], g  W( Sapi_secure = false
0 O2 @6 q# U/ O" l, w# w ; h3 r% V) k( U' h$ `
# Additional API configuration options are as follows, defaults shown.) ]2 H. f1 I: _+ Z
# api_user = admin+ F6 E6 P- j7 ^/ T( h' R$ S, P& e
# api_password = admin
) T5 f+ P) U4 r# [) ?# api_port = 5001
7 D- u! v, T: p9 P$ x# trusted_ip_list = 192.168.0.10,192.168.0.11- s- E% F' @3 J, P) B0 C; x
注意:需要修改的地方就行把trusted_ip_list替换成自己实际场景的节点ip9 X: x! V6 C/ ]# s: c. p/ V4 p
完事之后重启iscsi服务) R! s# J4 s% c5 P
# systemctl daemon-reload
/ D" I9 u, w! ^6 K# systemctl enable rbd-target-api
/ m, a1 {: X" @# systemctl start rbd-target-api, m, v6 C. j( Q, x3 K0 W6 c
OK到此为止,iscsi gw已经安装配置完成,下面开始创建iscsi target# ?; X% e0 [7 ?7 [7 X2 Q

  b( a/ i6 }- I# T; Q" U" J1.执行gwcli命令进入iscsi9 n7 v; S$ h% n" Y4 S

5 ^- N. B, R4 ]/ E$ G' F2 E2.创建iscsi target( _7 b% x4 Q9 B3 a; d9 L' Z; I' C& }
> /> cd /iscsi-target
; @# \, \2 T0 }. J9 |2 d% G> /iscsi-target>  create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw! D, H0 C- l# i3 g# z  B

' H% d( D# ~1 n3.创建iSCSI网关。以下使用的IP是用于iSCSI数据传输的IP,它们可以与trusted_ip_list中列出的用于管理操作的IP相同,也可以不同,看有没有做多网卡分离
* |5 p; X# ]" w" t  m> /iscsi-target> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
) ]+ }4 B3 r3 J0 j  F) _* A' e: b> /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21 skipchecks=true
6 ^( R" k: p; I$ \/ K> /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22 skipchecks=true1 [  r9 C6 o! Y5 H% K
) c9 O0 M5 \$ {' o7 F4 D3 Z) {$ p
4.创建一个rbd设备disk_1
- C' V3 l5 P* I) K+ d9 y+ D> /iscsi-target...-igw/gateways> cd /disks
5 i1 k# x5 O% ?- r> /disks> create pool=rbd image=disk_1 size=90G
9 U4 A0 Q: O8 a  a( o+ Y 3 C: g( X/ u, u1 a
5.创建iqn
0 L' I; T# b7 \4 n) ]8 E* o% i" U; ~> /disks> cd /iscsi-target/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts
. _! Z+ V% y% `) p, ~+ f0 J* C/ Q> /iscsi-target...eph-igw/hosts>  create iqn.1994-05.com.redhat:rh7-client& z: {- Y& [1 {
0 a; i/ x9 ]7 L. @& b( V9 U
6.创建chap的用户名密码,并且chap必须设置,否则服务端是禁止连接的
) i( S% F0 m) e! W> /iscsi-target...at:rh7-client>  auth chap=myiscsiusername/myiscsipassword' u- }9 n9 d* l; t  e5 ~$ f6 {5 U
- ]" H; p  o5 Z; K5 ]
7.增加磁盘到客户端0 `7 k" E# B& R; i$ {+ `( q
> /iscsi-target...at:rh7-client> disk add rbd.disk_1
: O/ P. D9 _7 y/ A) q' w5 {2 N 1 N  N3 ~- y  O
OK,到这里就配置完成了,我们看下最终是什么样的
, k( L2 b8 T2 u) D/ O7 D2 Hiscsi.png, X, [6 O6 b& D( a8 _/ W1 o, d
) q5 q1 e. ]7 w1 z2 |* z) t% k
安装配置完之后就可以挂载使用了,一般也就是windows/Linux,我们先说下Linux下挂载方式' @( W2 j# ]6 }
4 S, @7 s$ Y: ]3 D2 Z, i2 ]
1.安装iscsi工具+ s+ `% y( e4 @# J
# yum install iscsi-initiator-utils
& k$ d! p$ f0 Z9 B# g2 H1 J5 f. z8 h# yum install device-mapper-multipath
( [- A; a' J1 e + d/ H  l/ R# j6 d$ }# H
2.配置多路径
- V, @9 P1 ?) c  [, P6 |7 c# mpathconf --enable --with_multipathd y% M" |- ?3 V& _4 I
devices {; H0 f# U1 {) X8 F( e
        device {
% F8 \# `0 I, ~# W/ C' c                vendor                 "LIO-ORG"4 _5 c; c9 h/ n& G; d1 V$ B
                hardware_handler       "1 alua"3 _! d, y( V  f8 [% H5 v
                path_grouping_policy   "failover"1 S# r, l. e. A+ e. M
                path_selector          "queue-length 0"; K: H, _$ r+ p3 z
                failback               60
) C7 x) R. `5 X* d                path_checker           tur/ y% k; y& v+ \0 K" ^% V
                prio                   alua
; z# N9 m& H. Z* a' r, e+ c                prio_args              exclusive_pref_bit
7 e! ~# q# [. p) @! o                fast_io_fail_tmo       25
, S4 n/ S& ~( {/ V' d                no_path_retry          queue
3 M- Y/ ^( x3 u& F+ V8 z        }
6 {* [- b# f1 q% O}
( o1 Y4 ^* h0 H% |
; \7 \& U  k8 ?, R3.重启服务. |1 `+ ^- i) G! u% F# w. Z
# systemctl reload multipathd
* n  E: R: I" R 1 h% ]6 g5 p) P8 M) I
4.配置chap认证
- d% S9 u6 N" N8 g修改配置客户端的名称为之前设置的名称9 h8 P5 o/ g4 V6 c: r: u1 B1 d  s
# vi /etc/iscsi/initiatorname.iscsi * K6 [5 ~" s# T2 M
InitiatorName= iqn.1994-05.com.redhat:rh7-client
7 d  A8 J6 N# v* v5 `修改chap认证配置文件! r' K& M4 u! k6 q. K# Z, J
# vi /etc/iscsi/iscsid.conf
* s+ k+ l, B& }0 l# L2 [0 [ node.session.auth.authmethod = CHAP+ p! Y2 \" |; W3 n  j6 r6 w
node.session.auth.username = myiscsiusername) q( H; B* J3 [2 U  r0 o
node.session.auth.password = myiscsipassword" i0 @! j7 Y) g( Q

6 `) e$ v, H: w) C; n# B, Y5.查询iscsi target
" J6 a8 ?( k! Z' \8 V) |( o9 y# iscsiadm -m discovery -t -st 10.172.19.21! i# _( j) M; H7 @  o

, G% U) j/ l+ G5 z% _" ^6.连接target  K3 S; a6 A1 V7 a; [5 f' Y
# iscsiadm -m node -T iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw -l( W/ m0 s8 C5 f  G0 l9 X1 o+ H
# multipath –ll' `$ L, |( e- N  a& ~. o

# \+ q- j) s: V" ^" g

1

主题

0

回帖

12

积分

管理员

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

配置yum文件ceph-iscsi

[root@ceph01 ~]# vi /etc/yum.repos.d/CentOS-Base.repo % _( L1 z! F0 b' D% l
7 c$ ^# L* @( U
[Storage]
" G( o9 O4 A! U  R; ]$ [
name=CentOS-$releasever - Storage
) L. a3 c' W  Y6 W$ P
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64
/ceph-nautilus/
$ `( p+ \+ q8 I' f) l( x
gpgcheck=0

! Q% }. r. \5 H, p8 _  {
enabled=1% q4 F; P- q; v7 }) h) t8 c
+ `/ z8 E8 @+ K( }  A: I
[Gluster]

+ \( y3 s/ ~( a1 o
name=CentOS-$releasever - Storage
0 {6 u- Y$ O- z5 m, c+ P
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64/gluster-5
// t0 h+ y7 v% M3 z
gpgcheck=0

0 M' L# e' W- R
enabled=1
& j6 I- m3 _7 y( A- {! I( Z& i

5 F4 W& I4 @2 E+ |- R  m[ceph-iscsi]
3 E" o* E3 {3 q% E
name=CentOS-$releasever - Storage. O# G6 h9 k  o' G4 c+ g% C
baseurl=https://mirrors.huaweicloud.com/ceph/ceph-iscsi/3
/rpm/el7/noarch/
5 g0 @/ o6 Z" _, ?
gpgcheck=0

& P  C: V2 E( A; |/ O
enabled=18 Z. P# f# p$ H" K- a' g- M5 y% z
; l4 ^* p) O- F+ z
[epel]

7 X' ^. S' U7 X; l5 y
name=CentOS-$releasever - Storage/ M* Y. R4 w4 l
baseurl=https://mirrors.huaweicloud.com/epel/7Server/x86_64
/1 C; \' `6 ^5 v; M
gpgcheck=0

! p) O8 y* z' |* B/ G
enabled=1
/ V( M" g2 a. l* U' C/ ^% U% e( L* s

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-7-10 21:37:05 | 显示全部楼层
直接yum install试试可以发现,只有targetcli和python-rtslib能装上,而且版本都比官网说的要低,好吧,麻烦来了。
+ j6 m0 ^* V0 c9 f( Q  L+ i0 Z  x2 P: k$ B
2 D9 Y: [, k2 q' T/ X经过一段几个小时*的搜索……从下面链接中找到了rpm包:$ M7 ]  Q0 v7 {8 _6 K

. G8 g( I& ^6 B+ [Build new RPM for 3.09 l. z8 Q5 H- k3 C7 [7 q
Missing ceph-iscsi-cli package
5 \3 Z! N$ `$ Z# ~  C新建repo文件:
) m5 o, v; R# j! s" o+ F5 L4 k7 z! H8 i( n" q
sudo vim /etc/yum.repo.d/iscsi.repo( s1 ]  {# X- A! Q* {" d; l. P
cat /etc/yum.repo.d/iscsi.repo9 O5 c  y- z7 e

9 X! R& p, E6 H; E8 }$ H8 y[ceph-iscsi]
0 p1 v4 i$ [9 d7 Qname=Ceph-iscsi
4 V) V1 ^. Z% `* \" v8 \: w9 Abaseurl=https://4.chacra.ceph.com/r/ceph-iscsi/master/88f3f67981c7da15448f140f711a1a8413d450b0/centos/7/flavors/default/noarch/6 N! Y  o1 k2 B, r3 j' n
priority=1$ Y7 |2 d! i1 B) u. }5 O! `
gpgcheck=0
$ z( s) o8 n" R9 b) U% m
, G1 N$ [2 R" \8 N+ R- G, n[tcmu-runner]
7 \5 r/ i+ c" @9 b. ]" M, X1 Cname=tcmu-runner
! Z. d0 A' w" U. o8 @- y3 |+ \baseurl=https://3.chacra.ceph.com/r/tcmu-runner/master/eef511565078fb4e2ed52caaff16e6c7e75ed6c3/centos/7/flavors/default/x86_64/
' k* y1 ?- \$ A1 Q; `5 {' ppriority=1  x! Y: x& E/ X; W
gpgcheck=0! I- g5 u! m* I6 i& U2 u3 ?
0 g/ T/ Z2 c! |. i5 U
[python-rtslib]# @# e" k; r( H0 Z
name=python-rtslib4 t" M. h! Y5 A% \6 ^; T
baseurl=https://2.chacra.ceph.com/r/python-rtslib/master/67eb1605c697b6307d8083b2962f5170db13d306/centos/7/flavors/default/noarch/
5 A3 Z4 `5 _: i( U" A* `priority=18 m- _1 U5 S. C0 P
gpgcheck=0/ u1 m7 J/ G. w# ^- F% ~) a
这里我使用的是本地源,将上面的包下载到本地源:
4 R/ y2 K1 \9 W$ s) E& H2 y
9 m0 i5 {. }- Z6 q% H3 q5 J& ^ sudo yum install --downloadonly --downloaddir=yum/ceph-iscsi/ targetcli python-rtslib tcmu-runner ceph-iscsi+ ~# X% h; n  t+ V& l# I
createrepo -p -d -o yum/ yum/  F# r6 J$ X0 o7 a
注意到这里没有包含targetcli的repo,因为没有找到,使用yum基础的Base源或者是Ceph源可以安装targetcli-2.1.fb46-7.el7.noarch.rpm, 虽然官网需要的是targetcli-2.1.fb47 or newer package,但在后续使用中发现没有影响,所以这里就不用管targetcli了。
! x3 t9 |  m3 f) A, _
+ P! S" c1 @4 o) u那么这里下载下来的就是:# y4 ^9 ~: Y4 K$ c
. |; k4 P5 B4 U! c( d, h, A
targetcli-2.1.fb46-7.el7.noarch.rpm
) p% w, Q8 u0 ^python-rtslib-2.1.fb68-1.noarch.rpm
9 W6 d0 x9 C2 y& V7 ^7 Q) Dtcmu-runner-1.4.0-0.1.51.geef5115.el7.x86_64.rpm1 D9 o; R0 f5 r0 K1 Y! N
ceph-iscsi-3.2-8.g88f3f67.el7.noarch.rpm6 u# b: [; R" h) W2 {
ceph-iscsi网关初始配置& w2 C4 Y' U# M  Z# d
如果使用的不是集群内的节点作为ceph-iscsi网关,那就需要进行一些初始的配置。
3 s* X0 U, ^2 s2 ^% E
3 s, O$ l" P9 ]. s2 s3 v4 }5 N安装ceph。! @! o* M3 `8 g; u+ F7 }4 [
从集群中的一台机器上拷贝/etc/ceph/ceph.conf到本机的/etc/ceph/ceph.conf。; d+ X2 Z% ]4 q, h  X8 T
从集群中的一台机器上拷贝/etc/ceph/ceph.client.admin.keyring到本机的/etc/ceph/ceph.client.admin.keyring。
, N* X" R5 z: P- _7 q+ t当然第2和3步可以直接在deploy节点使用ceph-deploy admin {node-gateway},{node-gateway}就表示网关节点的名字。
7 ?1 d: Q+ A, P. d5 d; {% [+ C4 b( _. u! B! V
可见这里就是为了将ceph-iscsi网关节点变成一个admin节点。
7 L( @; h1 `4 V) P- l$ e/ w
% T/ c! V2 Y- V9 ^# N这时在网关节点上应该可以执行相关命令操作ceph集群,例如sudo ceph -s查询当前集群的状态。9 h1 b# z! Y! w& E4 s

+ I+ Y, q0 q% ~! \3 |  R# q+ Z安装配置iscsi- L: l0 ~( j3 d& }2 j; }% x, [
这里官网建议先切换到root用户,方便一点:  `4 K  L& ?9 N" q8 p3 T' e- R5 b
9 Y9 D5 H- _6 U2 w* d! F+ S
su root5 [, m, P: U# c+ Z4 G" z6 O
在两个网关节点上都安装iscsi(注意到上面已经将相关包下载到了本地源,所以可以直接yum安装):
" b; _" {* L$ L6 z9 b1 e! T% _: b+ m+ v, y; P. Q: z( [* }. e
yum install -y ceph-iscsi( H9 B0 D6 h7 E# w
服务启动:3 F, }. z! `% \  x2 ~

5 r5 b  v( W; L$ s; J& L先创建rbd pool,如果没有的话。
' f2 n' ?8 P, `; Z
( A0 o, t* G# X3 \3 C: X5 j0 l ceph osd lspools! S2 m1 `: T$ L( e* v8 H7 L
8 @4 p+ M4 |. N) C( t
1 cephfs_data
. q+ _5 q7 B1 ]7 ?2 cephfs_metadata% x0 P) t& }) [: b' E3 `1 Y

" M5 {7 N, {3 A* F7 h ceph osd pool create rbd 128
5 {0 t% L7 Y' i3 D9 ]9 {- y, a
3 \) @2 z# l6 n" T% J( }pool 'rbd' created
' t  Z/ J# u7 v- ?  G创建并修改/etc/ceph/iscsi-gateway.cfg文件:) P7 M4 C+ l* I0 [

$ |, M4 E! j. _ vim /etc/ceph/iscsi-gateway.cfg5 Y' e7 M2 E4 ?" n# {7 Z) j3 I
cat /etc/ceph/iscsi-gateway.cfg2 `' g% ?, s/ J* `" m0 g9 r5 d

9 r* i! m# P; @[config]2 f4 Y* ~1 R; K) N* l
Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
% ?" E: U# `4 X) }! k' Y access to the Ceph storage cluster from the gateway node is required, if not8 X, D: q9 C  H5 J' ~
colocated on an OSD node." {. f$ ^& Z' o" S$ k# I
cluster_name = ceph5 i5 |* _9 ?! c0 Q; ^) N
( ~! |& y1 b# s1 q
Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
6 M4 I9 E* N% ]# \# \6 r) \1 N drectory and reference the filename here
8 j) s  X: y4 Z2 n. bgateway_keyring = ceph.client.admin.keyring) v0 Z8 R- h; N5 }. y3 v% q/ a
! {$ Q  w& O1 s9 v' f/ f" p0 a6 i

$ z  w/ K# n. ~" u; Q* U) ?. I API settings.6 b% D' |+ ?, Q$ i+ [7 g* P5 V
The API supports a number of options that allow you to tailor it to your
# p$ I, }/ Y. ]3 h& }  I0 W3 A" B local environment. If you want to run the API under https, you will need to6 d3 b0 |# S: r9 A0 x/ |" d
create cert/key files that are compatible for each iSCSI gateway node, that is+ Q/ U& p  B5 s1 m2 J. N+ e" i
not locked to a specific node. SSL cert and key files *must* be called
4 {& S# T! B. G- r/ [/ e 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory
7 z- P/ k# [4 b6 T$ H+ W; m) c on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
  L$ w# F* u% T to switch to https mode.2 k: P% ^) |. h, K6 [2 i
5 C+ y; R: K4 \9 y2 M3 r0 G8 P2 s
To support the API, the bear minimum settings are:
& H/ C( }* A; Y/ {$ Q' o/ wapi_secure = false  _' K! [7 B# D
: e% Q# U+ g' E- G6 [
Additional API configuration options are as follows, defaults shown.
, Y& b( o3 Z* | api_user = admin+ V; y' ?. U- a$ d: [0 b
api_password = admin
; B8 y6 H' y% h- G api_port = 5001( T1 V' b* X5 ^5 b* ?; D+ m4 I
trusted_ip_list = 192.168.90.234,192.168.90.235
9 U* ^$ t( w# f( x& d# E上面trusted_ip_list填写的就是两台网关的ip(这里不讨论多网卡的情况)。# L) ?* ?- J2 ]# J" \

6 n2 q! E+ Y3 v" e+ }2 V在另外一台网关上复制这个文件:! A! y* c9 Z& ?
  r2 J. Z: v. Z! i# D
sudo scp cluster@node2:/etc/ceph/iscsi-gateway.cfg /etc/ceph/iscsi-gateway.cfg! e) N: n- s# y# n
在两台网关上都开启rbd-target-api服务:
% s; J9 a( U0 O  `$ F/ P5 ~" f3 T
systemctl daemon-reload
7 C8 c8 E& u0 M5 s3 I systemctl enable rbd-target-api5 g: f2 K& M6 m" e" x9 M; S
systemctl start rbd-target-api5 |7 G" w5 K- F! e0 D3 w! T
配置:(在其中一台网关配置就行)) G' S3 P5 O( i5 o
4 A6 p' ?- w" Q" Q" Q
gwcli
; O' f. n2 u; h1 e cd /iscsi-targets" U7 U1 `; t1 v4 R  U

/ m7 s/ k: f/ r# ` create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
8 m4 p2 ?9 }$ d* T0 [ok
6 F; |! _# D2 \- e) [- Z( K3 E0 H6 L1 o0 h5 e+ }. J( X
cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
0 r3 T* M/ `9 W" j7 v9 q& V' g- b; t9 @8 t
/iscsi-target...-igw/gateways> create node2 192.168.90.234+ L0 T5 |( [; g% w2 C9 a. y* a9 \
Adding gateway, sync'ing 0 disk(s) and 0 client(s)0 K# Q- p1 v! @- D% n! h" J2 z
ok" _, {2 z" \1 ^

- N, ~9 s/ |- y# a7 [& T! m3 n- P/iscsi-target...-igw/gateways> create node3 192.168.90.235- K" P* K5 e, D; x2 K
Adding gateway, sync'ing 0 disk(s) and 0 client(s)
( v9 x: Q+ ?; F, E7 kok& }; U& n1 F6 `% W

" ]% b1 f: l4 W5 d5 p/iscsi-target...-igw/gateways> cd /disks4 u4 y( @7 U. x8 Y

- i: c8 e6 q: j; ` create pool=rbd image=disk_1 size=200G* u; ]. Z$ K: j; N' s" o
ok
& c+ N  X! \( J* M1 k2 S2 `- R6 ]. ~$ _$ _) e8 T
cd /iscsi-targets/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts& C  }- l' x6 }5 e0 e( S

/ J# P  G: r/ t! X# w; W& u/iscsi-target...csi-igw/hosts> create iqn.1994-05.com.redhat:rh7-client" \) E  b: D, ~+ z
ok5 W) \( n( }1 D
6 b/ {5 I7 }% X- T0 H
/iscsi-target...at:rh7-client> auth username=myiscsiusername password=myiscsipassword
1 l, g5 I& m8 [( k/ y! sok3 l" u+ F! }4 e( p; [" m
8 `7 `+ I( S) c
/iscsi-target...at:rh7-client> disk add rbd/disk_12 X4 C2 g* [- z: b/ p* f
ok. N8 T* s: Y1 R& [4 u" N% t
配置完成,可以看到我当前的目录结构:, K  T, W( ?7 c( R

8 N' h5 t, J* i0 T ls
  w, d8 a0 F' d( q5 vo- / ......................................................................... [...]: W8 r- w1 C8 y* M
  o- cluster ......................................................... [Clusters: 1]
4 j% v4 L  y$ D4 y  | o- ceph .......................................................... [HEALTH_WARN]
$ k+ K8 I* n% C8 F$ b  |   o- pools .......................................................... [Pools: 3]
7 R1 C' ~( q3 `5 v2 R9 j8 B  |   | o- cephfs_data ... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 2029431878b]
. D+ J" W& G' L+ Q* h' m. W7 c  |   | o- cephfs_metadata .... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 77834b]3 P! ]5 a: N* D0 |% y- S4 Y
  |   | o- rbd ................ [(x3), Commit: 200G/2028052096K (10%), Used: 15352b]9 f/ x- y/ }7 F* t1 {
  |   o- topology ................................................ [OSDs: 6,MONs: 3]
6 W7 B% U! E( F0 m  o- disks ........................................................ [200G, Disks: 1]! \( h' x4 z* j
  | o- rbd ............................................................ [rbd (200G)]$ }! r# K! b! @: i. _
  |   o- disk_1 ................................................ [rbd/disk_1 (200G)]
6 r* }& u3 u5 t  h! V7 L0 z  o- iscsi-targets ............................... [DiscoveryAuth: None, Targets: 1]$ i; \! g9 i& e6 J( x  S8 |
    o- iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw ..................... [Gateways: 2]
5 G2 I$ j1 ?$ v, p* |0 ?5 M$ X      o- disks .......................................................... [Disks: 1]
3 m, l) B; y  S5 x( y, @; J) S+ g# u# F      | o- rbd/disk_1 ............................................... [Owner: node3]
8 g; S+ E$ R, M0 m' \4 J6 n; a      o- gateways ............................................ [Up: 2/2, Portals: 2]
, t4 `) U' D* O4 J. V7 _      | o- node2 ............................................. [192.168.90.234 (UP)]
$ D2 G7 g' y' B/ {- M/ y( |9 }      | o- node3 ............................................. [192.168.90.235 (UP)]7 h$ _# z. L; a& y$ p
      o- host-groups .................................................. [Groups : 0]. E9 M4 S9 i9 b/ u# Z
      o- hosts .............................................. [Hosts: 1: Auth: CHAP]/ x  O4 K& t, [3 N  V( g
        o- iqn.1994-05.com.redhat:rh7-client .......... [Auth: CHAP, Disks: 1(200G)]% R8 z* w( F% G5 \
          o- lun 0 ................................ [rbd/disk_1(200G), Owner: node3]
4 _# f" J1 W% n! v- dlinux客户端配置2 }& l' V" c2 ~% w
在作为客户端的linux主机上。: h9 i8 y3 n4 L! |$ M+ _

% n6 c0 a' z$ W2 ?安装相关组件:
5 D, R; V& S+ v% [( A) t+ h# D$ X# e, h; S, T0 Q: J6 f! E
sudo yum install -y iscsi-initiator-utils% R  [& F3 ?% P8 Z5 N
sudo yum install -y device-mapper-multipath0 V5 M1 D  ^8 [9 Z/ O4 ~1 p
开启multipathd服务并进行配置:% c1 C6 I" O8 A& g6 e/ i" _. e6 E
! O9 b' L5 x* }8 Z7 ^8 w
sudo mpathconf --enable --with_multipathd y/ C* l8 m5 y/ Z) e. B5 F

/ @2 ^  l2 I# N7 G sudo vim /etc/multipath.conf
  }; s2 v, a. A& X sudo cat /etc/multipath.conf1 ~# i% c* f* O$ ~4 C" f) S! A

/ [' Q' _# A$ a, xdevices {
1 n5 V3 q( L* F! |$ b; z        device {& x$ V& u. A% M' [, q3 r
                vendor                 "LIO-ORG"9 x3 _) E' S) _9 f& C
                hardware_handler       "1 alua"
6 ]! ~' w$ ^" k0 u* c                path_grouping_policy   "failover"
8 W$ g  i* j1 ~                path_selector          "queue-length 0"
3 _; ]0 m# H& a$ r                failback               607 W  _; a* q% [
                path_checker           tur- f9 \; d; t5 c$ N5 }
                prio                   alua* T9 E- g5 z0 P/ z5 D0 t5 L6 B
                prio_args              exclusive_pref_bit
% T5 I$ p( e3 H8 ?$ `* `, r8 i. N                fast_io_fail_tmo       25
, J1 B# \8 c; q/ `/ W! w- A                no_path_retry          queue7 z) R! _+ u8 {) r- {
        }/ e! L  h: p+ n
}" n' M# z9 ~. P" L' b0 M
修改客户端名称:
$ |9 L) C3 z' J( _
& W7 K. l% x& x' T sudo vim /etc/iscsi/initiatorname.iscsi, }; N+ ?" d8 H% F% r: a* f
sudo cat /etc/iscsi/initiatorname.iscsi: Q. `4 [) ]& t  p' M% M

6 I- f4 s) e3 x( OInitiatorName=iqn.1994-05.com.redhat:rh7-client
0 Q2 H* `! D8 p8 ]- k& p8 X修改chap认证配置文件:
. r( }3 z4 g( P) M& U  ?
  ~4 Y8 c1 x1 x5 }- }$ n% r: n sudo vim /etc/iscsi/iscsid.conf$ r4 D) [- m* w" s
sudo cat /etc/iscsi/iscsid.conf: d% w; t' p( t
7 X. `- W( Y4 A4 j* k/ A( H
..., i! b0 K! }: o8 p
*************! Y" B( v. S2 j/ _+ L
CHAP Settings
$ q; H+ A8 s7 u2 Y9 M *************9 ^3 q6 M6 u% e; ^

, W5 V% D( c8 w  i  O2 W& V0 [% n8 K To enable CHAP authentication set node.session.auth.authmethod
* ~/ F! s4 U8 @, ] to CHAP. The default is None.8 \! ?4 U4 c8 J8 Q. d. `
node.session.auth.authmethod = CHAP' l/ ^8 m- z! ]) |: g
& P5 o/ \, F* H3 J7 g; t1 n2 ^% F0 o
To set a CHAP username and password for initiator/ O, V, O1 Y, W8 g) C& }5 f
authentication by the target(s), uncomment the following lines:( _: O4 Y9 h9 \
node.session.auth.username = myiscsiusername6 |& z, |& j8 S( L
node.session.auth.password = myiscsipassword3 ?: G. z. c$ E( s  s2 Y
...- l& {) ~* C( o0 U2 {

. Z0 L9 d# u7 m$ \- ?* b( P& P+ J发现target:. e$ S5 k/ _. A, K, E
) ?; W: y% C1 g& N  Z6 r* n
sudo iscsiadm -m discovery -t st -p 192.168.90.234
% d- p) h0 S: U" h7 _6 R4 J
+ i, W( f* r6 O* y. A* Q7 E192.168.90.234:3260,1 iqn.2003-01.org.linux-iscsi.rheln1( j( L+ p) P! G# I( o
192.168.90.235:3260,2 iqn.2003-01.org.linux-iscsi.rheln1& u, U  ~! x+ ^& A& X% z
登入target:
) S5 ~: ]; e: f- x5 ?" E( o+ h8 [' v4 w+ F+ K; ~- P
sudo iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rheln1 -l
8 y9 a: u) V. K# \) I: `8 }查看是否成功:
( P0 y& d7 i; l1 y  u
# t+ y2 J& A5 G) z sudo multipath -ll8 F7 O4 ]  M5 @8 b
mpatha (360014050fedd563975249adb2e84e978) dm-2 LIO-ORG ,TCMU device     
8 w# l+ }! q$ Y8 j- g- [size=200G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
/ q: f) x+ c1 B4 x1 P|-+- policy='queue-length 0' prio=50 status=active5 {* t; C* T1 {' W, T% |
| `- 3:0:0:0 sdc 8:32 active ready running0 q5 w2 c! M; V! Y
`-+- policy='queue-length 0' prio=10 status=enabled. l. n3 K1 Y) L9 W+ m% r8 h& H
  `- 2:0:0:0 sdb 8:16 active ready running7 R" R+ d# H. i! R% l
在fdisk中就可以直接看到这个“硬盘”:
9 f$ k! T. V# B: ?. K9 i: ]4 t, F9 V" X7 d6 B3 _
sudo fdisk -l
, t8 Y/ U1 g4 N' i& Z2 {  S
3 g5 d4 b6 k7 X* d1 U4 {...
5 [$ [2 M$ B8 J. fDisk /dev/mapper/mpatha: 10.7 GB, 10737418240 bytes, 20971520 sectors
* o. e* {6 c: z8 v! y0 h  |Units = sectors of 1 * 512 = 512 bytes: A: T9 }( I8 v& M- R+ N" D3 a4 q" ?
Sector size (logical/physical): 512 bytes / 512 bytes0 ?# B9 |8 h& ~3 g/ s% r3 n
I/O size (minimum/optimal): 512 bytes / 524288 bytes
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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