General steps:
- create and setup logical volume
- install iscsi target
- configure iscsi
- test
- LVM
pvcreate --zero y /dev/sde will zero the first 2048 bytes of sde and initialize sde for use.
I created 4 PVs using pvcreate --zero y /dev/sde /dev/sdf /dev/sdg /dev/sdh.
Next is to create a volume group.
To create a volume group use vgcreate. vgcreate VG_stor /dev/sde, this will create a volume group with the name VG_stor which contains the PV sde.
For my VG I ran vgcreate VG_stor /dev/sde /dev/sdf /dev/sdg /dev/sdh
Now time to create logical volumes
Logical volumes are created using lvcreate. To create a 100GB volume the command would look like lvcreate -L 100G -n vol_scsi VG_stor. This creates a 100GB volume with the name vol_scsi from the volume group VG_stor.
The command I used was lvcreate -L 100G -n vol_scsi VG_stor
In short
pvcreate --zero y /dev/sde /dev/sdf /dev/sdg /dev/sdh;
vgcreate VG_stor /dev/sde /dev/sdf /dev/sdg /dev/sdh;
lvcreate -L 100G -n vol_scsi VG_stor;
- iSCSI target setup
To config file for the iSCSI target is /etc/tgt/targets.conf.
This setup will be very simple. Edit targets.conf and add the following:
<target iqn.2012-05.host.server:target0>
backing-store /dev/VG_stor/vol_scsi
</target>
Now start the target daemon and have it startup on boot.
service tgtd start;
chkconfig tgtd on;
Check the target information
tgtadm --mode target --op show;
Allow port 3260 via tcp in iptables.
This should show the targets that are configured.
All that is left is to create and setup the iSCSI initiator.
- iSCSI initiator setup
install iscsi-initiator-utils and configure /etc/iscsi/iscsid.conf if needed.
Now time to discover the target. iscsiadm -m discovery -t sendtargets -p iscsi-target-ip
There should be a target listed with the iqn of the iscsi target.
start the iscsi services
service iscsi start;
service iscsid start;
Look at the discovered targets.
iscsiadm -m node -o show;
Time to login to the target and confirm session.
iscsiadm -m node --login;
iscsiadm -m session -o show;
There should be a new entry in /proc/partitions. In my case it was sdd.
Now that is a basic run through on using LVM and iSCSI. It can get much more complex.
No comments:
Post a Comment