iSCSI技术概述
配置iSCSI服务端
[root@shareserver ~]# fdisk /dev/vdb
Command (m for help): n
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G
Command (m for help): t
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): wq
[root@shareserver ~]# pvcreate /dev/vdb1
[root@shareserver ~]# vgcreate vg0 /dev/vdb1
[root@shareserver ~]# vgdisplay
[root@shareserver ~]# lvcreate -l 255 -n lv0 vg0
[root@shareserver ~]# lvs
[root@shareserver ~]# yum install targetcli.noarch -y
[root@shareserver ~]# targetcli
/> ls
/> backstores/block create westos:storage1 /dev/vg0/lv0
/> ls
/> iscsi/ create iqn.2018-11.com.westos:storage1
/> ls
/> iscsi/iqn.2018-11.com.westos:storage1/tpg1/luns create /backstores/block/westos:storage1
/> ls
/> iscsi/iqn.2018-11.com.westos:storage1/tpg1/acls create iqn.2018-11.com.westos:westoskey
/> ls
/> iscsi/iqn.2018-11.com.westos:storage1/tpg1/portals create 172.25.254.160
/> ls
/> exit
省略部分安装过程
安装成功后启动服务,并加入开机自动启动项。
配置Linux客户端
[root@client ~]# yum install iscsi-initiator-utils.x86_64 -y
[root@client ~]# iscsiadm -m discovery -t st -p 172.25.254.160
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi
[root@client ~]# systemctl restart iscsid
[root@client ~]# iscsiadm -m node -T iqn.2018-11.com.westos:storage1 -p 172.25.254.160 -l
[root@client ~]# fdisk -l
[root@client ~]# mkfs.xfs /dev/sda
[root@client ~]# mount /dev/sda /mnt
[root@client ~]# df -h
[root@client ~]# cd /mnt/
[root@client mnt]# touch file
[root@client mnt]# ls
file
[root@client mnt]# cd
[root@client ~]# vim /etc/fstab
[root@client ~]# mount -a
[root@client ~]# reboot
[root@client ~]# df -h
配置Windows客户端
简述一下,控制面板>系统和安全>管理工具>iSCSI发起程序>目标为服务端IP>更改发起程序名称>连接>格式化使用
删除iSCSI配置
客户端
[root@client ~]# yum install tree -y
[root@client ~]# tree /var/lib/iscsi/
[root@client ~]# iscsiadm -m node -T iqn.2018-11.com.westos:storage1 -p 172.25.254.160 -u
[root@client ~]# iscsiadm -m node -T iqn.2018-11.com.westos:storage1 -p 172.25.254.160 -o delete
[root@client ~]# systemctl restart iscsi
[root@client ~]# fdisk -l
服务端
[root@shareserver ~]# targetcli
/> clearconfig confirm=True
/> ls
/> exit