linux配制iscsi
服务端centos7
- 假定已经装好了两块磁盘/dev/sdb,/dev/sdc
- yum install -y targetd targetcli
- targetcli进入配制命令行
- 通过/dev/sdb,/dev/sdc创建两个block
/backstores/block create idisk1 /dev/sdb /backstores/block create idisk2 /dev/sdc
- 创建一个iscsi服务
iscsi/ create iqn.2024-08.com.sysush:server
- 通过block创建两个lun
cd iqn.2024-08.com.sysush:server/tpg1 luns/ create /backstores/block/idisk1 luns/ create /backstores/block/idisk2
- 创建客户端认证
acls/ create iqn.2024-08.com.sysush:client cd iqn.2024-08.com.sysush:client set auth userid=vec set auth password=665544332211
- 退出命令行
exit
- 重启targetd服务,并查看端口是否监听
systemctl restart targetd systemctl enable targetd ss -napt | grep 3260
- 防火墙放过3260端口
firewall-cmd --add-port=3260/tcp --permanent && firewall-cmd --reload
客户端(oracle linux 6.8)
- yum -y install iscsi-initiator-utils
- 修改/etc/iscsi/initiatorname.iscsi把InitiatorName改成刚才客户端认证的名字
InitiatorName=iqn.2024-08.com.sysush:client
- 修改/etc/iscsi/iscsid.conf,启用node.session.auth.authmethod,node.session.auth.username,node.session.auth.password
node.session.auth.authmethod = CHAP node.session.auth.username = vec node.session.auth.password = 665544332211
- 重启iscsi客户端
service iscsid restart
- 查看iscsi服务端,其中192.168.85.102是服务端的ip,如果能查到iqn.2024-08.com.sysush:server说明正常
iscsiadm -m discovery -t st -p 192.168.85.102
- 连接服务端
iscsiadm -m node -T iqn.2024-08.com.sysush:server -p 192.168.85.102 --login
- 再执行fdisk -l就能看到/dev/sdb,/dev/sdc,就能当成普通磁盘使用了