Command action
l logical (5 or over)
p primary partition (1-4)
l # 选择l,逻辑卷
First cylinder (1-20480, default 1):
Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-20480, default 20480):
Using default value 20480Command (m for help): p # 查看信息
Disk /dev/sdb: 21.5 GB, 21474836480 bytes64 heads, 32 sectors/track, 20480 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: 0x47756356
Device Boot Start End Blocks Id System
/dev/sdb4 1 20480 20971504 5 Extended
/dev/sdb5 1 20480 20971488 83 Linux
Command (m for help): w # 保存
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks
[root@iSCSI_Server ~]# partprobe /dev/sdb # 使刚才的配置立即生效
[root@iSCSI_Server ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
64 heads, 32 sectors/track, 30720 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: 0x000da3dc
Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 30720 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
64 heads, 32 sectors/track, 20480 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: 0x47756356
Device Boot Start End Blocks Id System
/dev/sdb4 1 20480 20971504 5 Extended
/dev/sdb5 1 20480 20971488 83 Linux
[root@iSCSI_Server ~]# cat /proc/partitions
major minor #blocks name
8 0 31457280 sda
8 1 512000 sda1
8 2 30944256 sda2
8 16 20971520 sdb
8 20 1 sdb4
8 21 20971488 sdb5
253 0 27795456 dm-0
253 1 3145728 dm-1
#注:看到以上标黄的信息证明已经创建逻辑卷成功!
接下来创建LVM卷
[root@iSCSI_Server ~]# pvcreate /dev/sdb5 # 创建PV
Physical volume "/dev/sdb5" successfully created
[root@iSCSI_Server ~]# vgcreate kvmvg /dev/sdb5 # 创建VG
Volume group "kvmvg" successfully created
[root@iSCSI_Server ~]# lvcreate -L 19G -n kvmlv kvmvg # 创建LV
Logical volume "kvmlv" created.
[root@iSCSI_Server ~]# lvs # 查看
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root VolGroup -wi-ao---- 26.51g
lv_swap VolGroup -wi-ao---- 3.00g
kvmlv kvmvg -wi-a----- 19.00g
[root@iSCSI_Server ~]#
#注:看到以上标黄的信息证明已经创建成功!
3、安装服务端软件:scsi-target-utils
[root@iSCSI_Server ~]# yum -y install epel-release
[root@iSCSI_Server ~]# yum -y install scsi-target-utils.x86_64
4、配置iSCSI服务:
[root@iSCSI_Server ~]# vim /etc/tgt/targets.conf
#### 在 40行后添加以下信息#######
<target iqn.2017-03.com.zlyang:kvm.iscsi>
backing-store /dev/kvmvg/kvmlv
initiator-address 192.168.30.0/24
</target>
注:
iqn.2017-03.com.zlyang:kvm.iscsi : 为共享名
iqn.2017-03.com.zlyang:kvm.iscsi :共享卷名及路径
initiator-address 192.168.30.0/24 :允许哪些地址访问
5、启动服务
[root@iSCSI_Server ~]# service tgtd start
[root@iSCSI_Server ~]# chkconfig tgtd on
[root@iSCSI_Server ~]# netstat -tnlt|grep 3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN
tcp 0 0 :::3260 :::* LISTEN
6、添加防火墙规则
[root@iSCSI_Server ~]# iptables -I INPUT 4 -p tcp --dport 3260 -j ACCEPT
[root@iSCSI_Server ~]# iptables-save
[root@iSCSI_Server ~]# service iptables save
[root@iSCSI_Server ~]# service iptables restart
三、安装Client
因为两台Client配置几乎一样,在此以Client1为例给大家演示具体部署过程
1、首先查看本地磁盘
[root@iSCSI_Client_1 ~]# fdisk -l