#ISCSI#


1.简介

ISCSI是直接对设备进行共享的服务

 

 

2.启动iscsi共享设备

 

[在server上]

 

#建立一个lvm设备

[[email protected] ~]# fdisk /dev/vdb

n

[Enter]

[Enter]

+1000M

wq

[[email protected] ~]# partprobe


[[email protected] ~]# pvcreate /dev/vdb1

[[email protected] ~]# vgcreate vg0 /dev/vdb1 ##把物理分区做成物理卷

[[email protected] ~]# vgdisplay ##查看物理卷组

[[email protected] ~]# lvcreate -l 249 -n iscsi_storage vg0 ##在vg0中建立iscsi_storage设备

Linux学习笔记 --ISCSI

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

 

[[email protected] ~]# yum install targetcli -y

[[email protected] ~]# systemctl start target

[[email protected] ~]# systemctl enable target

Linux学习笔记 --ISCSI


[[email protected] ~]# targetcli ##进入ISCSI目标交互式配置模式

Linux学习笔记 --ISCSI

/> /backstores/block create server1storage /dev/vg0/iscsi_storage ##创建目录

/> /iscsi create iqn.2017-06.com.example:strage1 ##创建iqn

/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/luns create /backstores/block/server1storage ##关联

/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/acls create iqn.2017-06.com.example:server1storage ##加密

/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/portals create 172.25.29.11 ##创建端口

/> exit ##退出

Linux学习笔记 --ISCSI

 

[在desktop上]

 

[[email protected] ~]# vim /etc/iscsi/initiatorname.iscsi ##编辑initiator名称配置文件

InitiatorName=iqn.2017-06.com.example:server1storage ##设置initiator名称

Linux学习笔记 --ISCSI 


[[email protected] ~]# iscsiadm -m discovery -t st -p 172.25.29.11 ##查找iscsi服务器所提供的iscsi目标

[[email protected] ~]# iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.29.11 -l ##登陆服务器上的iscsi目标  -l是LOGIN的意思,即挂载

Linux学习笔记 --ISCSI


[[email protected] ~]# fdisk -l

 Linux学习笔记 --ISCSI


[[email protected] ~]# yum install tree.x86_64 -y

 

[[email protected] ~]# tree -C /var/lib/iscsi/

Linux学习笔记 --ISCSI

 

3.挂载

 

[[email protected] ~]# fdisk /dev/sda

n

[Enter]

[Enter]

[Enter]

wq

[[email protected] ~]# partprobe


[[email protected] ~]# mkfs.xfs /dev/sda1  ##格式化

[[email protected] ~]# mount /dev/sda1 /mnt/       ##挂载

Linux学习笔记 --ISCSI


#永久挂载

[[email protected] ~]# blkid

/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"

/dev/sda1: UUID="b7e517a4-fcac-4b3e-9306-c3c6a0ca9eee" TYPE="xfs"

[[email protected] ~]# vim /etc/fstab

UUID="b7e517a4-fcac-4b3e-9306-c3c6a0ca9eee"     /mnt    xfs     defaults,_netdev        0 0


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

 

 

4.删除

 

[在desktop端]

 

[[email protected] ~]# umount /mnt/

[[email protected] ~]# iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.29.11 -u ##登出iSCSI目标,以暂时断开连接

[[email protected] ~]# iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.29.11 -o delete ##删除iSCSI目标的本地记录,以永久断开连接

[[email protected] ~]# tree -C /var/lib/iscsi/

Linux学习笔记 --ISCSI


[在server端]

 

[[email protected] ~]# targetcli

/> clearconfig confirm=True ##清除iscsi的所有配置信息

/> exit

Linux学习笔记 --ISCSI

 

相关文章:

  • 2021-08-13
  • 2021-05-21
  • 2021-10-15
  • 2021-09-19
猜你喜欢
  • 2021-12-14
  • 2021-11-30
  • 2022-02-10
  • 2021-08-08
  • 2022-12-23
相关资源
相似解决方案