Bài 8: Cấu hình Storage Server trên CentOS 6

1.Cấu hình  lưu trữ  với  iSCSI. cấu hình lưu trữ mạng trên server gọi là  iSCSI Target, một client kết nối tới   iSCSI Target gọi là  iSCSI Initiator.

bên dưới là ví dụ về cấu hình iSCSI

dlp.server.world
[10.0.0.30] – iSCSI Target
www.server.world
[10.0.0.31] – iSCSI Initiator
ví dụ trên hướng dẫn cấu hình  LVM partition trên iSCSI Target,

Tìm hiểu thêm về iSCSI

[1] Cấu hình  iSCSI Target
#  tạo ổ cứng vật lý

[root@dlp ~]# pvcreate /dev/sdb1

  Physical volume “/dev/sdb1” successfully created
# tạo ổ cứng vật lý tên là “vg_target00”

[root@dlp ~]#vgcreate -s 32M vg_target00 /dev/sdb1

  Volume group “vg_target00” successfully created
# tạo ổ cứng vật lý tên là  “lv_target00”

[root@dlp ~]#lvcreate -L 100G -n lv_target00 vg_target00

  Logical volume “lv_target00” created

[root@dlp ~]#yum -y install scsi-target-utils

[root@dlp ~]#vi /etc/tgt/targets.conf

# add at the last
# if you set some devices, add <target>-</target> and set the same way with follows
# naming rule : [ iqn.yaer-month.domain:any name ]

<target iqn.2011-07.world.server:target0>

# provided devicce as a iSCSI target

backing-store /dev/vg_target00/lv_target00

# iSCSI Initiator’s IP address you allow to connect

initiator-address 10.0.0.31

# authentication info ( set anyone you like for “username”, “password” )

incominguser username password

</target>

[root@dlp ~]#/etc/rc.d/init.d/tgtd start

Starting SCSI target daemon:[ OK ]

[root@dlp ~]#chkconfig tgtd on

[root@dlp ~]#tgtadm –mode target –op show

# confirm status
Target 1: iqn.2011-07.world.server:target0
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store type: rdwr
            Backing store path: None
    Account information:
        username
    ACL information:
        10.0.0.31

2.cấu hình  iSCSI Initiator

dlp.server.world
[10.0.0.30] – iSCSI Target
www.server.world
[10.0.0.31] – iSCSI Initiator
[1] Cấu hình iSCSI Initiator

[root@www ~]#yum -y install iscsi-initiator-utils

[root@www ~]#vi /etc/iscsi/iscsid.conf

# line 49: uncomment

node.session.auth.authmethod = CHAP

# line 53,54: uncomment and set username and password which set on iSCSI Target

node.session.auth.username =username

node.session.auth.password =password

# discover target

[root@www ~]#iscsiadm -m discovery -t sendtargets -p 10.0.0.30

Starting iscsid: Loading iSCSI transport class v2.0-870.
iscsi: registered transport (tcp)
iscsi: registered transport (iser)
cxgb3i: tag itt 0x1fff, 13 bits, age 0xf, 4 bits.
iscsi: registered transport (cxgb3i)
cnic: Broadcom NetXtreme II CNIC Driver cnic v2.1.2 (May 26, 2010)
Broadcom NetXtreme II iSCSI Driver bnx2i v2.1.1 (Mar 24, 2010)
iscsi: registered transport (bnx2i)
iscsi: registered transport (be2iscsi)
[ OK ]
10.0.0.30:3260,1 iqn.2011-07.world.server:target0

[root@www ~]#chkconfig iscsi on

[root@www ~]#chkconfig iscsid on

# confirm status after discovery

[root@www ~]#iscsiadm -m node -o show

# BEGIN RECORD 2.0-872
node.name = iqn.2011-07.world.server:target0
node.tpgt = 1
node.startup = automatic
iface.hwaddress = <empty>
iface.ipaddress = <empty>
iface.iscsi_ifacename = default
iface.net_ifacename = <empty>
iface.transport_name = tcp
iface.initiatorname = <empty>
node.discovery_address = 10.0.0.30
node.discovery_port = 3260
node.discovery_type = send_targets
node.session.initial_cmdsn = 0
node.session.initial_login_retry_max = 8
node.session.xmit_thread_priority = -20
node.session.cmds_max = 128
node.session.queue_depth = 32
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = ********
node.session.auth.username_in = <empty>
node.session.auth.password_in = <empty>
node.session.timeo.replacement_timeout = 120
node.session.err_timeo.abort_timeout = 15
node.session.err_timeo.lu_reset_timeout = 30
node.session.err_timeo.tgt_reset_timeout = 30
node.session.err_timeo.host_reset_timeout = 60
node.session.iscsi.FastAbort = Yes
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.session.iscsi.DefaultTime2Retain = 0
node.session.iscsi.DefaultTime2Wait = 2
node.session.iscsi.MaxConnections = 1
node.session.iscsi.MaxOutstandingR2T = 1
node.session.iscsi.ERL = 0
node.conn[0].address = 10.0.0.30
node.conn[0].port = 3260
node.conn[0].startup = manual
node.conn[0].tcp.window_size = 524288
node.conn[0].tcp.type_of_service = 0
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.auth_timeout = 45
node.conn[0].timeo.noop_out_interval = 5
node.conn[0].timeo.noop_out_timeout = 5
node.conn[0].iscsi.MaxXmitDataSegmentLength = 0
node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144
node.conn[0].iscsi.HeaderDigest = None
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD
# login to target

[root@www ~]#iscsiadm -m node –login

Logging in to [iface: default, target: iqn.2011-07.world.server:target0, portal: 10.0.0.30,3260]
scsi2 : iSCSI Initiator over TCP/IP
scsi 2:0:0:0: RAID IET Controller 0001 PQ: 0 ANSI: 5
scsi 2:0:0:1: Direct-Access IET VIRTUAL-DISK 0001 PQ: 0 ANSI: 5
Login to [iface: default, target: iqn.2011-07.world.server:target0, portal: 10.0.0.30,3260] successful.
# confirm session

[root@www ~]#iscsiadm -m session -o show

tcp: [1] 10.0.0.30:3260,1 iqn.2011-07.world.server:target0
# confirm partitions

[root@www ~]#cat /proc/partitions

major minor #blocks name

8      0      31457280      sda

8      1      512000         sda1

8      2      30944256      sda2

253   0      20971520     dm-0

253   1      6160384       dm-1

253   2      3809280       dm-2

8      0       104857600    sdb

8      1       104857600    sdb1

# added new device provided from target
# config for auto-mount when booting

[root@www ~]#vi /etc/fstab

/dev/mapper/VolGroup-lv_root /                      ext4    defaults        1 1
UUID=3d3f19a1-582f-4a29-a304-349750094b2c /boot     ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                   swap    defaults        0 0
tmpfs                       /dev/shm                tmpfs   defaults        0 0
devpts                      /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                       /sys                    sysfs   defaults        0 0
proc                        /proc                   proc    defaults        0 0
# add iSCSI filesystem
/dev/sdb1                   /var/kvm                ext4    _netdev         0 0

[root@www ~]#chkconfig netfs on