博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ISCSI共享存储配置跟parted命令简述
阅读量:6250 次
发布时间:2019-06-22

本文共 9253 字,大约阅读时间需要 30 分钟。

ISCSI 术语
IQN: ISCSI合格名称,格式:iqn.YYYY-MM.com.clovem.www:stro_name              ==>主机名倒着写
Target:ISCSI存储服务器
Initiator:使用Target的节点,前端节点
Node:ISCSI存储服务器或者前端节点
Portal:ISCSI的访问入口,ISCSI存储的端口

ISCSI Target: node4

1.安装scsi-target-utils  //服务端程序

[root@node4 ~]# yum  install scsi-target-utils -y[root@node4 ~]# vgs  VG    #PV #LV #SN Attr   VSize VFree  vgsrv   1   3   0 wz--n- 8.78g 4.69g[root@node4 ~]# lvcreate  -L 1GB  -n  lv0   vgsrv  Logical volume "lv0" created[root@node4 ~]# lvs  LV   VG    Attr   LSize   Origin Snap%  Move Log Copy%  Convert  home vgsrv -wi-ao 256.00m                                      lv0  vgsrv -wi-a-   1.00g                                      root vgsrv -wi-ao   3.31g                                      swap vgsrv -wi-ao 544.00m                                    [root@node4 ~]# ls /dev/vgsrv/lv0/dev/vgsrv/lv0

2.编辑 /etc/tgt/targets.conf,复制38-40行,粘贴如下

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

backing-store /dev/vgsrv/lv0

3. 启动tgtd服务,查看设备是否被导出

[root@node4 ~]# service tgtd startStarting SCSI target daemon:                               [  OK  ][root@node4 ~]# tgt-admin  --showTarget 1: iqn.2013-05.com.clovem:target1    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, Block size: 1            Online: Yes            Removable media: 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: 1074 MB, Block size: 512            Online: Yes            Removable media: No            Readonly: No            Backing store type: rdwr            Backing store path: /dev/vgsrv/lv0            Backing store flags:    Account information:    ACL information:        ALL

4.查看Target1后面的LUN:1是我们导出的设备:/dev/vgsrv/lv0

ISCSI Initiator:desktop26

[root@desktop26 ~]# rpm -q iscsi-initiator-utilsiscsi-initiator-utils-6.2.0.872-34.el6.x86_64[root@desktop26 ~]# which iscsiadm/sbin/iscsiadm

1.启用发现并登录

[root@desktop26 ~]# ls /dev/sd*/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3[root@desktop26 ~]# iscsiadm  -m discovery -t sendtargets  -p 172.18.26.4:3260172.18.26.4:3260,1 iqn.2013-05.com.clovem:target1[root@desktop26 ~]# iscsiadm  -m node -T iqn.2013-05.com.clovem:target1 -lLogging in to [iface: default, target: iqn.2013-05.com.clovem:target1, portal: 172.18.26.4,3260] (multiple)Login to [iface: default, target: iqn.2013-05.com.clovem:target1, portal: 172.18.26.4,3260] successful.[root@desktop26 ~]# ls /dev/sd*/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb[root@desktop26 ~]# ls /dev/disk/by-path/ip-172.18.26.4:3260-iscsi-iqn.2013-05.com.clovem:target1-lun-1  pci-0000:00:07.1-scsi-1:0:1:0-part1pci-0000:00:07.1-scsi-1:0:0:0                                   pci-0000:00:07.1-scsi-1:0:1:0-part2pci-0000:00:07.1-scsi-1:0:1:0                                   pci-0000:00:07.1-scsi-1:0:1:0-part3

2. 通过iscsiadm命令查看是否导入成功

[root@desktop26 ~]# iscsiadm  -m session  -P1Target: iqn.2013-05.com.clovem:target1    Current Portal: 172.18.26.4:3260,1    Persistent Portal: 172.18.26.4:3260,1        **********        Interface:        **********        Iface Name: default        Iface Transport: tcp        Iface Initiatorname: iqn.1994-05.com.redhat:59585542a2c        Iface IPaddress: 172.18.26.254        Iface HWaddress: 
Iface Netdev:
SID: 2 iSCSI Connection State: LOGGED IN iSCSI Session State: LOGGED_IN Internal iscsid Session State: NO CHANGE

3.修改Initiator端名,尽量做在发现跟登入前

[root@desktop26 ~]# cat /etc/iscsi/initiatorname.iscsiInitiatorName=iqn.2013-05.com.clovem:node1[root@desktop26 ~]# iscsiadm  -m node -T iqn.2013-05.com.clovem:target1 -uLogging out of session [sid: 10, target: iqn.2013-05.com.clovem:target1, portal: 172.18.26.4,3260]Logout of [sid: 10, target: iqn.2013-05.com.clovem:target1, portal: 172.18.26.4,3260] successful.[root@desktop26 ~]# service iscsid stopStopping iscsid:[root@desktop26 ~]# iscsiadm  -m discovery -t sendtargets  -p 172.18.26.4:3260Starting iscsid:                                           [  OK  ]172.18.26.4:3260,1 iqn.2013-05.com.clovem:target1[root@desktop26 ~]# iscsiadm  -m node -T iqn.2013-05.com.clovem:target1 -lLogging in to [iface: default, target: iqn.2013-05.com.clovem:target1, portal: 172.18.26.4,3260] (multiple)Login to [iface: default, target: iqn.2013-05.com.clovem:target1, portal: 172.18.26.4,3260] successful.[root@desktop26 ~]# iscsiadm  -m session -P1Target: iqn.2013-05.com.clovem:target1    Current Portal: 172.18.26.4:3260,1    Persistent Portal: 172.18.26.4:3260,1        **********        Interface:        **********        Iface Name: default        Iface Transport: tcp        Iface Initiatorname: iqn.2013-05.com.clovem:node1        Iface IPaddress: 172.18.26.254        Iface HWaddress: 
Iface Netdev:
SID: 11 iSCSI Connection State: LOGGED IN iSCSI Session State: LOGGED_IN Internal iscsid Session State: NO CHANGE

现在可以看到Iface Initiatorname: iqn.2013-05.com.clovem:node1 ,修改成功,一般情况下面在导入设备之前就修改客户端设备名。


回到node4中查看状态,可以看到客户端设备名了

[root@node4 ~]# tgt-admin  --showTarget 1: iqn.2013-05.com.clovem:target1    System information:        Driver: iscsi        State: ready    I_T nexus information:        I_T nexus: 11            Initiator: iqn.2013-05.com.clovem:node1            Connection: 0                IP Address: 172.18.26.254    LUN information:        LUN: 0            Type: controller            SCSI ID: IET     00010000            SCSI SN: beaf10            Size: 0 MB, Block size: 1            Online: Yes            Removable media: 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: 1074 MB, Block size: 512            Online: Yes            Removable media: No            Readonly: No            Backing store type: rdwr            Backing store path: /dev/vgsrv/lv0            Backing store flags:    Account information:    ACL information:        ALL

定义服务端导出设备属性以及访问控制,修改/etc/tgt/target.conf

< backing-store /dev/vgsrv/lv0> vendor-id clovemfong, Inc. scsi_id target1 scsi_sn s01 initiator-address 172.18.26.254

重新加载配置文件:service tgtd force-reload //由于当前有客户端登入,需要强制重载配置文

[root@node4 ~]# tgt-admin  --showTarget 1: iqn.2013-05.com.clovem:target1    System information:        Driver: iscsi        State: ready    I_T nexus information:        I_T nexus: 1            Initiator: iqn.2013-05.com.clovem:node1            Connection: 0                IP Address: 172.18.26.254    LUN information:        LUN: 0            Type: controller            SCSI ID: IET     00010000            SCSI SN: beaf10            Size: 0 MB, Block size: 1            Online: Yes            Removable media: No            Readonly: No            Backing store type: null            Backing store path: None            Backing store flags:        LUN: 1            Type: disk            SCSI ID: target1            SCSI SN: s01            Size: 1074 MB, Block size: 512            Online: Yes            Removable media: No            Readonly: No            Backing store type: rdwr            Backing store path: /dev/vgsrv/lv0            Backing store flags:    Account information:    ACL information:        172.18.26.254

如果ISCSI存储设备容量>=2TB,就不能够使用常规的fdisk 命令进行磁盘的分区了(其分区表格式为msdos),需要使用parted,其分区表格式为GPT

命令:

parted  /dev/sdb  print //查看分区

parted  /dev/sdb  mklabel gpt    //转换格式(msdos gpt)

parted  /dev/sdb mkpart primary 1m 100m //创建起始大小为1M,结束为100M的名为primary的分区

分区改名:

parted  /dev/sdb name  2 ' "Linux FileSystem" '  //对2号分区改名  

parted  -s /dev/sdb mkfs 1 ext4   //将1号分区格式化为ext4文件系统,测试发现不支持ext4如此格式化,仅仅默认支持ext2,所以通过mkfs.ext4命令进行格式化即可。

[root@desktop26 ~]# parted  /dev/sdb mklabel gptWarning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?Yes/No? Yes                                                             Information: You may need to update /etc/fstab.                         [root@desktop26 ~]# parted  /dev/sdb mkpart rh436 200m 300mInformation: You may need to update /etc/fstab.                         [root@desktop26 ~]# parted  /dev/sdb printModel: IET VIRTUAL-DISK (scsi)Disk /dev/sdb: 1074MBSector size (logical/physical): 512B/512BPartition Table: gptNumber  Start  End    Size    File system  Name   Flags 1      200MB  300MB  99.6MB               rh436[root@desktop26 ~]# mkfs.ext4 /dev/sdb1  > /dev/null  2>&1[root@desktop26 ~]# parted  /dev/sdb printModel: IET VIRTUAL-DISK (scsi)Disk /dev/sdb: 1074MBSector size (logical/physical): 512B/512BPartition Table: gptNumber  Start  End    Size    File system  Name   Flags 1      200MB  300MB  99.6MB  ext4         rh436[root@desktop26 ~]# mkdir /rh436 ; mount /dev/sdb1  /rh436 ; df -H |grep rh436/dev/sdb1               97M   5.8M    86M   7% /rh436

转载地址:http://iousa.baihongyu.com/

你可能感兴趣的文章
clang
查看>>
IOS成长之路-Nsstring中搜索方法rangeOfString
查看>>
递归函数的概念使用方法与实例
查看>>
RMAN_学习笔记4_RMAN Virtual Catalog虚拟恢复目录
查看>>
cf451C-Predict Outcome of the Game
查看>>
struct dev_t
查看>>
Java 原型模式
查看>>
【转】Android4.3 蓝牙BLE初步
查看>>
题目:求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。
查看>>
hadoop2.0 和1.0的区别
查看>>
手机web——自适应网页设计(html/css控制) - 51CTO.COM
查看>>
ibatis resultMap 的用法
查看>>
Protocol Buffer技术详解(数据编码)
查看>>
【javascript】ajax 基础
查看>>
2015 UESTC 搜索专题N题 韩爷的梦 hash
查看>>
MySQL 二进制日志过滤
查看>>
Centos下Tomcat 安装Apache Portable Runtime
查看>>
【BZOJ】2563: 阿狸和桃子的游戏
查看>>
redis 中文字符显示
查看>>
webview与JS的交互
查看>>