在linux挂载网络驱动器,利用centos 6.6 搭建iscsi服务器并在centos挂载iscsi网络驱动器...

##################################################################

搭建iscsi服务器:

参考自:http://www.linuxidc.com/Linux/2016-09/135655.htm

yum install scsi-target-utils -y

vi /etc/tgt/targets.conf

在末尾添加

backing-store /dev/sdb

保存退出

service tgtd start

[root@localhost ~]# tgtadm --lld iscsi --mode target --op show

Target 1: iqn.2017-09.com.renkailang:server.target1

System information:

Driver: iscsi

State: ready

I_T nexus information:

I_T nexus: 10

Initiator: iqn.1994-05.com.redhat:e997bd467e98

Connection: 0

IP Address: 192.168.130.128

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: 16106 MB, Block size: 512

Online: Yes

Removable media: No

Prevent removal: No

Readonly: No

Backing store type: rdwr

Backing store path: /dev/sdb

Backing store flags:

Account information:

ACL information:

ALL

###############################################################

配置iscsi客户端initiator

yum install -y iscsi-initiator-utils

service iscsid start

service iscsi start

chkconfig iscsid on

iscsiadm -m discovery -t st -p 192.168.130.133 #发现iscsi服务器

iscsiadm -m node -p 192.168.130.133 -l #登录iscsi服务器

iscsiadm -m node -p 192.168.130.133 -u #登出iscsi服务器

iscsiadm -m session #查看会话信息

[root@localhost ~]#  vi /etc/iscsi/iscsid.conf

去掉node.startup = automatic前面#号,或者在最后添加node.startup = automatic

fdisk -l #查看是否多出sdb

fdisk /dev/sdb 创建新分区,(注意:超过2T分区需要使用parted命令进行分区操作)

[root@localhost ~]# fdisk /dev/sdb

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-3263, default 1): 1

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-3263, default 3263): 3263

Using default value 3263

Command (m for help): w

The partition table has been altered!

[root@localhost ~]# fdisk -l

多出以下信息:

磁盘 /dev/sdb:16.1 GB, 16106127360 字节,31457280 个扇区

Units = 扇区 of 1 * 512 = 512 bytes

扇区大小(逻辑/物理):512 字节 / 512 字节

I/O 大小(最小/最佳):512 字节 / 512 字节

磁盘标签类型:dos

磁盘标识符:0x8da8d2d4

设备 Boot      Start         End      Blocks   Id  System

/dev/sdb1              32    31457279    15728624   83  Linux

[root@localhost ~]#mkfs.ext4 /dev/sdb1

[root@localhost ~]# df -T

文件系统                类型        1K-块    已用     可用 已用% 挂载点

/dev/mapper/centos-root xfs      37300436 1096992 36203444    3% /

/dev/sda1               xfs        508588  125596   382992   25% /boot

/dev/sdb1               ext4     15350752   38392 14509548    1% /test

##########################################################################

挂载iscsi磁盘,并设置开机启动:

mount -t ext4 /dev/sdb1 /testdir

编辑/etc/rc.d/rc.local文件(注意:一定要利用/etc/rc.d/rc.local设置开机启动,切记不要用/etc/fstab挂载iscsi等网络存储,/etc/fstab是在系统启动时加载,但此时网络等相关iscsi服务都没启动起来,会导致开机出现异常)

[root@localhost ~]#vi /etc/rc.d/rc.local

#在末尾添加:

sleep 10s #添加10s缓冲时间,等iscsi等相关服务起来之后再进行挂载。

/bin/mount -t ext4 /dev/sdb1 /testdir

保存退出

[root@localhost ~]#chmod +x /etc/rc.d/rc.local

相关命令:

1.发现iscsi存储: iscsiadm -m discovery -t st -p ISCSI_IP

2.查看iscsi发现记录 iscsiadm -m node

3.删除iscsi发现记录 iscsiadm -m node -o delete -T LUN_NAME -p ISCSI_IP

4.登录iscsi存储 iscsiadm -m node -T LUN_NAME -p ISCSI_IP -l

5.登出iscsi存储 iscsiadm -m node -T LUN_NAME -p ISCSI_IP -u

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值