阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Linux iSCSI Multipath多路径及名称持久化配置

434次阅读
没有评论

共计 7036 个字符,预计需要花费 18 分钟才能阅读完成。

环境:
iscsi server : openfiler eth0/eth1 bind->192.108.26.100
                   iqn.2006-01.com.openfiler:tsn.b45ae024d498
                   iqn.2006-01.com.openfiler:tsn.67571ed98f10
iscsi client : CentOS 6.6 eth1->192.108.26.117    eth2->192.108.26.118

1. 安装 iscsi-initiator
[root@ct6601 ~]# yum install -y iscsi-initiator-utils

2. 安装 device-mapper-multipath
[root@ct6601 ~]# yum install -y device-mapper-multipath

3. 设定 multipathd 服务开机自启动
[root@ct6601 etc]# chkconfig multipathd on

4. 测试网卡 eth1,eth2 能否 ping 通 iscsi server
[root@ct6601 ~]# ping -I eth1 192.108.26.100
[root@ct6601 ~]# ping -I eth2 192.108.26.100

5. 在 /etc/sysctl.conf 添加以下, 否则在第 8 步可能一直 timeout
[root@ct6601 ~]# cat >> /etc/sysctl.conf << EOF
net.ipv4.conf.eth1.rp_filter=2
net.ipv4.conf.eth2.rp_filter=2
EOF

[root@ct6601 ~]# sysctl -p

6. 修改 /etc/iscsi/iscsid.conf 中的 timeout 时间
[root@ct6601 ~]# cat /etc/iscsi/iscsid.conf |grep timeout|grep -v ^#
node.session.timeo.replacement_timeout = 2
node.conn[0].timeo.login_timeout = 2
node.conn[0].timeo.logout_timeout = 2
node.conn[0].timeo.noop_out_timeout = 2
node.session.err_timeo.abort_timeout = 2
node.session.err_timeo.lu_reset_timeout = 2
node.session.err_timeo.tgt_reset_timeout = 2

7. 建 iscsi iface
[root@ct6601 ~]# iscsiadm -m iface -I iface1 -o new

[root@ct6601 ~]# iscsiadm -m iface -I iface2 -o new

# 查看 /var/lib/iscsi/ 下的文件
[root@ct6601 ~]# cd /var/lib/iscsi/
[root@ct6601 iscsi]# du -sh *
12K    ifaces
4.0K    isns
4.0K    nodes
4.0K    send_targets
4.0K    slp
4.0K    static
# 绑定 iscsi iface 到网卡
[root@ct6601 iscsi]# iscsiadm -m iface -I iface1 -o update -n iface.net_ifacename -v eth1

[root@ct6601 iscsi]# iscsiadm -m iface -I iface2 -o update -n iface.net_ifacename -v eth2

8. 发现 iscsi target
[root@ct6601 iscsi]# iscsiadm -m discovery -t st -p 192.108.26.100  -I iface1 -I iface2
Starting iscsid:                                          [OK]
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.b45ae024d498
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.67571ed98f10
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.b45ae024d498
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.67571ed98f10

# 发现后相关文件已经生成
[root@ct6601 iscsi]# du -sh *
12K    ifaces
4.0K    isns
36K    nodes
28K    send_targets
4.0K    slp
4.0K    static

9. 启动 iscsi 服务, 建立连接
[root@ct6601 iscsi]# service iscsi start

10. 查看连接信息及 iscsi 盘
[root@ct6601 ~]# iscsiadm -m session -P 1
Target: iqn.2006-01.com.openfiler:tsn.b45ae024d498 (non-flash)
        Current Portal: 192.108.26.100:3260,1
        Persistent Portal: 192.108.26.100:3260,1
                **********
                Interface:
                **********
                Iface Name: iface1
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.RedHat:bfec8c6a9151
                Iface IPaddress: 192.108.26.117
                Iface HWaddress: <empty>
                Iface Netdev: eth1
                SID: 5
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE

                **********
                Interface:
                **********
                Iface Name: iface2
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.redhat:bfec8c6a9151
                Iface IPaddress: 192.108.26.118
                Iface HWaddress: <empty>
                Iface Netdev: eth2
                SID: 6
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE
Target: iqn.2006-01.com.openfiler:tsn.67571ed98f10 (non-flash)
        Current Portal: 192.108.26.100:3260,1
        Persistent Portal: 192.108.26.100:3260,1
                **********
                Interface:
                **********
                Iface Name: iface1
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.redhat:bfec8c6a9151
                Iface IPaddress: 192.108.26.117
                Iface HWaddress: <empty>
                Iface Netdev: eth1
                SID: 7
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE

                **********
                Interface:
                **********
                Iface Name: iface2
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.redhat:bfec8c6a9151
                Iface IPaddress: 192.108.26.118
                Iface HWaddress: <empty>
                Iface Netdev: eth2
                SID: 8
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE

# 查看 iscsi 盘               
[root@ct6601 iscsi]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0001e517

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1        523    4194304  82  Linux swap / Solaris
Partition 1 does not end on cylinder boundary.
/dev/sda2  *        523        3917    27261952  83  Linux

Disk /dev/sdb: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfef2bf25

Disk /dev/sdc: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfef2bf25

Disk /dev/sdd: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xab210de1

Disk /dev/sde: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xab210de1

11. 查看 wwid
[root@ct6601 ~]# scsi_id -gu /dev/sdb
14f504e46494c45527646546462502d716247302d7a61554b
[root@ct6601 ~]# scsi_id -gu /dev/sdc
14f504e46494c45527646546462502d716247302d7a61554b
[root@ct6601 ~]# scsi_id -gu /dev/sdd
14f504e46494c45524b61654859532d47436c612d30625046
[root@ct6601 ~]# scsi_id -gu /dev/sde
14f504e46494c45524b61654859532d47436c612d30625046   

12. 配置 /etc/multipath.conf
[root@ct6601 etc]# cat  /etc/multipath.conf
defaults {
        user_friendly_names yes
}
multipaths {
        multipath {
                wwid                    14f504e46494c45527646546462502d716247302d7a61554b
                alias                  dm1
                path_grouping_policy    multibus
                failback                manual
                rr_weight              priorities
                no_path_retry          5
        }
                multipath {
                wwid                    14f504e46494c45524b61654859532d47436c612d30625046
                alias                  dm2
                path_grouping_policy    multibus
                failback                manual
                rr_weight              priorities
                no_path_retry          5
        }
}

13. 启动 multipathd
[root@ct6601 etc]# service multipathd restart   

14. 查看 multipath 信息及 mapper 盘
[root@ct6601 ~]# multipath -ll
dm2 (14f504e46494c45524b61654859532d47436c612d30625046) dm-1 OPNFILER,VIRTUAL-DISK
size=40G features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
`-+- policy=’round-robin 0′ prio=1 status=active
  |- 6:0:0:0 sdd 8:48 active ready running
  `- 5:0:0:0 sde 8:64 active ready running
dm1 (14f504e46494c45527646546462502d716247302d7a61554b) dm-0 OPNFILER,VIRTUAL-DISK
size=40G 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
  `- 4:0:0:0 sdc 8:32 active ready running

[root@ct6601 etc]# ll /dev/mapper/
total 0
crw-rw—- 1 root root 10, 58 May 11 08:28 control
lrwxrwxrwx 1 root root      7 May 11 09:27 dm1 -> ../dm-0
lrwxrwxrwx 1 root root      7 May 11 09:27 dm2 -> ../dm-1

15. 验证可用性
略.

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-05/131479.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计7036字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19351
评论数
4
阅读量
7990534
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换,告别多工具切换

12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换,告别多工具切换

12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换...
星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛 NAS 硬件 03:五盘位 +N5105+ 双网口的成品 NAS 值得入手吗 前言 大家好,我...
150元打造低成本NAS小钢炮,捡一块3865U工控板

150元打造低成本NAS小钢炮,捡一块3865U工控板

150 元打造低成本 NAS 小钢炮,捡一块 3865U 工控板 一块二手的熊猫 B3 工控板 3865U,搭...
如何免费使用强大的Nano Banana Pro?附赠邪修的用法

如何免费使用强大的Nano Banana Pro?附赠邪修的用法

如何免费使用强大的 Nano Banana Pro?附赠邪修的用法 前言 大家好,我是星哥,今天来介绍谷歌的 ...
免费领取huggingface的2核16G云服务器,超简单教程

免费领取huggingface的2核16G云服务器,超简单教程

免费领取 huggingface 的 2 核 16G 云服务器,超简单教程 前言 HuggingFace.co...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
免费无广告!这款跨平台AI RSS阅读器,拯救你的信息焦虑

免费无广告!这款跨平台AI RSS阅读器,拯救你的信息焦虑

  免费无广告!这款跨平台 AI RSS 阅读器,拯救你的信息焦虑 在算法推荐主导信息流的时代,我们...
浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍 前言 在 AI 自动化快速发展的当下,浏览器早已不再只是...
小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比

小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比

小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比 星哥玩云,带你从小白到上云高手。今天咱们就来聊聊——什...
支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare 也瘫了连监控都挂,根因藏在哪? 最近两天的互联网堪称“故障...
开源MoneyPrinterTurbo 利用AI大模型,一键生成高清短视频!

开源MoneyPrinterTurbo 利用AI大模型,一键生成高清短视频!

  开源 MoneyPrinterTurbo 利用 AI 大模型,一键生成高清短视频! 在短视频内容...