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

ceph luminous 提供iscsi服务

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-7-10 17:41:02 | 显示全部楼层 |阅读模式
开始安装之前必须要满足以下条件:6 z( y* M' h1 l  N: p% Q
正在运行的Ceph Luminous版本集群或更高版本的存储群集;(本文我们采用的是M版本)
% f6 J9 u  I" G6 VRHEL/CentOS 7.5或者Linux kernel v4.16或更新;# E4 b1 S& d& B: }- I) H, |
同时拥有以下几个包:8 B/ y5 E* }9 H/ W% t- i
targetcli-2.1.fb47 or      newer package0 E% y- Y: [! W) j8 e
python-rtslib-2.1.fb64 or      newer package
7 U* d# Z* ]) \+ htcmu-runner-1.3.0 or      newer package
9 N6 F8 G' i! L$ K3 k- |$ E- }' hceph-iscsi-config-2.4 or      newer package/ @& c9 L. w4 X' D- E' k
ceph-iscsi-cli-2.5 or      newer package
' Y6 y; D1 h3 J; k! `; p注意:我们本次安装ISCSI GW是在OSD 节点上安装# s. R0 i- N" u1 A% O5 e1 V2 C
由于很多童鞋可能获取不到rpm包,所以我这里整理了一下所需要的rpm并且分享了出来,以下是链接; a& e- v& O, Y1 Y" Q, I
链接: https://pan.baidu.com/s/1piNymp6oWLNHvXKaxBszLg 密码: 4vag
' ~. u5 P2 Y+ {( I  P安装部分就不说了只要把rpm包下载到本地,安装很简单,下面来说下配置部分:- H! r. `+ k/ p" c, ^- C4 C/ F8 E
首先创建一个iscsi gw的配置文件; ]; n8 c: `1 c# b4 C, b# e) o( |1 K
# touch /etc/ceph/iscsi-gateway.cfg. U! M! ^, y; K& m" q4 l2 j
里面内容如下:
4 V% ?# {7 i0 `6 o, u8 x6 T/ W[config]
4 S$ E& p7 s' G$ x# Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
% S+ @8 J4 ^1 q1 q4 v+ d# access to the Ceph storage cluster from the gateway node is required, if not
- k, {, `. k* R# colocated on an OSD node.; N( s) s: P9 z4 u& ?7 x
cluster_name = ceph% h9 i1 u$ A. t: x) P
+ T8 w. \/ g) J/ @+ g- u: Z+ ~
# Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
) W7 n- n" Q/ a; U6 o# drectory and reference the filename here
, |6 [! C- `- o' l0 h7 o: M( fgateway_keyring = ceph.client.admin.keyring
' J, c/ `4 r0 ?3 ?. q8 |/ s# J   g5 A% c) j; l" M  s! u) k
+ u" s8 U& U* V/ q3 f" C* @7 G
# API settings.* j- s4 }% ~- {. {
# The API supports a number of options that allow you to tailor it to your" p% m4 }* [- [  t8 ~
# local environment. If you want to run the API under https, you will need to
. Z( t8 Q2 P8 s* _# create cert/key files that are compatible for each iSCSI gateway node, that is' y' v% z' ~- C
# not locked to a specific node. SSL cert and key files *must* be called
$ F! s5 P' j+ @% F# 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory
+ i- g  N4 j% Z+ q# ~5 P/ y# on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'" \, d1 C3 |( }" Y4 W) b
# to switch to https mode.
  P4 x# V, P6 P; V: F$ Z
* w0 @* A! M/ n: g# To support the API, the bear minimum settings are:
4 P# p; d2 {- {9 xapi_secure = false
6 ]" m" S% r& b4 Q% x9 H' X/ z 9 s  W& s! H0 e( D
# Additional API configuration options are as follows, defaults shown.9 f% r8 C5 U+ r
# api_user = admin
! ?- E% \; X8 T3 P# api_password = admin
* p/ P; i9 k  Y# api_port = 5001
$ S+ y" j8 b! M: n+ b4 `# trusted_ip_list = 192.168.0.10,192.168.0.11
! e8 z5 u- E! S2 {6 @9 Z2 E8 t注意:需要修改的地方就行把trusted_ip_list替换成自己实际场景的节点ip
  A9 ?( ]" B/ t$ d( [& k, _完事之后重启iscsi服务; n) R, O# ^- P0 C( Z
# systemctl daemon-reload
# k6 a& H2 G1 Y4 I- S9 {, t% L3 H# systemctl enable rbd-target-api
5 G, c* p) I6 p# }# systemctl start rbd-target-api1 m# K) n' m* N" k. Y4 f
OK到此为止,iscsi gw已经安装配置完成,下面开始创建iscsi target
4 e, c7 o2 b* O/ O! N, C0 i  T) e# @; f- ]. V! L- v) _2 `% G
1.执行gwcli命令进入iscsi
4 y; Q& V% a" a- o2 E# l
1 i9 {% x' K+ d3 [  B/ y  B* U2.创建iscsi target- p0 |9 d9 ~% F3 ~/ p: y+ _
> /> cd /iscsi-target
5 ~% T+ {" s0 n' p" a> /iscsi-target>  create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
7 {, }9 x: a) o' S1 L4 e
9 g/ ^/ ^( g4 J: o/ ?8 y  g3.创建iSCSI网关。以下使用的IP是用于iSCSI数据传输的IP,它们可以与trusted_ip_list中列出的用于管理操作的IP相同,也可以不同,看有没有做多网卡分离8 j1 Y2 X* a4 u
> /iscsi-target> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways! Y. {5 o  m/ q: i
> /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21 skipchecks=true, `- J- g% P' b$ p7 u5 W9 y5 T$ H$ [* i
> /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22 skipchecks=true
9 B1 Y% j( ?  {2 H% t4 I   x* h; K) s6 u. S4 `$ [
4.创建一个rbd设备disk_1
. {/ s  d# I& ~* Z3 |# t> /iscsi-target...-igw/gateways> cd /disks
( f" ?# W9 ]2 ^6 V8 \% }9 X% d> /disks> create pool=rbd image=disk_1 size=90G
+ W" M! O1 t" p* G6 X/ Z- m$ w 3 m* o/ M7 Z# x1 j& y* f# F7 D
5.创建iqn' x! i# c+ ]  Y- r7 E- g
> /disks> cd /iscsi-target/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts3 f3 y$ R3 R' p0 `" |' V
> /iscsi-target...eph-igw/hosts>  create iqn.1994-05.com.redhat:rh7-client
6 f% L$ K% G" `; G
8 @) i- P5 n, Q$ |' B7 `9 _; |6.创建chap的用户名密码,并且chap必须设置,否则服务端是禁止连接的
* H' E( Q9 ]# S7 F8 t( u> /iscsi-target...at:rh7-client>  auth chap=myiscsiusername/myiscsipassword3 p  E+ |. F- S! \; z7 b
8 n% N& Q2 T; k! Q
7.增加磁盘到客户端& S0 x* Z8 m/ R- _. E0 n
> /iscsi-target...at:rh7-client> disk add rbd.disk_1
# n1 K2 [1 e, L   G. A0 m6 n+ ^6 R  J5 g
OK,到这里就配置完成了,我们看下最终是什么样的$ `# E/ b9 }1 D# ?: C6 _
iscsi.png
+ w/ p- n; [# p+ Z$ d
' H5 f0 V3 h3 ~! M2 ~& P安装配置完之后就可以挂载使用了,一般也就是windows/Linux,我们先说下Linux下挂载方式+ l) A* C2 I9 T3 V
7 S$ R% e7 Q  C8 [  }/ n
1.安装iscsi工具
& I8 A8 g5 @0 B' a! D$ d. a0 k2 d# yum install iscsi-initiator-utils
' C' P! D8 _/ Z, _% y9 T# yum install device-mapper-multipath
% E, ^2 l+ ^' N" q4 w( V2 M
, L2 n1 i- \/ n  T; o2.配置多路径
5 K& L0 f, k9 Q% c+ z# mpathconf --enable --with_multipathd y
2 V* S, z3 ~' Wdevices {
; y# E. @2 v3 }+ i4 A0 P, J9 O) ]        device {
3 @4 J& r6 q6 h, k6 L& T3 ?                vendor                 "LIO-ORG"
9 F% D3 j& |! S4 J4 \0 |  N/ \9 {                hardware_handler       "1 alua"2 Q$ W6 K& }; C* V  y9 v; N+ x
                path_grouping_policy   "failover". ~% }! D- R8 O$ A
                path_selector          "queue-length 0"2 V( f2 B. u( _2 t
                failback               60' n( ~5 ~! J+ b. \! P( N0 @7 L
                path_checker           tur4 X. t  d' m7 N( ]& f  j/ y5 e
                prio                   alua
% D3 V9 s) h, y) t& F                prio_args              exclusive_pref_bit
. x9 F* `  r2 F: I. Y& w) ]  T% S                fast_io_fail_tmo       25
2 K4 G( q3 {! i) ^: i                no_path_retry          queue
: w' N% Y( `7 r) z' [7 M( f6 m        }
' U' q8 K! H) }7 v! w" P}
: ~6 F) M+ P! _: [# L4 c
; K6 W# t& q" @3.重启服务1 u6 E* k. X% P1 R2 g! `
# systemctl reload multipathd! H- \6 E/ t$ W2 \+ Q( E
5 P- t$ s8 q5 ~- o# z7 O
4.配置chap认证' [. ]2 q2 o0 l
修改配置客户端的名称为之前设置的名称. r" P( v, g) ~
# vi /etc/iscsi/initiatorname.iscsi
* ^  n3 b3 n! y- D+ }; ^ InitiatorName= iqn.1994-05.com.redhat:rh7-client. H9 G0 n. r; W4 }9 Q4 |% _( ~
修改chap认证配置文件
" T" [1 c$ d! r- W # vi /etc/iscsi/iscsid.conf5 z3 ^* S# ^, B' R$ y2 z. d
node.session.auth.authmethod = CHAP* L8 I3 i7 H. O
node.session.auth.username = myiscsiusername% p/ E7 S6 C4 j4 B2 e- Z
node.session.auth.password = myiscsipassword( x: \# j& V0 n9 I7 W2 {& O/ X

7 G. j0 ]8 b# \  @5.查询iscsi target( Z  n7 V7 H0 k
# iscsiadm -m discovery -t -st 10.172.19.213 M3 h3 j0 N, L. k/ M  ~% B
6 e$ T) G5 N( y0 G# O& C
6.连接target8 M. K$ e" q" q/ J
# iscsiadm -m node -T iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw -l* `! l  B. k2 g, j! W. i
# multipath –ll6 t( W$ e" E2 N* R

2 H0 F- T# c, Y5 }- P* G1 E* O3 \

1

主题

0

回帖

12

积分

管理员

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

配置yum文件ceph-iscsi

[root@ceph01 ~]# vi /etc/yum.repos.d/CentOS-Base.repo & b0 a( ~) _/ \. D$ ~
) ?# i. o7 B6 z. Q
[Storage]
, f' e- K# S9 f- ~) ]* M4 b! u  ?8 z
name=CentOS-$releasever - Storage9 J" b+ x. j  Q
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64
/ceph-nautilus/7 h% }0 _( h# b2 ^) }' R  i; I, J
gpgcheck=0

2 }1 O; t9 G6 j
enabled=1: B/ Q0 \4 C$ Q# `4 z1 a& X: z6 }

) Y% g, B  i: H# @, Z, C# g% O[Gluster]

& X! Y8 i* x$ ]* @4 O! k
name=CentOS-$releasever - Storage. D; }" h, a$ C* S0 G0 w# T  b+ ~
baseurl=https://mirrors.huaweicloud.com/centos/7.7.1908/storage/x86_64/gluster-5
/- H, c# v3 C8 _+ b0 ?! c+ U
gpgcheck=0
0 v9 v" t' R5 a
enabled=1! ~$ I1 l, S$ Q& u% o4 W! @
$ R* d* e+ F, K. s
[ceph-iscsi]
) J) Z' _: x  [1 T5 q1 Z4 n
name=CentOS-$releasever - Storage
3 d& n9 J4 y0 i) K6 c
baseurl=https://mirrors.huaweicloud.com/ceph/ceph-iscsi/3
/rpm/el7/noarch/& C* v+ \2 g- O' [; ]
gpgcheck=0

4 K* X( i5 A+ M5 \6 y) ~1 L6 p
enabled=11 j. D+ B/ }, x. P/ G; _. U0 S6 Q! C
: I% ?6 W9 b) Q! L# H) _( p
[epel]
$ B1 ^7 u7 v/ I" ?6 A
name=CentOS-$releasever - Storage. |! F* R- [- w5 V' ]/ a
baseurl=https://mirrors.huaweicloud.com/epel/7Server/x86_64
/* y) P0 ^) G, M
gpgcheck=0

4 I. A2 @: |9 h+ A' d' N7 A. `
enabled=1
3 r$ I! b1 @* B9 e; i7 b

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-7-10 21:37:05 | 显示全部楼层
直接yum install试试可以发现,只有targetcli和python-rtslib能装上,而且版本都比官网说的要低,好吧,麻烦来了。' M4 L0 G0 S# m* h3 ~, L" c0 r8 n
, y# I0 [3 X; Z! m' v: a
经过一段几个小时*的搜索……从下面链接中找到了rpm包:) K& g( }2 x8 n0 j: Q9 {, v9 m
( W5 G0 |* q( V7 E
Build new RPM for 3.07 T, E* Y# [* A' @
Missing ceph-iscsi-cli package% t0 ?, @8 [0 s7 J5 x% `% i8 D
新建repo文件:
# e, t9 S( @* K4 I. A
' e9 n! A# x- L, D sudo vim /etc/yum.repo.d/iscsi.repo
/ m8 p+ H1 F7 H  g7 x9 @9 G6 Y cat /etc/yum.repo.d/iscsi.repo
2 o1 z; _* d. a" b  x
2 G% U& V7 G, w4 i; l: M[ceph-iscsi]
8 E* @# \; n  Bname=Ceph-iscsi
. ^- r$ h- C& P0 F' l$ y& Nbaseurl=https://4.chacra.ceph.com/r/ceph-iscsi/master/88f3f67981c7da15448f140f711a1a8413d450b0/centos/7/flavors/default/noarch/
( B) E- s( Y3 Npriority=1
+ r+ R6 v8 X0 E# r( D. h/ \3 hgpgcheck=0
" I2 t; O0 a) w+ i& o
0 X% r- c' ^7 v3 i" E[tcmu-runner]
1 A2 _+ ]4 v# e+ A: G; Q; I5 g' x% Mname=tcmu-runner% U4 T/ d' n$ I, d. k2 Z: D+ P
baseurl=https://3.chacra.ceph.com/r/tcmu-runner/master/eef511565078fb4e2ed52caaff16e6c7e75ed6c3/centos/7/flavors/default/x86_64/
; `$ F% s& z. h7 Cpriority=1
3 [0 Q5 d0 k( \4 O5 n7 ]' ugpgcheck=0. s5 z" I) K& h7 ]8 p- X
- f% s6 W: R& d- K0 G4 O1 r
[python-rtslib]6 ?: [! v1 P4 }* U2 a. I
name=python-rtslib& R9 c% K, F0 ?# v
baseurl=https://2.chacra.ceph.com/r/python-rtslib/master/67eb1605c697b6307d8083b2962f5170db13d306/centos/7/flavors/default/noarch/
6 h4 {) x6 `% A: F# ?priority=1% L& X* L3 l( C
gpgcheck=0
$ |" \% O1 b2 \, A& u' r2 [9 ?6 Q这里我使用的是本地源,将上面的包下载到本地源:
" z5 D0 c; H$ H3 o4 e7 d7 n: T  T, h
sudo yum install --downloadonly --downloaddir=yum/ceph-iscsi/ targetcli python-rtslib tcmu-runner ceph-iscsi- @) W5 N' T6 @: y6 Y
createrepo -p -d -o yum/ yum/
* Y% w! c( e, T6 B$ V注意到这里没有包含targetcli的repo,因为没有找到,使用yum基础的Base源或者是Ceph源可以安装targetcli-2.1.fb46-7.el7.noarch.rpm, 虽然官网需要的是targetcli-2.1.fb47 or newer package,但在后续使用中发现没有影响,所以这里就不用管targetcli了。
! s* x! k- x# p5 v- |; O1 ^6 ^- k5 h8 l4 P" Z/ \8 K2 Z/ j
那么这里下载下来的就是:
: u, K8 w# S2 H& y$ S* i. d9 B! l, k1 B1 X* e% P9 Y$ y: Q
targetcli-2.1.fb46-7.el7.noarch.rpm( {* C: \5 Y, r; i
python-rtslib-2.1.fb68-1.noarch.rpm
$ s7 L* V  D- B, |( O! `0 u2 }tcmu-runner-1.4.0-0.1.51.geef5115.el7.x86_64.rpm
/ J& l9 [3 R4 @% i% @! D8 X. F/ uceph-iscsi-3.2-8.g88f3f67.el7.noarch.rpm
$ W& v5 j4 L! N1 t. N# |$ l4 T1 kceph-iscsi网关初始配置  u1 O+ \; S! j0 A
如果使用的不是集群内的节点作为ceph-iscsi网关,那就需要进行一些初始的配置。5 i" N' b, @% `% ~
/ t4 m0 Y( w+ M( l
安装ceph。
* B, d* ?5 L% s- ^' l2 `从集群中的一台机器上拷贝/etc/ceph/ceph.conf到本机的/etc/ceph/ceph.conf。( y: |  c: U9 }  g
从集群中的一台机器上拷贝/etc/ceph/ceph.client.admin.keyring到本机的/etc/ceph/ceph.client.admin.keyring。
' ~' O- `8 Z# h: h' n# g当然第2和3步可以直接在deploy节点使用ceph-deploy admin {node-gateway},{node-gateway}就表示网关节点的名字。- d( B. I7 o3 C/ C5 ^
* L" n( d( ^# \& j3 p# [
可见这里就是为了将ceph-iscsi网关节点变成一个admin节点。5 ?8 y6 \3 L  G+ t

! b/ i+ l! X# s这时在网关节点上应该可以执行相关命令操作ceph集群,例如sudo ceph -s查询当前集群的状态。
1 X- t& i! ^* V
( s0 y  @" y# O, l) p安装配置iscsi
% `2 g" {* y, z: f$ _  u# s* O+ K这里官网建议先切换到root用户,方便一点:
0 a' e' X+ K+ ?, C0 m% m( l/ w! v  |0 i4 V/ y) k
su root3 X+ ^7 u* B# c" e
在两个网关节点上都安装iscsi(注意到上面已经将相关包下载到了本地源,所以可以直接yum安装):
1 M7 k7 k" j5 |  v/ b; |/ o% i
8 d! K7 ?1 ^/ G0 \. \ yum install -y ceph-iscsi0 U2 ^5 K5 V( G/ n
服务启动:8 @5 c. @1 h0 ?. l- D
0 S; }. \. K% [
先创建rbd pool,如果没有的话。  H3 p* ^) y4 |  L' W2 j7 V
- C( g/ o7 J8 J  H+ T9 e
ceph osd lspools3 W- p" J% G. i9 x6 D+ S- Y, k

1 q$ ?4 V, p7 f1 cephfs_data( t9 N8 J7 l8 g9 F
2 cephfs_metadata+ A( V( F6 K0 l: ]

5 c7 w/ z. C* q* G) Q& ` ceph osd pool create rbd 128/ v. K" d+ Y+ K% l5 L  B( g, W- a
7 b+ \. |6 z  ]! [
pool 'rbd' created' @3 X2 K) z( A
创建并修改/etc/ceph/iscsi-gateway.cfg文件:
; k# r: _) ^1 {$ p' j0 O$ e
7 m& X* W# Z7 N# |0 W* O, d vim /etc/ceph/iscsi-gateway.cfg
( r, g# v& N; f/ e cat /etc/ceph/iscsi-gateway.cfg2 L3 o, l0 N0 O& W2 }! _. A: @+ S
0 w% S% Y, \' B
[config]4 H# x: o( z( P& B
Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
% y) p7 D0 X2 [6 }) _) K6 {6 B. s4 T access to the Ceph storage cluster from the gateway node is required, if not+ a) W/ _; H. S" D: y' ?
colocated on an OSD node.
8 y- g8 Q( E- l/ Pcluster_name = ceph
' b" T5 v6 Y: ~" q- w& |
- d# p, g* J: O8 X( m$ p6 C Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph& B; N* z) q; i6 t
drectory and reference the filename here
7 T/ @7 y) R9 O* lgateway_keyring = ceph.client.admin.keyring; }; P4 O6 u6 o2 i) `
# g1 y% s4 N9 @! M2 m& n
3 N* b! p2 e) ?  b  k" [0 {
API settings.5 x( `5 e: J. c: u0 `* O( a
The API supports a number of options that allow you to tailor it to your2 T& w$ ~% A- N
local environment. If you want to run the API under https, you will need to+ Z' v3 h3 ]/ J+ m, P8 x
create cert/key files that are compatible for each iSCSI gateway node, that is
! t/ \& G& P; Q1 h7 s not locked to a specific node. SSL cert and key files *must* be called
' w0 p' X' L+ p 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory
- w6 \" U5 C8 g8 `7 b on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
0 X) R8 }( a4 X2 s( r  _; Z& N to switch to https mode.0 ^. e. n3 l& v: w0 S) p' n
: C" J9 g1 J5 t) p& d- Z
To support the API, the bear minimum settings are:
. ?/ W5 x+ a3 o* y3 }; M4 Y1 `+ Rapi_secure = false0 P, T- E1 k: U* p" m) [
  j7 A2 m1 [: l1 P% C2 ^
Additional API configuration options are as follows, defaults shown.2 M* K& ^! ~& C& k: }( g" ?) h* q
api_user = admin0 W' S4 m* @' W, l
api_password = admin9 ]0 t' |; D' n$ b7 u- P9 `
api_port = 5001
1 n# T0 W8 K2 x5 otrusted_ip_list = 192.168.90.234,192.168.90.235
  T/ l+ M  m4 ?. S& D, R上面trusted_ip_list填写的就是两台网关的ip(这里不讨论多网卡的情况)。
( D( o: j0 I1 `( A* i. Q9 J+ X& e8 a2 k& V# e: V; m. P
在另外一台网关上复制这个文件:, a: u( H- A+ r. A
( Y+ o3 o. ^3 ?* Q) U
sudo scp cluster@node2:/etc/ceph/iscsi-gateway.cfg /etc/ceph/iscsi-gateway.cfg3 g/ p5 s$ L  P2 w5 k
在两台网关上都开启rbd-target-api服务:6 k+ h0 Y4 k1 H1 l

4 I2 v8 Y+ V3 a- U$ t systemctl daemon-reload
  x  k) `2 S6 \6 h8 N' Y7 F$ d5 g systemctl enable rbd-target-api
4 ~' s/ z2 g. j+ f/ A0 ? systemctl start rbd-target-api
, E* H! T9 H/ S配置:(在其中一台网关配置就行)
* E( G0 U' _: Y5 n7 f+ Z; y! V9 F, `" @* y2 x' L2 x( Z- g
gwcli
! O! @- q. a3 V cd /iscsi-targets
7 s$ O& ^1 P8 y& [1 Q  O
3 c0 d' y8 Z/ H6 M8 x create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw) m& q5 y0 z3 w6 [% N# ?2 y
ok
/ D8 G, J( d% V5 t( U+ Z# |- F4 c$ l, D2 {- m/ q
cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
- a6 C& x2 `: B4 C( z
, U) ?5 f9 x" O1 f4 ?2 e/iscsi-target...-igw/gateways> create node2 192.168.90.234
- w: A5 e- X7 N# H7 B2 C3 y4 EAdding gateway, sync'ing 0 disk(s) and 0 client(s)  r; u- g# B6 g& V5 c8 ~
ok3 p; z2 z* }+ W: @
, y1 ~! D" T4 l! A( c
/iscsi-target...-igw/gateways> create node3 192.168.90.235
5 s0 [/ ?4 g. M# _1 BAdding gateway, sync'ing 0 disk(s) and 0 client(s)
+ P9 p8 X! S/ \2 bok
8 q$ E# ~0 D  Q9 d! H; K5 k" J( m
, ]  w  |5 ~1 [: |+ D/iscsi-target...-igw/gateways> cd /disks
" }9 N6 ]/ Q) ?7 t/ ]8 r/ ?: m: I1 l8 |0 b
create pool=rbd image=disk_1 size=200G
8 `5 m( z. L  ?$ \) Qok: w# ?# V5 K6 F( N

, g7 x" w9 p( S( ~$ ]' W cd /iscsi-targets/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts
- y7 x$ d' @! H" |" l7 X8 X6 P1 o6 ^5 \
/iscsi-target...csi-igw/hosts> create iqn.1994-05.com.redhat:rh7-client, f9 a+ T: A7 M/ M% \0 Y$ a: H
ok8 Y9 [- B% `: e5 M1 R$ c1 G( R
/ Y) p8 F% }7 c4 b
/iscsi-target...at:rh7-client> auth username=myiscsiusername password=myiscsipassword
. J- f: T8 o  Z1 O, Ook
4 y) g$ I( v2 H3 X* O- c+ W1 o9 ^! U
/iscsi-target...at:rh7-client> disk add rbd/disk_14 W4 K6 N6 F# Z
ok
: v5 V) [# p! D( ~) ?' B1 C- Q配置完成,可以看到我当前的目录结构:  h8 M7 w/ N/ y7 d* n
+ _, |1 m4 W! S* w/ N- |& [( k
ls2 K- |6 d5 h: {5 @5 i2 S& X) A
o- / ......................................................................... [...]+ L1 v9 [- _; p6 v0 Y. q# d* C
  o- cluster ......................................................... [Clusters: 1]
' X$ q9 M' R* `  | o- ceph .......................................................... [HEALTH_WARN]# A$ G* X2 P# i' ]' w
  |   o- pools .......................................................... [Pools: 3]/ S5 Z/ w6 e2 e, B
  |   | o- cephfs_data ... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 2029431878b]
" v. C9 S% S: u% \* @  |   | o- cephfs_metadata .... [(x3), Commit: 0.00Y/2028052096K (0%), Used: 77834b]% B6 J+ x1 t4 I' p( m' c+ C
  |   | o- rbd ................ [(x3), Commit: 200G/2028052096K (10%), Used: 15352b]
5 G/ b! r# R  t  |   o- topology ................................................ [OSDs: 6,MONs: 3]
& S$ z0 d9 x: g# j7 P  o- disks ........................................................ [200G, Disks: 1]
2 Z  R$ N- ^7 o- Z  C- q  | o- rbd ............................................................ [rbd (200G)]
% K1 }; H; E! U' A  |   o- disk_1 ................................................ [rbd/disk_1 (200G)]9 g) q7 v' i  R! s
  o- iscsi-targets ............................... [DiscoveryAuth: None, Targets: 1]/ `, L5 y$ Z% V; M* T
    o- iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw ..................... [Gateways: 2]
# J' I7 J6 \9 M      o- disks .......................................................... [Disks: 1]
1 `. f* m+ r/ n5 m0 m- P! I, B      | o- rbd/disk_1 ............................................... [Owner: node3]
5 b: e  A% P4 U% ]/ W* k  Q      o- gateways ............................................ [Up: 2/2, Portals: 2]
+ ]8 t% S6 r- {, f) T% _$ T8 w      | o- node2 ............................................. [192.168.90.234 (UP)]
+ [9 M8 U- V1 W, {7 W2 i      | o- node3 ............................................. [192.168.90.235 (UP)]
8 v% k! i$ B/ x+ x# B, Q9 @, W      o- host-groups .................................................. [Groups : 0]
  b  r) ~! W* L+ i+ \+ K* N. I! f      o- hosts .............................................. [Hosts: 1: Auth: CHAP]
; o/ A2 l" {, v        o- iqn.1994-05.com.redhat:rh7-client .......... [Auth: CHAP, Disks: 1(200G)]! s- d# W( U! E& t0 y
          o- lun 0 ................................ [rbd/disk_1(200G), Owner: node3]
& Q5 b3 P0 o8 [3 d0 l% ?. alinux客户端配置
4 Q9 I' f, F0 V在作为客户端的linux主机上。9 k2 ]3 c4 h; v2 d

9 T' b' j7 Y. y8 Z7 S安装相关组件:
; @! [9 {$ I, u# `# S- @( e$ }: M5 l8 i
sudo yum install -y iscsi-initiator-utils
+ g( f0 p, \7 _# G sudo yum install -y device-mapper-multipath8 {5 c* z/ v6 @& X0 f. a
开启multipathd服务并进行配置:  f$ W, ], L6 G6 O2 C

+ z  G8 q. {# J sudo mpathconf --enable --with_multipathd y( {* X1 b& P( r/ ~, h6 J
: Q& A2 m, }: K- X1 v$ U
sudo vim /etc/multipath.conf
: m  X8 _/ F5 H' Q sudo cat /etc/multipath.conf& t3 R0 a" i+ `( X* a( I
  Z+ V0 P" i6 }4 A) p$ `  c
devices {
0 v0 F1 D; ~# g) {: b2 w) C1 Y) {1 W& T        device {5 Z; V: }: }6 t% h+ ]2 C
                vendor                 "LIO-ORG"' D) D# ~$ P+ F- M) B
                hardware_handler       "1 alua"
5 M( i7 T& a# h& N                path_grouping_policy   "failover"
3 i: ^3 _! ~/ u& }- a7 G                path_selector          "queue-length 0"1 Z. p; m* ?( o: t3 g2 G$ K+ k
                failback               60
# X/ N: V; y+ L                path_checker           tur
0 k# k: v- J% p5 B5 W/ q- `                prio                   alua# x; e6 b# W5 o
                prio_args              exclusive_pref_bit" Q- a2 Y/ T3 B' U- m2 k) ]4 }0 _8 \( C
                fast_io_fail_tmo       25
$ e1 Y7 O4 B) g2 K" v                no_path_retry          queue& b2 X+ O, F: U( [' P2 E, q
        }7 l+ `. [6 Y8 a# F  n' i
}! B+ e6 N+ _! O  [5 N4 E3 |( v
修改客户端名称:
( k$ r4 h* Y) p6 d! a
3 E' [3 z: F( o9 S* C  P/ N sudo vim /etc/iscsi/initiatorname.iscsi
+ }4 p' F- g2 y! C* _6 j sudo cat /etc/iscsi/initiatorname.iscsi
9 r. x3 s( B1 S2 B, E7 k( A8 @
- L5 C# Y9 x* T+ x, T, `9 g5 tInitiatorName=iqn.1994-05.com.redhat:rh7-client
9 P; o, e, a$ Z/ F: z修改chap认证配置文件:' |; U, Q0 x# F! ]  M6 ~4 h

# q2 u: O$ p/ E% ^. {7 i sudo vim /etc/iscsi/iscsid.conf/ C- \6 u3 I4 q' _9 \6 R) {* ~
sudo cat /etc/iscsi/iscsid.conf
8 V7 s4 F- [: B, N
' v9 l* k- X3 @...# n9 Y* t$ |4 C
*************6 R* l, Y0 w$ \9 W" f
CHAP Settings
8 ~0 R  t- I: d *************1 F! ?5 c' `5 X9 E8 T

- b7 E! J- s, T7 n- u To enable CHAP authentication set node.session.auth.authmethod' _6 l: o, q7 K: i$ L
to CHAP. The default is None.+ h/ m7 j- j7 U9 F0 ^
node.session.auth.authmethod = CHAP
, ?' l( B: x$ ~7 a5 C9 O4 d5 ~+ n' |7 g: V
To set a CHAP username and password for initiator' D5 Z* K$ k* p0 e3 X$ I1 t
authentication by the target(s), uncomment the following lines:0 ?& i# c2 h( i
node.session.auth.username = myiscsiusername2 w, k# W" [- i% C
node.session.auth.password = myiscsipassword' @- ^+ j- e3 {9 ~8 G7 J& N# E! q
...! f  Y9 Q& W% u
* _/ X+ ~% M, P* Y' |  F* ]( ~
发现target:
: k7 P2 k( D7 F2 g0 i* f7 q: {' i' {0 Q1 m5 {4 P
sudo iscsiadm -m discovery -t st -p 192.168.90.2346 u. \2 t) W0 k, h. C1 w
1 i9 M6 s; v+ v( M+ R$ M
192.168.90.234:3260,1 iqn.2003-01.org.linux-iscsi.rheln1
: K! `; i' Q2 N( o! t; H' b; f192.168.90.235:3260,2 iqn.2003-01.org.linux-iscsi.rheln19 `9 A  N7 K  Z- O
登入target:& ?: Z5 ^- K4 Y# l% t

2 Z/ e+ |1 \. x/ V  B: v: |# { sudo iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rheln1 -l: y+ l+ v4 G" v9 u+ c. ?2 t# u" o
查看是否成功:
6 ^0 L( ], M4 `- f1 y+ [% m% T0 u. T# \
sudo multipath -ll4 G" V# J7 b% Q
mpatha (360014050fedd563975249adb2e84e978) dm-2 LIO-ORG ,TCMU device     ( ], P- G6 f' L- X/ c# a
size=200G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw+ V/ B+ S! x4 w& B
|-+- policy='queue-length 0' prio=50 status=active
% ?/ A# o/ L) w( }7 q/ L1 Z& ?| `- 3:0:0:0 sdc 8:32 active ready running
" H. Z8 J3 L  S`-+- policy='queue-length 0' prio=10 status=enabled
  A, m% D# m8 }- u5 c4 q/ Q. Q0 x  A9 Y; i  `- 2:0:0:0 sdb 8:16 active ready running# z, ~9 |8 d) a) M( O" \
在fdisk中就可以直接看到这个“硬盘”:: q& {! S; q  }: w+ \) U
/ p9 k, d1 r: }, x  z
sudo fdisk -l
: j7 l; c/ a7 ]: U
& y* B/ ?* I8 I) D- s$ N...3 _" a: Z: I1 L9 U6 u5 q
Disk /dev/mapper/mpatha: 10.7 GB, 10737418240 bytes, 20971520 sectors
  S  T: `7 X7 E- O5 Q; o/ P) T- j. wUnits = sectors of 1 * 512 = 512 bytes
" I/ h+ C- I' F, E7 o6 [- [$ E% e1 a9 mSector size (logical/physical): 512 bytes / 512 bytes
0 ?9 C& x/ G0 N$ t( y9 D) _8 |( Z/ kI/O size (minimum/optimal): 512 bytes / 524288 bytes
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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