# Target (Server) Side
# -----------------------------
I used 2 machines
Master 192.168.1.10 Target
Node1 192.168.1.20 Initiator
1. Create iSCSI Target
# yum install scsi-target-utils
# service tgtd start && chkconfig tgtd on
# iscsi --mode target --op new --tid 1 --targetname iqn-2013-3.com.example.master:disk1
Note: Target name is divided as follow
iqn-Year-Month.Reversed FQDN:Target Name
# tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store /dev/sda
# tgtadm --lld iscsi --mode target --op show
2. Security
# tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address 192.168.1.20
# tgtadm --lld iscsi --mode account --op new --user user1 --password 123
# tgtadm --lld iscsi --mode account --op show
# tgtadm --lld iscsi --mode account --op bind --tid 1 --user user1
# tgtadm --lld iscsi --mode target --op show
# iptables -I INPUT -p tcp --dport 3260 -j ACCEPT
3. Save changes permanently
# tgt-admin --dump
backing-store /dev/sda
incominguser user1 PLEASE_CORRECT_THE_PASSWORD
initiator-address 192.168.1.20
# after modifying user's password append this block of configuration at the end of /etc/tgt/targets.conf
# service tgtd restart
# tgt-admin -s # You should see the configuration of the target
# Initiator (Client) Side
# ------------------------------
# yum install iscsi-initiator-utils
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2013-3.com.example.node1:node1
# /etc/init.d/iscsid force-start
# chkconfig iscsid on && chkconfig iscsi on
# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.1.10 --discover # Discover luns in the target server, it takes into consideration Account and ACL information
# vim /var/lib/iscsi/nodes/iqn-2013-3.com.example.master\:disk1/192.168.1.10\,3260\,1/default # Enable CHAP authentication and add ACL information
#node.session.auth.authmethod = None
node.session.auth.authmethod = CHAP
node.session.auth.username = user1
node.session.auth.password = 123
Before Login
# fdisk -l | grep Disk
Disk /dev/vda: 5368 MB, 5368709120 bytes
Disk identifier: 0x00017416
Disk /dev/mapper/vg_master-lv_root: 3766 MB, 3766484992 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_master-lv_swap: 1073 MB, 1073741824 bytes
Disk identifier: 0x00000000
# iscsiadm --mode node --targetname iqn-2013-3.com.example.master:disk1 --portal 192.168.1.10:3260 --login
After Login
# fdisk -l | grep Disk
Disk /dev/vda: 5368 MB, 5368709120 bytes
Disk identifier: 0x00017416
Disk /dev/mapper/vg_master-lv_root: 3766 MB, 3766484992 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_master-lv_swap: 1073 MB, 1073741824 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 2147 MB, 2147483648 bytes # iscsi Target after login
Disk identifier: 0x00000000
# mkdir /data
# vim /etc/fstab
/dev/sda1 /data ext4 defaults,_netdev 0 0
# mount -a
Note:- _netdev delay mounting of the drive after loading networking
# -----------------------------
I used 2 machines
Master 192.168.1.10 Target
Node1 192.168.1.20 Initiator
1. Create iSCSI Target
# yum install scsi-target-utils
# service tgtd start && chkconfig tgtd on
# iscsi --mode target --op new --tid 1 --targetname iqn-2013-3.com.example.master:disk1
Note: Target name is divided as follow
iqn-Year-Month.Reversed FQDN:Target Name
# tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store /dev/sda
# tgtadm --lld iscsi --mode target --op show
2. Security
# tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address 192.168.1.20
# tgtadm --lld iscsi --mode account --op new --user user1 --password 123
# tgtadm --lld iscsi --mode account --op show
# tgtadm --lld iscsi --mode account --op bind --tid 1 --user user1
# tgtadm --lld iscsi --mode target --op show
# iptables -I INPUT -p tcp --dport 3260 -j ACCEPT
3. Save changes permanently
# tgt-admin --dump
backing-store /dev/sda
incominguser user1 PLEASE_CORRECT_THE_PASSWORD
initiator-address 192.168.1.20
# after modifying user's password append this block of configuration at the end of /etc/tgt/targets.conf
# service tgtd restart
# tgt-admin -s # You should see the configuration of the target
# Initiator (Client) Side
# ------------------------------
# yum install iscsi-initiator-utils
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2013-3.com.example.node1:node1
# /etc/init.d/iscsid force-start
# chkconfig iscsid on && chkconfig iscsi on
# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.1.10 --discover # Discover luns in the target server, it takes into consideration Account and ACL information
# vim /var/lib/iscsi/nodes/iqn-2013-3.com.example.master\:disk1/192.168.1.10\,3260\,1/default # Enable CHAP authentication and add ACL information
#node.session.auth.authmethod = None
node.session.auth.authmethod = CHAP
node.session.auth.username = user1
node.session.auth.password = 123
Before Login
# fdisk -l | grep Disk
Disk /dev/vda: 5368 MB, 5368709120 bytes
Disk identifier: 0x00017416
Disk /dev/mapper/vg_master-lv_root: 3766 MB, 3766484992 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_master-lv_swap: 1073 MB, 1073741824 bytes
Disk identifier: 0x00000000
# iscsiadm --mode node --targetname iqn-2013-3.com.example.master:disk1 --portal 192.168.1.10:3260 --login
After Login
# fdisk -l | grep Disk
Disk /dev/vda: 5368 MB, 5368709120 bytes
Disk identifier: 0x00017416
Disk /dev/mapper/vg_master-lv_root: 3766 MB, 3766484992 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_master-lv_swap: 1073 MB, 1073741824 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 2147 MB, 2147483648 bytes # iscsi Target after login
Disk identifier: 0x00000000
# mkdir /data
# vim /etc/fstab
/dev/sda1 /data ext4 defaults,_netdev 0 0
# mount -a
Note:- _netdev delay mounting of the drive after loading networking
No comments:
Post a Comment