linux运维-iscsi
############iscsi##################
1.作用:
iSCSI(Internet SCSI)支持从客户端(发起端)通过IP向远程服务器上的SCSI存储设备(目标)发送SCSI命令。iSCSI限定名称用于确定发起端和目标,并采用iqn.yyyy-mm.{reverse domain}:label的格式。默认情况下,网络通信是至iSCSI目标上的端口3260/tcp的明文。
iSCSI发起端:需要访问原始SAN存储的客户端。
iSCSI目标:从iSCSI服务器提供的远程硬盘磁盘,或“目标门户”
iSCSI目标门户:通过网络向发起端提供目标的服务器。
IQN:“iSCSI限定名称”。每个发起端和目标需要唯一名称进行标识,
最好的做法是使用一个在Internet上可能独一无二的名称。
2.启动iscsi共享服务
sever:
建立一个1000M的lvm设备
先建立一个磁盘分区
pvcreate /dev/vdb1
vgcreate vg0 /dev/vdb1
lvcreate -L 500M -n iscsi_datavg0
lvscan ##查看逻辑卷
yum install targetcli -y ##安装服务
systemctl start target
systemctl enable target
systemctl stop firewalld
targetcli ##配置服务
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> ls
/> /backstores/block create server22storage /dev/vg0/iscsi_storage ##给设备起名字
/> /iscsi create iqn.2017-06.com.example:storage1 ##建立iqn
/> /iscsi/iqn.2017-06.com.example:storage1/tpg1/luns create /backstores/block/server23storage
/> /iscsi/iqn.2017-06.com.example:storage1/tpg1/acls create iqn.2017-06.com.example:server23storagekey ##生成key
/> /iscsi/iqn.2017-06.com.example:storage1/tpg1/portals create 172.25.22.11 ##连接服务端的端口
/> exit
desktop:
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-06.com.example:server22storagekey ##指定key
iscsiadm -m discovery -t st -p 172.25.22.11 ##查找iscsi服务器所提供的iscsi目标
iscsiadm -m node -T iqn.2017-06.com.example:storage1 -p 172.25.22.11 -l ##登陆服务器上的iscsi
yum install tree -y
tree -C /var/lib/iscsi ##可以查看到已经登陆成功的设备树
3.挂载:
vim /etc/fstab
UUID="debaea92-d79a-4a58-bc7a-79559cee8587" /mnt xfs defaults,_netdev 0 0
mount -a ##尽量用uid进行挂载,因为每次开机时,这个服务都会发生飘移
4.删除:
desktop:
umount /mnt
vim /etc/fstab
删除自动挂载
iscsiadm -m node -T iqn.2017-06.com.example:storage1 -p 172.25.22.11 -u ##退出登陆
iscsiadm -m node -T iqn.2017-06.com.example:storage1 -p 172.25.22.11 -o delete ##删除设备
server:
targetcli
>/ clearconfig confirm=True ##删除所有配置