环境
服务端: host1 192.168.40.130 192.168.211.130 客户端 host2 192.168.40.131 192.168.211.131 host3 192.168.40.132 192.168.211.132 echo "nameserver 114.114.114.114" >> /etc/resolv.conf
服务端
yum install -y scsi-target-utils fdisk /dev/sdb /dev/sdb1 vim /etc/tgt/targets.conf <target iqn.2024-04.host1:target_san1> backing-store /dev/sdb1 initiator-address 192.168.40.131 initiator-address 192.168.40.132 initiator-address 192.168.40.130 initiator-address 192.168.211.131 initiator-address 192.168.211.132 initiator-address 192.168.211.130 vendor_id host1 product_id target1 </target> systemctl restart tgtd netstat -antup | grep 3260 查看状态 tgt-admin --show [root@host1 tgt]# tgt-admin --show Target 1: iqn.2024-04.host1:target_san1 System information: Driver: iscsi State: ready I_T nexus information: I_T nexus: 1 Initiator: iqn.1994-05.com.redhat:ea6095f63b2d alias: host2 Connection: 0 IP Address: 192.168.211.131 I_T nexus: 4 Initiator: iqn.1994-05.com.redhat:ea6095f63b2d alias: host3 Connection: 0 IP Address: 192.168.40.132 I_T nexus: 5 Initiator: iqn.1994-05.com.redhat:ea6095f63b2d alias: host3 Connection: 0 IP Address: 192.168.211.132 LUN information: LUN: 0 Type: controller SCSI ID: IET 00010000 SCSI SN: beaf10 Size: 0 MB, Block size: 1 Online: Yes Removable media: No Prevent removal: No Readonly: No SWP: No Thin-provisioning: No Backing store type: null Backing store path: None Backing store flags: LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 5369 MB, Block size: 512 Online: Yes Removable media: No Prevent removal: No Readonly: No SWP: No Thin-provisioning: No Backing store type: rdwr Backing store path: /dev/sdb1 Backing store flags: Account information: ACL information: 192.168.40.131 192.168.40.130 192.168.40.132 192.168.211.131 192.168.211.132 192.168.211.130
客户端
yum -y install iscsi-initiator-utils yum -y install temp/iscsi-initiator-utils-* [root@host3 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.40.130:3260 192.168.40.130:3260,1 iqn.2024-04.host1:target_san1 [root@host3 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.211.130:3260 192.168.211.130:3260,1 iqn.2024-04.host1:target_san1 [root@host3 ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sda3 [root@host3 ~]# systemctl restart iscsi [root@host3 ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb /dev/sdb1 /dev/sdc /dev/sdc1 yum install device-mapper-multipath -y cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/ systemctl restart multipathd multipath -ll [root@host3 ~]# multipath -ll mpatha (360000000000000000e00000000010001) dm-0 host1 ,target1 size=5.0G features='0' hwhandler='0' wp=rw |-+- policy='service-time 0' prio=1 status=active | `- 3:0:0:1 sdb 8:16 active ready running `-+- policy='service-time 0' prio=1 status=enabled `- 4:0:0:1 sdc 8:32 active ready running vim /etc/multipath.conf #defaults { # user_friendly_names yes # find_multipaths yes #} multipaths { multipath { wwid "360000000000000000e00000000010001" #填写硬盘产品关键信息 alias webdata #自定义名字 path_grouping_policy multibus path_selector "round-robin 0" failback manual rr_weight priorities no_path_retry 5 } } [root@host3 ~]# systemctl restart multipathd [root@host3 ~]# multipath -ll webdata (360000000000000000e00000000010001) dm-0 host1 ,target1 size=5.0G features='1 queue_if_no_path' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 3:0:0:1 sdb 8:16 active ready running `- 4:0:0:1 sdc 8:32 active ready running [root@host3 ~]# ls /dev/mapper/webdata* /dev/mapper/webdata /dev/mapper/webdata1 [root@host3 ~]# mount /dev/mapper/webdata1 /opt [root@host3 ~]# ls /opt 1100.txt 118.txt 126.txt 134.txt 142.txt 150.txt 159.txt 167.txt 175.txt 183.txt 191.txt 19.txt 110.txt 119.txt 127.txt 135.txt 143.txt 151.txt 15.txt 168.txt 176.txt 184.txt 192.txt grub 111.txt 11.txt 128.txt 136.txt 144.txt 152.txt 160.txt 169.txt 177.txt 185.txt 193.txt lost+found 112.txt 120.txt 129.txt 137.txt 145.txt 153.txt 161.txt 16.txt 178.txt 186.txt 194.txt 113.txt 121.txt 12.txt 138.txt 146.txt 154.txt 162.txt 170.txt 179.txt 187.txt 195.txt 114.txt 122.txt 130.txt 139.txt 147.txt 155.txt 163.txt 171.txt 17.txt 188.txt 196.txt 115.txt 123.txt 131.txt 13.txt 148.txt 156.txt 164.txt 172.txt 180.txt 189.txt 197.txt 116.txt 124.txt 132.txt 140.txt 149.txt 157.txt 165.txt 173.txt 181.txt 18.txt 198.txt 117.txt 125.txt 133.txt 141.txt 14.txt 158.txt 166.txt 174.txt 182.txt 190.txt 199.txt [root@host3 ~]# rm -rf /opt/*.txt [root@host3 ~]# ls /opt grub lost+found [root@host1 tgt]# ifdown ens36 成功断开设备 "ens36"。 [root@host3 ~]# multipath -ll webdata (360000000000000000e00000000010001) dm-0 host1 ,target1 size=5.0G features='1 queue_if_no_path' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 3:0:0:1 sdb 8:16 active ready running `- 4:0:0:1 sdc 8:32 failed faulty running [root@host3 ~]# ls /opt grub lost+found [root@host3 ~]# cp /etc/passwd /opt [root@host3 ~]# ls /opt grub lost+found passwd
菜鸟的自白
分类:
运维
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现