• 转:iSCSI Target & Initiator in RHEL 5.3


    简介:
    RHEL 5.3 开始,提供了编译好的 iscsi target 。
    这里转载一篇相关的文章,原文由两个部分组成,分别介绍 target 和 Initiator, 这里将两篇合二为一。

    Orignal Site: http://pbraun.nethence.com 


    iSCSI targets

    Introduction
    The target name may be forged like e.g.,
    iqn.2010-07.net.example:disk50gb
    Note. lowcase characters only, otherwise some initiators won't accept it (namely Microsoft iSCSI initiator).
    TGT iSCSI target (since RHEL 5.3)
    Install TGT,
    yum install scsi-target-utils
    Make sure you've got a LV or an disk to share,
    fdisk -l
    Start and enable the daemon at boot time,
    /etc/init.d/tgtd start
    chkconfig tgtd on
    create the target and define its name,
    tgtadm --lld iscsi --mode target --op new --tid=1 --targetname iqn.2010-07.net.example:disk50gb
    note. id must not be zero
    add a LUN to the target,
    tgtadm --lld iscsi --mode logicalunit --op new --tid=1 --lun=1 --backing-store=/dev/sdb
    note. lun >=1
    note. it's also possible to use a vdisk file instead of /dev/sdb
    enable the target to accept any initiators,
    tgtadm --lld iscsi --mode target --op bind --tid=1 -I ALL
    check port 3260,
    netstat -apne | grep 3260
    #lsof -i:3260
    Note. to check for targets, luns, and connected initiators,
    tgtadm --lld iscsi --mode target --op show
    Note. to delete a LUN,
    tgtadm --lld iscsi --mode logicalunit --op delete --tid=1 --lun=1
    Note. to delete a target,
    tgtadm --lld iscsi --mode target --op delete --tid=1
    IET iSCSI target
    Get IET (iscsitarget.sourceforge.net/) and install it from source,
    yum install kernel-devel openssl-devel gcc
    tar xvzf iscsitarget-0.4.17.tar.gz
    cd iscsitarget-0.4.17
    make
    make install
    Make sure you've got a LV or an disk to share,
    fdisk -l
    Configure the LUNs,
    vi /etc/ietd.conf
    like,
    Target iqn.2009-05.net.example:vdisk20gb
    Lun 0 Path=/dev/sdb,Type=blockio
    MaxConnections 2
    InitialR2T No
    ImmediateData Yes
    Note. MaxConnections' default is 1...
    Note. "/dev/sdb" here
    Note. "vdisk20gb" as an example here, needs to be a unique string.
    Authorize all clients,
    vi /etc/initiators.allow
    like,
    iqn.2009-05.net.example:vdisk20gb ALL
    Launch the daemon and activate on boot,
    service iscsi-target start
    chkconfig iscsi-target on
    Check the service is running,
    ps aux | grep ietd
    Check for exported LUNs,
    cat /proc/net/iet/volume
    NetBSD iSCSI target
    As an alternative, there's also NetBSD's iSCSI target software.
    Get the RPM from EPEL (fedoraproject.org/wiki/EPEL) and install it,
    rpm -ivh netbsd-iscsi-20071205-1.el5.i386.rpm
    Check how much bytes you have to export,
    fdisk -l /dev/sdb
    Substract one byte to define the export length thereafter.
    Configure the target,
    vi /etc/iscsi/targets
    like,
    ## extent file or device start length
    extent0 /dev/sdb 0 62277025791
    # target flags storage netmask
    target0 rw extent0 10.1.1.0/24
    Start the daemon,
    /usr/sbin/iscsi-target
    References
    Linux SCSI target framework (tgt) project : stgt.berlios.de/
    tgtadm(8) - Linux man page : linux.die.net/man/8/tgtadm
    The iSCSI Enterprise Target Project : iscsitarget.sourceforge.net/
    How to setup an iSCSI target using tgtadm in Red Hat Enterprise Linux 5 : kbase.redhat.com/faq/docs/DOC-15154
    iSCSI target HowTo on Enterprise Linux (RHEL4) : mail.digicola.com/wiki/index.php?title=User:Martin:iSCSI
    Linux iscsitarget+tools : www3.amherst.edu/~swplotner/iscsitarget/
    Additional references

    iSCSI initiators


    Introduction
    If using an STGT on the target side, you will see a weired LUN0 on the initiator. Just discard it and on Windows, just don't configure any driver for it (lists.wpkg.org/pipermail/stgt/2009-February/002633.html).
    RHEL4/5 configuration
    Install the iscsi initiator RPM,
    yum install iscsi-initiator-utils
    Note. although the package name is identical on RHEL4/5, it's different :
    - configuration file and paths
    - rhel5 has 'iscsi' and 'iscsid' init scripts
    - rhel4 only has 'iscsi' init script
    RHEL5
    On RHEL5,
    cd /etc/iscsi
    mv iscsid.conf iscsid.conf.dist
    sed -e '
    /^[[:space:]]*$/d;
    /^[[:space:]]*#/d;
    ' iscsid.conf.dist > iscsid.conf
    Note. the default config is fine for dedicated VLANs but if you need CHAP authentication add,
    node.session.auth.authmethod = CHAP
    node.session.auth.username = USERNAME
    node.session.auth.password = PASSWORD
    discovery.sendtargets.auth.authmethod = CHAP
    discovery.sendtargets.auth.username = USERNAME
    discovery.sendtargets.auth.password = PASSWORD
    Enable the iscsi daemon,
    service iscsid start
    chkconfig iscsid on
    Note. we'll activate /etc/init.d/iscsi (to log into targets automaticly) later on
    RHEL4
    On RHEL4,
    cd /etc
    mv iscsi.conf iscsi.conf.dist
    vi iscsi.conf
    like,
    DiscoveryAddress=ISCSI_SERVER
    # OutgoingUserName=USERNAME
    # OutgoingPassword=PASSWORD
    LoginTimeout=15
    fix the perm,
    chmod 600 iscsi.conf
    Enable the iscsi daemon,
    service iscsi start
    chkconfig iscsi on
    RHEL4/5 finish up
    Check the iSCSI target is available on the network,
    telnet ISCSI_TARGET 3260
    Discover and login to all available targets,
    iscsiadm -m discovery -t st -p ISCSI_TARGET
    Note. for a specific interface e.g. 'bond0' for trunking, add '-I bond0'
    Note. eventually add "-d" to the iscsiadm command for debugging
    Note. login to a precise LUN,
    iscsiadm -m node -L automatic
    #iscsiadm -m node -T iqn.2010-07.net.example:disk50gb -p ISCSI_TARGET
    Show current records and sessions,
    iscsiadm -m node
    iscsiadm -m session
    Ready to go ! Check for new disks,
    cat /proc/scsi/scsi
    fdisk -l
    Note. to logout all sessions,
    iscsiadm -m node -U all
    Log again to the target but with the init script, and enable it for boot time,
    service iscsi start
    chkconfig iscsi on
    Note. don't restart that daemon ! It would change the device name until next reboot (for example, sdc would become sdd instantly...)
    RHEL4/5 troubbleshooting
    If you experience this error when shutting down the system,
    Synchronizing SCSI cache for disk sdb
    it's simply becuase the iscsi disk hasn't been removed. Enable the iscsi (beside iscsid) daemon to unlog from the target before completely shutting down the system.
    Microsoft iSCSI Software Initiator
    Discover the target,
    Discovery tab > Add
    then
    IP address or DNS name : ...
    proceed,
    Targets tab > select a target > Log On...
    To log off,
    Targets tab > select a target > Details
    then,
    Sessions tab > check a target > Log off...
    and unconfigure a target,
    Discovery tab > select a target portal > Remove
    StarWind Software Starport
    Instead of "Microsoft iSCSI Software Initiator" (www.microsoft.com/downloads/) you may use StarWind Software's one : StarPort (www.starwindsoftware.com/starport-free).
    Get StarPort and the Personal Free License .spk file. Install it and put the .spk file inside the installation directory,
    C:\Program Files\StarWind Software\StarPort
    note. the program won't start if the .spk file isn't there.
    start the program and register with that licence,
    Help > Register Startport...
    then in the Registration window,
    Load from file > C:\Program Files\StarWind Software\StarPort\StarPort_Free_Personal_License_1978.spk
    click "Register"
    Add a iSCSI disk,
    right click on "Remote iSCSI devices" > Add device
    then into the Wizard,
    Remote iSCSI device IP Address or Machine Name : ISCSI_SERVER
    Remote iSCSI device Port number : 3260
    select a target
    keep "Automount this device" box checked
    To log off,
    right click on an iSCSI disk > Remove device
    References
    ISCSI and XEN Server Storage Repository issue : forums.openfiler.com/viewtopic.php?id=2280
  • 相关阅读:
    网络状态码含义——(比如204,304, 404, 504,502)
    Vue两个简易代替vuex的方法(eventBus,observable)
    单页面首屏加载慢解决方案
    前端监控和前端埋点
    ES5 和 ES6的继承
    mysql 隔离级别
    mysql 事务
    Seata
    Sentinel Dashboard 部署
    java 垃圾回器
  • 原文地址:https://www.cnblogs.com/jjkv3/p/2773156.html
Copyright © 2020-2023  润新知