码迷,mamicode.com
首页 > 其他好文 > 详细

通过iscsi配置网络存储

时间:2020-05-28 12:54:46      阅读:53      评论:0      收藏:0      [点我收藏+]

标签:访问共享   raid   lock   other   服务   emctl   定义   点击   配置文件   

targetcli 交互配置

先做个软raid10

mdadm -Cv /dev/md0 -n 4 -l 10 /dev/sd[b-e]
#初始化
mdadm -D /dev/md0

安装targetd

yum install targetd targetcli

重启
开启启动

配置iscsi服务端

[root@rhceclient Desktop]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help‘.

/> ls
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 0]
  o- loopback ..................................................... [Targets: 0]
#创建保存数据的硬盘,相当于别名
/> cd backstores/block 
/backstores/block> create disk0 /dev/md0
Created block storage object disk0 using /dev/md0.
#创建共享的名称
/backstores/block> cd /iscsi 
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f.
Created TPG 1.
/iscsi> ls
o- iscsi .......................................................... [Targets: 1]
  o- iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f .... [TPGs: 1]
    o- tpg1 ............................................. [no-gen-acls, no-auth]
      o- acls ........................................................ [ACLs: 0]
      o- luns ........................................................ [LUNs: 0]
      o- portals .................................................. [Portals: 0]
#luns,当用户访问共享名称时,能提供什么服务
/iscsi> cd iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f/
/iscsi/iqn.20....d2f50c26b37f> ls
o- iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f ...... [TPGs: 1]
  o- tpg1 ............................................... [no-gen-acls, no-auth]
    o- acls .......................................................... [ACLs: 0]
    o- luns .......................................................... [LUNs: 0]
    o- portals .................................................... [Portals: 0]
/iscsi/iqn.20....d2f50c26b37f> cd tpg1/luns 
/iscsi/iqn.20...37f/tpg1/luns> create /backstores/block/disk0 
Created LUN 0.
/iscsi/iqn.20...37f/tpg1/luns> cd ..
/iscsi/iqn.20...0c26b37f/tpg1> ls
o- tpg1 ................................................. [no-gen-acls, no-auth]
  o- acls ............................................................ [ACLs: 0]
  o- luns ............................................................ [LUNs: 1]
  | o- lun0 ........................................... [block/disk0 (/dev/md0)]
  o- portals ...................................................... [Portals: 0]
#谁可以使用这个资源,当设备的名称是如下时,才可以使用这个资源。如下加了一个:client标识,可以自定义的。
/iscsi/iqn.20...0c26b37f/tpg1> cd acls 
/iscsi/iqn.20...37f/tpg1/acls> create iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f:client
Created Node ACL for iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f:client
Created mapped LUN 0.
/iscsi/iqn.20...37f/tpg1/acls> cd ..
/iscsi/iqn.20...0c26b37f/tpg1> ls
o- tpg1 ................................................. [no-gen-acls, no-auth]
  o- acls ............................................................ [ACLs: 1]
  | o- iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f:client  [Mapped LUNs: 1]
  |   o- mapped_lun0 ................................... [lun0 block/disk0 (rw)]
  o- luns ............................................................ [LUNs: 1]
  | o- lun0 ........................................... [block/disk0 (/dev/md0)]
  o- portals ...................................................... [Portals: 0]
#由谁提供iscsi存储服务
/iscsi/iqn.20...0c26b37f/tpg1> cd portals 
/iscsi/iqn.20.../tpg1/portals> create 192.168.10.10
Using default IP port 3260
Created network portal 192.168.10.10:3260.
/iscsi/iqn.20.../tpg1/portals> ls
o- portals ........................................................ [Portals: 1]
  o- 192.168.10.10:3260 ................................................... [OK]
#exit正常退出,会写到配置文件里
/iscsi/iqn.20.../tpg1/portals> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

重启服务并加入开机启动

systemctl restart targetd
systemctl enable targetd

清空iptables

iptables -F
service iptables save

配置Linux客户端

 vim /etc/iscsi/initiatorname.iscsi 
#发现命令,类似nfs showmount
 iscsiadm -m discovery -t st -p 192.168.10.10
 iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f -p 192.168.10.10 -l
#可以看到dev目录多了一个sdb设备
 ls /dev/sd*
#卸载 -u参数,代表out
 iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rhceclient.x8664:sn.d2f50c26b37f -u 

 ls /dev/sd*

配置Windows客户端

先配置发起程序名称
技术图片

在目标里输入共享名称,点击快速连接
技术图片

通过iscsi配置网络存储

标签:访问共享   raid   lock   other   服务   emctl   定义   点击   配置文件   

原文地址:https://blog.51cto.com/sampsondotqiu/2499125

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!