设为首页 收藏本站
查看: 2614|回复: 0

[经验分享] centos 6.8 linux iscsi服务器配置和客户端连接iscsi

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-8-19 09:22:02 | 显示全部楼层 |阅读模式
centos 6.8 linux  iscsi服务器配置和客户端连接iscsi

一、服务端配置
1、首先安装各种包
yum search scsi

iscsi-initiator-utils.x86_64 : iSCSI daemon and utility programs
iscsi-initiator-utils-devel.x86_64 : Development files for iscsi-initiator-utils
lsscsi.x86_64 : List SCSI devices (or hosts) and associated information
scsi-target-utils.x86_64 : The SCSI target daemon and utility programs
libhbalinux.i686 : FC-HBAAPI implementation using scsi_transport_fc interfaces
libhbalinux.x86_64 : FC-HBAAPI implementation using scsi_transport_fc interfaces
mtx.x86_64 : SCSI media changer control program
python-rtslib.noarch : API for RisingTide Systems generic SCSI target
sdparm.x86_64 : List or change SCSI/SATA disk parameters
sg3_utils.x86_64 : Utilities for devices that use SCSI command sets


执行 yum install -y scsi-target-utils.x86_64 iscsi-initiator-utils.x86_64 iscsi-initiator-utils-devel.x86_64
其实多装点也没有坏处

本机分了100G,在装系统的时候分了20G,剩余80G没用

2、建立分区

fdisk /dev/sda  
我这里建个三个    //建分区步骤略过
分区建立完毕  一定要 执行 partprobe  命令,写进内核
[iyunv@storage 1]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000af23c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2611    20971520   83  Linux
/dev/sda2            2611        3916    10482726   83  Linux
/dev/sda3            3917        6528    20980890   83  Linux
/dev/sda4            6529       13054    52420095   83  Linux

3.配置tgtd
vi /etc/tgt/targets.conf
在末尾加上如下配置

<target iqn.2008-09.com.example:server.target4>
    direct-store /dev/sda2     # Becomes LUN 1
    direct-store /dev/sda3      # Becomes LUN 2
    direct-store /dev/sda4      # Becomes LUN 3
     initiator-address 10.0.1.2     //允许连接的ip地址
     initiator-address 10.0.1.3
    write-cache off
</target>
配置完毕,启动服务

service tgtd start
chkconfig tgtd on
查看target状态

[iyunv@storage ~]# tgt-admin --show
Target 1: iqn.2008-09.com.example:server.target4
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
        I_T nexus: 1
            Initiator: iqn.1994-05.com.redhat:74bc8f791621
            Connection: 0
                IP Address: 10.0.1.3
        I_T nexus: 2
            Initiator: iqn.1994-05.com.redhat:9695b6e4df6f
            Connection: 0
                IP Address: 10.0.1.2
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 10734 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sda2
            Backing store flags:
        LUN: 2
            Type: disk
            SCSI ID: IET     00010002
            SCSI SN: beaf12
            Size: 21484 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sda3
            Backing store flags:
        LUN: 3
            Type: disk
            SCSI ID: IET     00010003
            SCSI SN: beaf13
            Size: 53678 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sda4
            Backing store flags:
    Account information:
    ACL information:
        10.0.1.2
        10.0.1.3
二、客户端配置

  • 安装软件包
    yum install -y iscsi-initiator-utils.x86_64 iscsi-initiator-utils-devel.x86_64

    service iscsid restart

  chkconfig iscsid on
2.查找发现网络中的存储
[iyunv@webdb1 ~]# iscsiadm -m discovery -t node
10.0.1.1:3260 via sendtargets
192.168.1.141:3260 via sendtargets
192.168.10.100:3260 via sendtargets
192.168.10.100:3205 via sendtargets
10.0.1.1:3205 via sendtargets
3.连接iscsi
iscsiadm -m node  //发现节点

[iyunv@webdb1 ~]#  iscsiadm -m node
10.0.1.1:3260,1 iqn.2008-09.com.example:server.target4
192.168.1.141:3260,1 iqn.2008-09.com.example:server.target4

iscsiadm -m discovery -t st -p 10.0.1.1:3260 //连接上
iscsiadm -m node -T iqn.2008-09.com.example:server.target4 -p 10.0.1.1 -l
登录完成
执行fdisk 查看是否成功连接

[iyunv@webdb1 ~]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000af23c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2611    20971520   83  Linux

Disk /dev/sdb: 10.7 GB, 10734311424 bytes
64 heads, 32 sectors/track, 10237 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: 0x00000000


Disk /dev/sdd: 53.7 GB, 53678177280 bytes
64 heads, 32 sectors/track, 51191 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: 0x00000000


Disk /dev/sdc: 21.5 GB, 21484431360 bytes
64 heads, 32 sectors/track, 20489 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: 0x00000000

已经成功连接。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-259844-1-1.html 上篇帖子: linux下高可用集群之RHCS详解 下篇帖子: rsync + sersync2进行实时同步数据 服务器 linux 客户端
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表