输入您的问题查找答案
   
 
相关文库文档
更多相关文库文档 >>
联系客服
在线技术支持
客户服务热线:

电话销售热线:

服务时间(法定节假日除外):
家庭产品:
周一~周五:8:30~20:30
周六:9:00~18:00
商用产品:
周一~周五:9:00~18:00
商用网络动态

与 NETGEAR 监控专用交换机亲密接触

选择德才兼备的 PoE 交换机

NETGEAR 交换机助力聊城第二人民医院智能监控建设

更多动态 >>

网件文库 » 存储产品  »  Linux iSCSI 发起端连接到 ReadyNAS 的方法
Linux iSCSI 发起端连接到 ReadyNAS 的方法

编号:50218       来自:NetGear       更新日期:2017-09-15       访问数量:9023

文档适用产品型号:RN526X,RR4312S,RN626X,RR3312,RR4312X,RN10200,RN10400,RN31200,RN31400,RN31600,RN51600,RN2120,RN3220,RN4220S,RN4220X,EDA500,RN716X

首先在ReadyNAS上面建立好一个LUN

建立一个新的群组

接着将该LUN添加到一个这个LUN GROUP

这里简单起见,允许所有客户端来连接

接着进入Linux系统,以root的身份运行一下命令(这里以CentOS 6.4为例)

首先需要运行iscsi和iscsid服务,并设置为开机启动:
[root@localhost ~]# service iscsi start
[root@localhost ~]# service iscsid start
[root@localhost ~]# chkconfig iscsi on
[root@localhost ~]# chkconfig iscsid on

发现ReadyDATA上面有哪些目标:
[root@localhost ~]# iscsiadm -m discovery -t st -p 10.45.1.50:3260
10.45.1.50:3260,1 iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1

接着进行登录操作
[root@localhost ~]# iscsiadm -m node -T iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1 -p 10.45.1.50:3260 -l
Logging in to [iface: default, target: iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1, portal: 10.45.1.50,3260] (multiple)
Login to [iface: default, target: iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1, portal: 10.45.1.50,3260] successful.

使用fdisk来查看连接上的LUN,在这里,sdc就是所连接的LUN(这里省略其他输出)
[root@localhost ~]# fdisk -l
Disk /dev/sdc: 107.4 GB, 107374182912 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 / 4194304 bytes
Disk identifier: 0x00000000

接着进行分区
[root@localhost ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x10e41df7.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
                     switch off the mode (command 'c') and change display units to
                     sectors (command 'u').

Command (m for help): n
Command action
    e extended
    p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054

Command (m for help): p

Disk /dev/sdc: 107.4 GB, 107374182912 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 / 4194304 bytes
Disk identifier: 0x10e41df7

Device Boot Start End Blocks Id System
/dev/sdc1 1 13054 104856223+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
促使内核重新扫描分区表
[root@localhost ~]# partx -a /dev/sdc
BLKPG: Device or resource busy
error adding partition 1

格式化分区
[root@localhost ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
6553600 inodes, 26214055 blocks
1310702 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
            4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

获取UUID,以便用于mount操作
[root@localhost ~]# blkid /dev/sdc1
/dev/sdc1: UUID="67971c0e-3c2e-4f5f-a54b-186a15270b49" TYPE="ext4"

接着设置启动时自动mount的参数,添加下面这行自动挂载参数。在这里,使用_netdev参数的作用是“在开机时,网络服务全部启动之后,再来连接并挂载该iSCSI”。避免网络还没准备好,就尝试连接iSCSI。
[root@localhost ~]# vim /etc/fstab
UUID=67971c0e-3c2e-4f5f-a54b-186a15270b49 /iscsi ext4 _netdev 0 0

建立挂载目录
[root@localhost ~]# mkdir /iscsi

执行挂载
[root@localhost ~]# mount -a

查看是否挂载成功(省略其他参数)
[root@localhost ~]# mount
/dev/sdc1 on /iscsi type ext4 (rw,_netdev)

这样就大功告成了。接着可以看看iSCSI上面的发现记录:
[root@localhost ~]# iscsiadm -m node
10.45.1.50:3260,1 iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1

以及现在的连接会话状况:
[root@localhost ~]# iscsiadm -m session
tcp: [3] 10.45.1.50:3260,1 iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1

如果想断开连接:
[root@localhost ~]# iscsiadm -m node -T iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1 -u
Logging out of session [sid: 3, target: iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1, portal: 10.45.1.50,3260]
Logout of [sid: 3, target: iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1, portal: 10.45.1.50,3260] successful.

如果不再需要连接到该ISCSI Target,必须删掉该记录,不然开机还会重新连接:
[root@localhost ~]# iscsiadm -m node -T iqn.1994-11.com.netgear:nas-34-ea-30:f4d861d5:group1 -o delete

然后将fstab里面的记录删除。

 

序号

日期

跟进人

内容摘要

1

2013-10-31

Canfeng Li

文档创建

 

  
 
以上内容是否为您所需要的答案?
以上内容是否清晰、简明和易于理解的?
您是如何知道网件社区的?