IP SAN实验

实验环境 centos7 serverx2

IP:192.168.0.206    192.168.0.207

iscsi-server端的配置

  • 准备磁盘设备
  • 安装程序包
  • 创建target
  • 创建lun
  • 授权

 

首先添加两块硬盘

sdb sdc

然后安装软件包

yum -y install epel-release

yum -y install scsi-target-utils

systemctl start tgtd

 

管理工具

target:管理target

logicalunit:管理lun

account:管理用户账号

 

 

 

管理操作

–lld <deiver>指明驱动 一般为iscsi

–mode   target:管理target

logicalunit:管理lun

account:管理用户账号

–op

show: 查看

new:新建

delete:删除

update:更新

bind:绑定

unbind:解绑

–tid 指明target号

 

常用选项

–lld,-L<指明驱动>

–mode,-m

–op,-o

–tid,-t

–lun,-l

–backing-store,-b

–initiator-address,-i

–targetname, -T

1

 

[root@localhost ~]# tgtadm –lld iscsi –mode target –op show 查看target

[root@localhost ~]# tgtadm –lld iscsi –mode target –op new –tid 1 –targetname iqn.2017-12.com.shoushangdezhu:A1.U1 #创建target

[root@localhost ~]# tgtadm –lld iscsi –mode logicalunit –op new –tid 1 –lun 2 –backing-store /dev/sdc    #在创建的target上添加lun

2

 

[root@localhost ~]# tgtadm –lld iscsi –mode logicalunit –op delete –tid 1 –lun 2 #删除lun

删除的时候只要指明tid 和 lun号就ok了

 

[root@localhost ~]# tgtadm –lld iscsi –mode target –op bind –tid 1 –initiator-address 192.168.0.0/24  #使用bind 绑定ip访问target

此处–initiator-address可用-i 代替

3

iscsi-initiator端的配置

  • 安装程序包,配置initiator的名字,并启动服务
  • 使用Iscsisadm实现target的发现、注册等
  • 发现模式:discover

iscsiadm -m discover -d # -t st-p IP:PORT

-t type :sendtargets可简写为st

  • 节点模式:node

iscsiadm -m node [ -d debug_level ] -T targetname -p ip:port -l | -u | -R | -s -o  operation

[root@localhost ~]# yum -y install iscsi-initiator-utils

[root@localhost ~]# systemctl start iscsi

[root@localhost ~]# systemctl start iscsid

[root@localhost ~]# iscsi-iname -p iqn.2017-06.com.shoushangdezhu

[root@localhost ~]# vi /etc/iscsi/initiatorname.iscsi #将生成的名字写入文件

或者[root@localhost ~]# echo “InitiatorName=$(iscsi-iname -p iqn.2017.com.shoushangdezhu)” > /etc/iscsi/initiatorname.iscsi

[root@localhost ~]# for i in iscsi iscsid; do systemctl restart $i;done

[root@localhost ~]# iscsiadm -m discovery -d 3 -t st -p 192.168.0.206:3260

4

[root@localhost ~]# iscsiadm -m node -d 1 -T iqn.2017-12.com.shoushangdezhu:A1.U1 -p 192.168.0.206:3260 -l #登录【-l】 临时登出【-u】 若要永久删除则使用【-o delete】

5

现在查看一下磁盘状况

6

发现本地已经多了两块磁盘,然后就能分区格式化然后挂载了

创建分区格式化

7

回到iscsi-server端发现分区中也存在sdb1

 

注意:不要让主机之间同时使用一块硬盘分区,同一个target中可能有很多块硬盘,将target的硬盘分配给不同的主机进行使用

 

 

基于account认证

tgtadm –lld iscsi –mode account –op new –user pig –password pig

tgtadm –lld iscsi –mode account -o bind –tid 1 –user pig

 

在initiator端

vim /etc/iscsi/iscsid.conf

8

修改username和password

然后

iscsiadm -m discovery -d 3 -t st -p 192.168.0.206:3260

iscsiadm -m node -d 1 -T iqn.2017-12.com.shoushangdezhu:A1.U1 -p 192.168.0.206:3260 -l

 

 

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/90187

(1)
N27_flypigN27_flypig
上一篇 2017-12-16 18:02
下一篇 2017-12-16 20:31

相关推荐

  • keepalive高可用haproxy实现URL资源的动静分离

    keepalive高可用haproxy实现动静分离URL资源 实现要点: (1) 动静分离discuzx,动静都要基于负载均衡实现; (2) 进一步测试在haproxy和后端主机之间添加varnish缓存; (3) 给出拓扑设计; (4) haproxy的设定要求:     (a…

    Linux干货 2016-11-12
  • Linux网络属性管理

      ifconfig命令 ifconfig [interface] # ifconfig -a # ifconfig IFACE [up|down] ifconfig interface [aftype] options | address … # ifconfig IFACE IP/mask [up] # ifconfig IFACE…

    Linux干货 2015-09-26
  • Linux 第七天: (08月05日) 练习和作业

    Linux 第七天: (08月05日) 练习和作业       1 找出ifconfig命令结果中本机的所有IPv4地址 ifconfig | tr -cs '[0-9].''\n' | sort -ut '.' -k3 -n 或ifconfig | head -2 |…

    Linux干货 2016-08-08
  • LINUX下的RPM应用

    一 前言 在进入RPM的应用前,关于可执行程序的一些基本知识有必要说明一下: 1 ABI:application binary interface,这是应用程序与系统间的协议,大家都知道同一个程序在不同的操作系统平台可能会无法执行,很大程度上就是因为ABI的不同,因此,对于可执行程序,选择对应操作系统平台是第一步 2 API:application prog…

    Linux干货 2017-04-17
  • grep,egrep及相应的正则表达式用法详解

    目录 1、grep简介     1.1、grep是什么     1.2、grep使用格式     1.3、grep常用选项 2、正则表达式与grep     2.1、正则表达式简介  &nb…

    系统运维 2016-08-22
  • Haproxy的基础应用!

            本篇博客主要是和大家共同了解一下Haproxy的功能与基础应用,目的是更加熟练的掌握Haproxy的工作原理,为将来的工种中做好铺垫!       本篇博客共分为两个部分:      …

    2017-05-16