iscsi

来源:互联网 发布:装修cad设计图软件 编辑:程序博客网 时间:2024/06/16 00:12

ISCSI

        iSCSI(Internet SCSI)支持从客户端(发起端)通过IP向远程服务器上的SCSI存储设备(目标)发送SCSI命令。iSCSI限定名称用于确定发起端和目标,并采用iqn.yyyy-mm.{reverse domain}:label的格式。默认情况下,网络通信是至iSCSI目标上的端口3260/tcp的明文

**iSCSI发起端:需要访问原始SAN存储的客户端。
** iSCSI目标:从iSCSI服务器提供的远程硬盘磁盘,或“目标门户”
** iSCSI目标门户:通过网络向发起端提供目标的服务器。
**IQN:“iSCSI限定名称”。每个发起端和目标需要唯一名称进行标识,最好的做法是使用一个在Internet上可能独一无二的名称。

1.
iscsi 是直接对设备进行共享的服务

2.启动iscsi共享设备

在server上:

yum install targetcli              ##安装iSCSI目标软件包
systemctl start target          ##启动服务
systemctl enable target      ##开机启动服务
systemctl stop firewalld      ##关闭火墙
systemctl disable firewalld ##开机不启动


建立一个lvm设备

fdisk /dev/vdb


pvcreate /dev/vdb1             ##创建物理卷
vgcreate vg0 /dev/vdb1      ##创建卷组vg0
vgdisplay                               ##查看可制作lv的容量

lvcreate -l 255 -n iscsi_storage vg0   ##创建逻辑卷

targetcli                              #####进入iSCSI目标交互式配置模式
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’.

/> ls
/> /backstores/block create server60storage /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/server60storage    ##创建目标地址
/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/acls create iqn.2017-06.com.example:server60storagekey   ##创建IQN密钥,明文密码
/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/portals create 172.25.254.133     ##设置iSCSI目标门户,即服务器IP,开启3260端口
/> exit




在desktop上:

vim /etc/iscsi/initiatorname.iscsi ##在/etc/iscsi/initiatorname.iscsi中设置发起端的IQN
InitiatorName=iqn.2017-06.com.example:server60storagekey ##=后为设置的密钥
systemctl restart iscsi ##重启服务


iscsiadm -m discovery -t st -p 172.25.0.11              ##查找iSCSI服务器所提供的iSCSI目标(目标门户)
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.0.11 -l ##登录服务器上的一个或多个iscsi目标


yum install tree -y ##下载树形菜单控件
tree -C /var/lib/iscsi/ ##查看ISCSI目标


3.挂载

此时,可以使用iSCSI磁盘,就好像它是本地连接硬盘驱动器。
客户端:
fdisk -l
Disk /dev/sda: 1069 MB, 1069547520 bytes, 2088960 sectors       ##由此可以看到ISCSA磁盘

partprobe                 ##同步分区
mkfs.xfs /dev/sda   ##格式化分区


mount /dev/sda /mnt  ##挂载
blkid                            ##查看UUID
vim /etc/fstab            ##编辑开机查看文件设置永久挂载
UUID=af2b09ce-3218-4805-86dd-1f619c37be9e /mnt xfs defaults,_netdev 0 0


4.删除

umount /mnt/ ##解除挂载
vim /etc/fstab ##删除永久挂载设置
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.254.133 -u ##退出登陆
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.254.133 -o delete ##删除ISCSI目标


在服务端:

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





原创粉丝点击