|
|
楼主 |
发表于 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 |
|