Chinaunix首页 | 论坛 | 博客
  • 博客访问: 137344
  • 博文数量: 25
  • 博客积分: 389
  • 博客等级: 一等列兵
  • 技术积分: 838
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-23 14:18
文章存档

2013年(20)

2012年(5)

分类: 服务器与存储

2013-03-09 13:18:32

iSCSI存储服务配置实现过程:
拓扑图:

 
服务器端配置
  1. 1)准备要共享的设备,这里使用本地磁盘上的新分区/dev/sda5
  2. # fdisk /dev/sda
  3. # partprobe /dev/sda
  4. 注意这里不要对新建分区进行格式化操作
  5. 2)安装iscsi服务端
  6. 用到的安装包有
  7. openib-1.4.1-6.el5.noarch.rpm scsi-target-utils-1.0.14-2.el5.i386.rpm libibverbs-1.1.3-2.el5.i386.rpm librdmacm-1.0.10-1.el5.i386.rpm libnes-0.9.0-2.el5.i386.rpm perl-Config-General-2.40-1.el5.noarch.rpm
  8. 配置好yum源然后安装scsi-target-utils
  9. # yum -y install scsi-target-utils
  10. 启动tgtd服务
  11. # service tgtd start
  12. # netstat –tnlp //确保3260端口已经打开//
  13. # chkconfig tgtd on //开机自动启动//
  14. 添加target
  15. # tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-08.com.wjw.target:dis1
  16. 查看创建的target
  17. # tgtadm --lld iscsi --op show --mode target
  18. Target 1: iqn.2012-08.com.wjw.target:dis1
  19.     System information:
  20.         Driver: iscsi
  21.         State: ready
  22.     I_T nexus information:
  23.     LUN information:
  24.         LUN: 0
  25.             Type: controller
  26.             SCSI ID: IET 00010000
  27.             SCSI SN: beaf10
  28.             Size: 0 MB, Block size: 1
  29.             Online: Yes
  30.             Removable media: No
  31.             Readonly: No
  32.             Backing store type: null
  33.             Backing store path: None
  34.             Backing store flags:
  35.     Account information:
  36. ACL information:
  37. target添加成功
  38. 添加LUN
  39. # tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sda5
  40. 查看一下
  41. # tgtadm --lld iscsi --op show --mode target
  42. Target 1: iqn.2012-08.com.wjw.target:dis1
  43.     System information:
  44.         Driver: iscsi
  45.         State: ready
  46.     I_T nexus information:
  47.     LUN information:
  48.         LUN: 0
  49.             Type: controller
  50.             SCSI ID: IET 00010000
  51.             SCSI SN: beaf10
  52.             Size: 0 MB, Block size: 1
  53.             Online: Yes
  54.             Removable media: 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: 419 MB, Block size: 512
  64.             Online: Yes
  65.             Removable media: No
  66.             Readonly: No
  67.             Backing store type: rdwr
  68.             Backing store path: /dev/sda5
  69.             Backing store flags:
  70.     Account information:
  71. ACL information:
  72. LUN添加成功
  73. 添加访问控制列表,开放给172.16.0.0/16网络中的主机访问
  74. # tgtadm --lld iscsi --op bind --mode target --tid 1 -I 172.16.0.0/16
  75. 查看一下
  76. # tgtadm --lld iscsi --op show --mode target
  77. Target 1: iqn.2012-08.com.wjw.target:dis1
  78.     System information:
  79.         Driver: iscsi
  80.         State: ready
  81.     I_T nexus information:
  82.     LUN information:
  83.         LUN: 0
  84.             Type: controller
  85.             SCSI ID: IET 00010000
  86.             SCSI SN: beaf10
  87.             Size: 0 MB, Block size: 1
  88.             Online: Yes
  89.             Removable media: No
  90.             Readonly: No
  91.             Backing store type: null
  92.             Backing store path: None
  93.             Backing store flags:
  94.         LUN: 1
  95.             Type: disk
  96.             SCSI ID: IET 00010001
  97.             SCSI SN: beaf11
  98.             Size: 419 MB, Block size: 512
  99.             Online: Yes
  100.             Removable media: No
  101.             Readonly: No
  102.             Backing store type: rdwr
  103.             Backing store path: /dev/sda5
  104.             Backing store flags:
  105.     Account information:
  106.     ACL information:
  107.         172.16.0.0/16 //访问控制列表已经添加成功//  
客户端1和客户端2配置
  1. 客户端已经默认安装过iscsi-initiator-utils
  2. 启动iscsi服务并使其开机自动启动
  3. # service iscsi start
  4. # chkconfig iscsi on
  5. 为了方便演示,这里为客户端1和客户端2的initiatorname添加别名;
  6. # vim /etc/iscsi/initiatorname.iscsi
  7. 客户端1添加如下行
  8. InitiatorAlias=initiator1
  9. 客户端2添加如下行
  10. InitiatorAlias=initiator1
  11. 配置客户端发现服务端共享target然后连接到本地上来
  12. # iscsiadm -m discovery -t sendtargets -p 172.16.11.12
  13. 172.16.11.12:3260,1 iqn.2012-08.com.wjw.target:dis1
  14. 查看/var/lib/iscsi/send_targets/172.16.11.12,3260/目录下信息
  15. # ls /var/lib/iscsi/send_targets/172.16.11.12,3260/
  16. iqn.2012-08.com.wjw.target:dis1,172.16.11.12,3260,1,default st_config //表明客户端已经成功发现服务端共享target并连接到本地上来了;
  17. 登录到服务端的target上
  18. # iscsiadm -m node -T iqn.2012-08.com.wjw.target:dis1 -p 172.16.11.12:3260 -l
  19. Logging in to [iface: default, target: iqn.2012-08.com.wjw.target:dis1, portal: 172.16.11.12,3260] (multiple)
  20. Login to [iface: default, target: iqn.2012-08.com.wjw.target:dis1, portal: 172.16.11.12,3260] successful. //登录成功//
  21. 查看磁盘设备
  22. # fdisk -l
  23.  
  24. Disk /dev/sda: 343.5 GB, 343597383680 bytes
  25. 255 heads, 63 sectors/track, 41773 cylinders
  26. Units = cylinders of 16065 * 512 = 8225280 bytes
  27.  
  28.    Device Boot Start End Blocks Id System
  29. /dev/sda1 * 1 13 104391 83 Linux
  30. /dev/sda2 14 5235 41945715 8e Linux LVM
  31. /dev/sda3 5236 5366 1052257+ 82 Linux swap / Solaris
  32.  
  33. Disk /dev/sdb: 419 MB, 419457024 bytes
  34. 13 heads, 62 sectors/track, 1016 cylinders
  35. Units = cylinders of 806 * 512 = 412672 bytes
  36.  
  37. Disk /dev/sdb doesn't contain a valid partition table //此时服务端的/dev/sda5分区已被客户端识别为了一块磁盘,可以对该磁盘进行分区格式化了;
  38. 在客户端1上对磁盘分区并格式化,创建一个/dev/sdb1分区
  39. # fdisk /dev/sdb
  40. # partprobe /dev/sdb
  41. # mke2fs -j /dev/sdb1
  42. 挂载/dev/sdb1至本地/mnt目录下
  43. # mount /dev/sdb1 /mnt
  44. # ls /mnt/
  45. lost+found //挂载成功//
  46. 复制/etc/fstab文件至/mnt目录下
  47. # cp /etc/fstab /mnt/
  48. # ls /mnt/
  49. fstab lost+found
  50. 通过客户端2来访问一下/dev/sdb1中的数据
  51. 挂载磁盘分区/dev/sdb1至本地/mnt目录
  52. # mount /dev/sdb1 /mnt
  53. # ls /mnt/
  54. lost+found //挂载成功//
  55. # ls /mnt/
  56. fstab lost+found
  57. 由此可见客户端1和2能同时共用服务端的iSCSI存储设备了;  
      以上就是iSCSI存储服务配置实现过程,后续更多内容将会持续添加,有好知识希望与大家共同分享。
阅读(1804) | 评论(1) | 转发(2) |
给主人留下些什么吧!~~

不吹牛会死啊2013-10-11 15:12:58

挺详细的,学习学习,那么是linux server+windows client  呢