iSCSIとmultipathの導入
9595 ワード
コンセプト: Linuxが所有するマルチパスソフトウェアはmultipathと呼ばれ、サーバが複数の物理パスを介してブロックストレージデバイスに接続されていることを意味します. ホストHBAカード、ケーブル、スイッチ、またはストレージデバイスのRAIDコントローラの障害などにより物理パスが失効した場合、サーバはこの物理パスを通過するI/Oを他の正常な物理パスに移行することができ、アプリケーションはこのような変更に気づかず、システムの可用性を向上させる.ハードウェアの面ではサーバに2つ以上のHBAインタフェースカードが必要で、ネットワークには2つ以上のスイッチがあり、ブロックストレージ装置には2つ以上の冗長コントローラがあり、各物理経路の間にハードウェアの相互依存はありません.マルチパス冗長I/OもI/Oの負荷バランスを実現し、システム性能を向上させることができるが、主にフォールトトレランスメカニズムである.
一、サービス側インストールiscsi
1、iscsiのインストール
2、iscsiの配置
二、クライアント構成iscsi
1、認証のインストールと加入
2、サーバー側iscsiを発見する
3、ログイン
4、iscsi設備を接続する
5、システムディスク情報の表示
三、multipathのインストールと構成(クライアント)
1、Multipathのインストール
2、wwidを見る
3、multipathの構成
4、フォーマットマウント
5、ステータスの表示
四、multipath構成の概要
五、よくある質問:
1、ssh接続できないの原因の1つ:selinux制限. sshリモートホスト上のselinuxを無効または緩和モードに設定するか、sshポートを放して解決します.
2、サーバーが失敗したことを発見するの原因の1つ:サーバファイアウォールの制限. 解決策:ファイアウォール を閉じる
3、補足:sedは非注釈行と非空白行に一致する
一、サービス側インストールiscsi
1、iscsiのインストール
[root@localhost ~]# yum -y install targetcli
2、iscsiの配置
[root@localhost ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb41
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
# 1: ,( yzl:storage1 ),/dev/sdb 。
/> /backstores/block create yzl:storage1 /dev/sdb
Created block storage object yzl:storage1 using /dev/sdb.
# 2: ISCSITarget , : , :iqn.yyyy-mm.: ( )
/> /iscsi create iqn.2020-04.com.example:localhost
Created target iqn.2020-04.com.example:localhost.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
# 3: ACL ISCSI , :iqn.2020-04.com.example:localhost ISCSI 。
/> /iscsi/iqn.2020-04.com.example:localhost/tpg1/acls create iqn.2020-04.com.example:
Created Node ACL for iqn.2020-04.com.example:localhost
# 4: lun(target )
/> /iscsi/iqn.2020-04.com.example:localhost/tpg1/luns create /backstores/block/yzl:storage1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2020-04.com.example:localhost
# 5: ip , :192.18.13.30 IP; 3260, 。。。 , , 。
#
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
二、クライアント構成iscsi
1、認証のインストールと加入
[root@yzl ~]# yum -y install iscsi-initiator-utils
[root@yzl ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-04.com.example:localhost
2、サーバー側iscsiを発見する
[root@yzl ~]# iscsiadm -m discovery -t st -p 192.168.40.193
192.168.40.193:3260,1 iqn.2020-04.com.example:localhost
[root@node2 multipath]# iscsiadm -m discovery -t st -p 172.16.100.56
172.16.100.56:3260,1 iqn.2020-04.com.example:node1
3、ログイン
[root@yzl ~]# iscsiadm -m node -T iqn.2020-04.com.example:localhost -p 192.168.40.193 -l
Logging in to [iface: default, target: iqn.2020-04.com.example:localhost, portal: 192.168.40.193,3260] (multiple)
Login to [iface: default, target: iqn.2020-04.com.example:localhost, portal: 192.168.40.193,3260] successful.
4、iscsi設備を接続する
[root@yzl ~]# iscsiadm -m node --login
5、システムディスク情報の表示
[root@yzl ~]# fdisk -l # lsblk
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ca9a5
...
...
Disk /dev/sdb: 8589 MB, 8589934592 bytes
64 heads, 32 sectors/track, 8192 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk identifier: 0x00000000
三、multipathのインストールと構成(クライアント)
1、Multipathのインストール
[root@yzl ~]# yum -y install device-mapper-multipath
[root@yzl ~]# modprobe dm-multipath # DM
[root@yzl ~]# modprobe dm-round-robin # DM
[root@yzl ~]# lsmod | grep dm_multipath
dm_multipath 17724 1 dm_round_robin
dm_mod 84337 9 dm_multipath,dm_mirror,dm_log
[root@yzl ~]# rpm -ql device-mapper-multipath #
[root@yzl ~]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/
#
[root@yzl ~]# mpathconf --enable
2、wwidを見る
# scsi_id (/usr/lib/udev/scsi_id /lib/udev/scsi_id )
[root@yzl ~]# /usr/lib/udev/scsi_id --whitelisted --device=/dev/sdb
-bash: /usr/lib/udev/scsi_id:
[root@yzl ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdb
360014050939ee9c6b434831840535128
3、multipathの構成
# vim :
[root@yzl ~]# sed -n "/^\s*[^#\t].*$/p" /etc/multipath.conf # ed
defaults {
user_friendly_names yes
}
multipaths {
multipath {
wwid 360014050939ee9c6b434831840535128
alias yzlpath1
path_grouping_policy multibus
path_checker readsector0
path_selector "round-robin 0"
failback manual
rr_weight priorities
no_path_retry 5
}
}
[root@yzl ~]# ls /dev/mapper/
control vg_yzl-lv_root vg_yzl-lv_swap
[root@yzl ~]# service multipathd restart # iscsid
ux_socket_connect: No such file or directory
multipathd : [ ]
multipathd: [ ]
[root@yzl ~]# ls /dev/mapper/
control vg_yzl-lv_root vg_yzl-lv_swap yzlpath1 # yzlpath1
4、フォーマットマウント
[root@yzl ~]# mkfs.xfs /dev/mapper/yzlpath1
meta-data=/dev/mapper/yzlpath1 isize=256 agcount=8, agsize=262144 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@yzl ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_yzl-lv_root
18G 11G 6.0G 64% /
tmpfs 931M 76K 931M 1% /dev/shm
/dev/sda1 485M 53M 407M 12% /boot
/dev/sr0 3.8G 3.8G 0 100% /media/Asianux
[root@yzl ~]# mkdir /iscsi
[root@yzl ~]# mount /dev/mapper/yzlpath1 /iscsi/
[root@yzl ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_yzl-lv_root
18G 11G 6.0G 64% /
tmpfs 931M 76K 931M 1% /dev/shm
/dev/sda1 485M 53M 407M 12% /boot
/dev/sr0 3.8G 3.8G 0 100% /media/Asianux
/dev/mapper/yzlpath1 8.0G 33M 8.0G 1% /iscsi
5、ステータスの表示
[root@yzl ~]# multipath -rr
Apr 26 23:44:27 | multipath.conf line 67, invalid keyword: path_checker
reload: yzlpath1 (360014050939ee9c6b434831840535128) undef LIO-ORG,yzl:storage1
size=8.0G features='0' hwhandler='0' wp=undef
`-+- policy='round-robin 0' prio=1 status=undef
`- 3:0:0:0 sdb 8:16 active ready running
[root@yzl ~]# multipath -ll
Apr 26 23:44:30 | multipath.conf line 67, invalid keyword: path_checker
yzlpath1 (360014050939ee9c6b434831840535128) dm-2 LIO-ORG,yzl:storage1
size=8.0G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
`- 3:0:0:0 sdb 8:16 active ready running
四、multipath構成の概要
:
- defaults: 。
- blacklist: ,multipath 。
- blacklist_exceptions: , , 。
- multipaths: 。
- devices: 。
:
uid_attribute: udev , ID_SERIAL
path_grouping_policy ###
- failover ### ( )
- multibus ###
- group_by_serial ###
- group_by_prio ###
- group_by_node_name ###
path_selector ###I/O
- service-time 0 ### IO ( )
- round-robin 0 ###
- queue-length 0 ### IO
failback ###
- immediate ###
- manual ### ,
- followover ### 。 。
no_path_retry ###
- fail ### ,
- queue ### ,
五、よくある質問:
1、ssh接続できない
[root@yzl ~]# ssh 192.168.40.193
[email protected]'s password:
Permission denied, please try again.
2、サーバーが失敗したことを発見する
[root@yzl ~]# iscsiadm -m discovery -t st -p 192.168.40.193
iscsiadm: cannot make connection to 192.168.40.193: No route to host
iscsiadm: cannot make connection to 192.168.40.193: No route to host
iscsiadm: cannot make connection to 192.168.40.193: No route to host
iscsiadm: cannot make connection to 192.168.40.193: No route to host
iscsiadm: cannot make connection to 192.168.40.193: No route to host
iscsiadm: cannot make connection to 192.168.40.193: No route to host
iscsiadm: connection login retries (reopen_max) 5 exceeded
iscsiadm: Could not perform SendTargets discovery: encountered connection failure
systemctl stop firewalld
3、補足:sedは非注釈行と非空白行に一致する
sed -n "/^\s*[^# \t].*$/p" "$file"