CentOS 6.6 安装 iSCSI

一,ISCSI简介

iSCSI,即internet SCSI,又称为IP-SAN,是IETF制订的一项标准,用于将SCSI数据块映射成以太网数据包。iSCSI是一种基于TCP/IP 的协议,用来建立和管理IP存储设备、主机和客户机等之间的相互连接,并创建存储区域网络(SAN)。SAN 使得SCSI 协议应用于高速数据传输网络成为可能,这种传输以数据块级别(block-level)在多个数据存储网络间进行。SCSI 结构基于C/S模式,其通常应用环境是:设备互相靠近,并且这些设备由SCSI 总线连接。

iSCSI 的主要功能是在TCP/IP 网络上的主机系统(启动器 initiator)和存储设备(目标器 target)之间进行大量数据的封装和可靠传输过程。

从根本上说,iSCSI协议是一种跨过IP网络来传输潜伏时间短的SCSI数据块的方法。

完整的iSCSI系统的拓扑结构如下:

与传统的SCSI技术比较起来,iSCSI技术有以下三个革命性的变化:

  1. 把原来只用于本机的SCSI协同透过TCP/IP网络传送,使连接距离可作无限的地域延伸;
  2.  
  3. 连接的服务器数量无限(原来的SCSI-3的上限是15);
  4.  
  5. 由于是服务器架构,因此也可以实现在线扩容以至动态部署。

ISCSI的协议结构:

二,搭建基于 IP SAN 的 ISCSI 存储系统

  1. 规划:
  2.  
  3. 环境: CentOS 6.6 32位
  4.  
  5. 服务器端 IP: 192.168.1.43
  6.  
  7. 客户端 IP : 192.168.1.111
  8.  
  9. 共享磁盘: /dev/sdb

1,配置服务器端

  1. [root@localhost ~]# yum -y install scsi-target-utils #安装服务器端软件
  2.  
  3. [root@node1 iscsi]# rpm -ql scsi-target-utils
  4. /etc/rc.d/init.d/tgtd
  5. /etc/sysconfig/tgtd
  6. /etc/tgt/targets.conf #配置文件
  7. /usr/sbin/tgt-admin
  8. /usr/sbin/tgt-setup-lun
  9. /usr/sbin/tgtadm
  10. /usr/sbin/tgtd
  11. /usr/sbin/tgtimg
  12. /usr/share/doc/scsi-target-utils-1.0.24
  13. /usr/share/doc/scsi-target-utils-1.0.24/README
  14. /usr/share/doc/scsi-target-utils-1.0.24/README.iscsi
  15. /usr/share/doc/scsi-target-utils-1.0.24/README.iser
  16. /usr/share/doc/scsi-target-utils-1.0.24/README.lu_configuration
  17. /usr/share/doc/scsi-target-utils-1.0.24/README.mmc
  18. /usr/share/man/man5/targets.conf.5.gz
  19. /usr/share/man/man8/tgt-admin.8.gz
  20. /usr/share/man/man8/tgt-setup-lun.8.gz
  21. /usr/share/man/man8/tgtadm.8.gz
  22.  
  23. [root@localhost ~]# lsmod |grep scsi
  24. mptscsih 31330 1 mptspi
  25. mptbase 86744 2 mptspi,mptscsih
  26. scsi_transport_spi 19726 1 mptspi #高级驱动程序

iscsi可以使用命令或配置文件进行配置,我们首先使用命令行来进行配置:

  1. [root@node1 iscsi]# service tgtd start
  2. Starting SCSI target daemon: [ OK ]
  3.  
  4. [root@node1 iscsi]# ss -tlnp |grep 3260 #其监听在3260端口
  5. LISTEN 0 128 :::3260 :::* users:((“tgtd”,11882,5),(“tgtd”,11885,5))
  6. LISTEN 0 128 *:3260 *:* users:((“tgtd”,11882,4),(“tgtd”,11885,4))
  7.  
  8. [root@localhost ~]# tgtadm -L iscsi -o new -m target -t 1 -T iqn.2015-08.com.feiyu.testsan:1 #创建一个target,-t指定TID,-T指定名称

iqn表示“ISCSI Qualified Name”,简称iqn。

  1. [root@localhost ~]# tgtadm -L iscsi -o show -m target
  2. Target 1: iqn.2015-08.com.feiyu.testsan:1
  3. System information:
  4. Driver: iscsi
  5. State: ready
  6. I_T nexus information:
  7. LUN information:
  8. LUN: 0
  9. Type: controller
  10. SCSI ID: IET 00010000
  11. SCSI SN: beaf10
  12. Size: 0 MB, Block size: 1
  13. Online: Yes
  14. Removable media: No
  15. Prevent removal: No
  16. Readonly: No
  17. Backing store type: null
  18. Backing store path: None
  19. Backing store flags:
  20. Account information:
  21. ACL information:

然后设定LUN(Logical Unit Number,逻辑单元号),服务器端只需要创建好分区,不需要格式化:

  1. [root@localhost ~]# tgtadm -L iscsi -o new -m logicalunit -t 1 -l 1 -b /dev/sdb5 #创建一个LUN,-m表示模式,-l :LUN ,-b: 设备
  2.  
  3. [root@localhost ~]# tgtadm -L iscsi -o bind -m target -t 1 -I 192.168.0.0/16
  4.  
  5. [root@node1 iscsi]# tgtadm -L iscsi -o show -m target
  6. Target 1: iqn.2015-08.com.feiyu.testsan:1
  7. System information:
  8. Driver: iscsi
  9. State: ready
  10. I_T nexus information:
  11. LUN information:
  12. LUN: 0
  13. Type: controller
  14. SCSI ID: IET 00010000
  15. SCSI SN: beaf10
  16. Size: 0 MB, Block size: 1
  17. Online: Yes
  18. Removable media: No
  19. Prevent removal: No
  20. Readonly: No
  21. Backing store type: null
  22. Backing store path: None
  23. Backing store flags:
  24. LUN: 1
  25. Type: disk
  26. SCSI ID: IET 00010001
  27. SCSI SN: beaf11
  28. Size: 2107 MB, Block size: 512
  29. Online: Yes
  30. Removable media: No
  31. Prevent removal: No
  32. Readonly: No
  33. Backing store type: rdwr
  34. Backing store path: /dev/sdb5
  35. Backing store flags:
  36. Account information:
  37. ACL information:
  38.  
  39. [root@node1 iscsi]# tgtadm -L iscsi -o bind -m target -t 1 -I 192.168.0.0/16 #设定共享区
  40. [root@node1 iscsi]# tgtadm -L iscsi -o show -m target
  41. Target 1: iqn.2015-08.com.feiyu.testsan:1
  42. System information:
  43. Driver: iscsi
  44. State: ready
  45. I_T nexus information:
  46. LUN information:
  47. LUN: 0
  48. Type: controller
  49. SCSI ID: IET 00010000
  50. SCSI SN: beaf10
  51. Size: 0 MB, Block size: 1
  52. Online: Yes
  53. Removable media: No
  54. Prevent removal: No
  55. Readonly: No
  56. Backing store type: null
  57. Backing store path: None
  58. Backing store flags:
  59. LUN: 1
  60. Type: disk
  61. SCSI ID: IET 00010001
  62. SCSI SN: beaf11
  63. Size: 2107 MB, Block size: 512
  64. Online: Yes
  65. Removable media: No
  66. Prevent removal: No
  67. Readonly: No
  68. Backing store type: rdwr
  69. Backing store path: /dev/sda5
  70. Backing store flags:
  71. Account information:
  72. ACL information:
  73. 192.168.0.0/16
  74.  
  75. [root@localhost ~]# tgtadm -L iscsi -o new -m logicalunit -t 1 -l 2 -b /dev/sdb6 #绑定第二个LUN

2,配置客户端

  1. [root@node1 ~]# yum install -y iscsi-initiator-utils #安装客户端
  2.  
  3.  
  4. [root@node1 iscsi]# echo “InitiatorName=`iscsi-iname -p iqn.2013-05.com.feiyu`” > /etc/iscsi/initiatorname.iscsi #生成iqn
  5. [root@node1 iscsi]# echo “InitiatorAlias=initiator1” >> /etc/iscsi/initiatorname.iscsi #定义别名
  6.  
  7. [root@node1 iscsi]# ls
  8. initiatorname.iscsi iscsid.conf
  9. [root@node1 iscsi]# cat initiatorname.iscsi #查看所定义的数据
  10. InitiatorName=iqn.2015-08.com.feiyu:10834bd52221
  11. InitiatorAlias=initiator1
  12.  
  13. [root@node1 ~]# service iscsi start #启动服务,需要启动两个服务
  14. [root@node1 ~]# service iscsid start
  15. [root@node1 ~]# chkconfig iscsi on
  16. [root@node1 ~]# chkconfig iscsid on

若出现以下错误,可能由于服务器端的防火墙没有关!

  1. [root@node1 ~]# iscsiadm -m discovery -t st -p 192.168.1.43
  2. Starting iscsid: [ OK ]
  3. iscsiadm: cannot make connection to 192.168.1.43: No route to host
  4.  
  5. [root@node1 ~]# iscsiadm -m discovery -t st -p 192.168.1.43 #进行探测
  6. 192.168.1.43:3260,1 iqn.2015-08.com.feiyu.testsan:1
  7.  
  8. [root@node1 ~]# iscsiadm -m node -T iqn.2015-08.com.feiyu.testsan:1 -p 192.168.1.43 -l #登录节点
  9. Logging in to [iface: default, target: iqn.2015-08.com.feiyu.testsan:1, portal: 192.168.1.43,3260] (multiple)
  10. Login to [iface: default, target: iqn.2015-08.com.feiyu.testsan:1, portal: 192.168.1.43,3260] successful.
  11.  
  12. [root@node1 ~]# fdisk -l #登录成功可以看到多了一块硬盘,
  13.  
  14. Disk /dev/sda: 21.5 GB, 21474836480 bytes
  15. 255 heads, 63 sectors/track, 2610 cylinders
  16. Units = cylinders of 16065 * 512 = 8225280 bytes
  17. Sector size (logical/physical): 512 bytes / 512 bytes
  18. I/O size (minimum/optimal): 512 bytes / 512 bytes
  19. Disk identifier: 0x0006d052
  20.  
  21. Device Boot Start End Blocks Id System
  22. /dev/sda1 * 1 39 307200 83 Linux
  23. Partition 1 does not end on cylinder boundary.
  24. /dev/sda2 39 2354 18598912 83 Linux
  25. /dev/sda3 2354 2610 2057689 5 Extended
  26. /dev/sda5 2354 2610 2057657+ 83 Linux
  27.  
  28. Disk /dev/sdc: 10.7 GB, 10742183424 bytes ——-> iscsi设备
  29. 64 heads, 32 sectors/track, 10244 cylinders
  30. Units = cylinders of 2048 * 512 = 1048576 bytes
  31. Sector size (logical/physical): 512 bytes / 512 bytes
  32. I/O size (minimum/optimal): 512 bytes / 512 bytes
  33. Disk identifier: 0x00000000

为磁盘创建分区并格式化。

  1. [root@node1 ~]# mke2fs -t ext4 /dev/sdc1

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/223305.html<

(0)
运维的头像运维
上一篇2025-04-15 21:52
下一篇 2025-04-15 21:53

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注