标签:internet 服务器 created server domain
#################iscsi################
#####################################
iSCSI(Internet SCSI)支持从客户端(发起端)通过IP向远程服务器上的
SCSI存储设备(目标)发送SCSI命令。iSCSI限定名称用于确定发起端和目
标,并采用iqn.yyyy-mm.{reverse domain}:label的格式。默认情况下,网络
通信是至iSCSI目标上的端口3260/tcp的明文。
l iSCSI发起端:需要访问原始SAN存储的客户端。
l iSCSI目标:从iSCSI服务器提供的远程硬盘磁盘,或“目标门户”
l iSCSI目标门户:通过网络向发起端提供目标的服务器。
l
IQN:“iSCSI限定名称”。每个发起端和目标需要唯一名称进行标识,
最好的做法是使用一个在Internet上可能独一无二的名称。
1.在server端
先对vdb进行分区
[root@server ~]# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created
[root@server ~]# vgcreate vg0 /dev/vdb1
Volume group "vg0" successfully created
[root@server ~]# lvcreate -l 249 -n iscsi_storage vg0
Logical volume "iscsi_storage" created
[root@server ~]# lvs ##查看lvm设备
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
iscsi_storage vg0 -wi-a----- 996.00m
安装iscsi目标软件包
yum install -y targetcli
systemctl enable target
systemctl start target
systemctl stop firewalld
进入iscsi目标交互式配置模式
[root@server ~]# 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 .........................................
/> /backstores/block create server1storage /dev/vg0/iscsi_storage
Created block storage object server1storage using /dev/vg0/iscsi_storage.
/> /iscsi create iqn.2017-06.com.example:stragel
Created target iqn.2017-06.com.example:stragel.
Created TPG 1.
/> clearconfig confirm=True
All configuration cleared
/> 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]
/> /backstores/block create server1storage /dev/vg0/iscsi_storage
Created block storage object server1storage using /dev/vg0/iscsi_storage.
/> /iscsi create iqn.2017-06.com.example:strage1
Created target iqn.2017-06.com.example:strage1.
Created TPG 1.
/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/luns create /backstores/block/server1storage
Created LUN 0.
/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/acls create iqn.017-06.com.example:server1storagekey
WWN not valid as: iqn, naa, eui
/> /iscsi/iqn.2017-06.com.example:strage1/tpg1/acls create iqn.2017-06.com.example:server1storagekey
Created Node ACL for iqn.2017-06.com.example:server1storagekey
Created mapped LUN 0.
/> /iscsi
/iscsi> 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 iscsi
2.在desktop端
systemctl stop firewalld
systemctl disable firewalld
[root@desktop ~]# vim /etc/iscsi/initiatorname.iscsi ###在/etc/iscsi/initiatorname.iscsi中设置发起端的IQN
[root@desktop ~]# iscsiadm -m discovery -t st -p 172.25.254.102 ###查找iscai服务器所提供的iscsi目标
172.25.254.102:3260,1 iqn.2017-06.com.example:strage1
[root@desktop ~]# iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.254.102 -l 登陆服务器上的一个或多个iscsi目标
Logging in to [iface: default, target: iqn.2017-06.com.example:strage1, portal: 172.25.254.102,3260] (multiple)
Login to [iface: default, target: iqn.2017-06.com.example:strage1, portal: 172.25.254.102,3260] successful.
[root@desktop ~]# fdisk -l
Disk /dev/sda: 1044 MB, 1044381696 bytes, 2039808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
对sda进行分区
[root@desktop ~]# partprobe ###同步分区表
[root@desktop ~]# mkfs.xfs /dev/sda
mkfs.xfs: /dev/sda appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
[root@desktop ~]# mkfs.xfs /dev/sda1 -f
meta-data=/dev/sda1 isize=256 agcount=8, agsize=31744 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=253952, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@desktop ~]# mount /dev/sda1 /mnt
[root@desktop ~]# yum install -y tree
[root@desktop ~]# tree -C /var/lib/iscsi/
/var/lib/iscsi/
├── ifaces
├── isns
├── nodes
│ └── iqn.2017-06.com.example:strage1
│ └── 172.25.254.102,3260,1
│ └── default
├── send_targets
│ └── 172.25.254.102,3260
│ ├── iqn.2017-06.com.example:strage1,172.25.254.102,3260,1,default -> /var/lib/iscsi/nodes/iqn.2017-06.com.example:strage1/172.25.254.102,3260,1
│ └── st_config
├── slp
└── static
[root@desktop ~]# blkid ###查看分区的UUID
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"
/dev/sda1: UUID="4fc4230e-3b7d-42fc-a11a-1d1d07968289" TYPE="xfs"
写自动挂载
vim /etc/fstab
3.删除客户端的数据
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.254.102 -u
##确保iscsi服务在引导时启动。
##确保没有使用目标所提供的任何设备。
##确保从/etc/fstab等位置中删除使用目标的所有永久挂载
##登出iSCSI目标,以暂时断开连接。
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.254.102 -o delete
###删除iSCSI目标的本地记录,以永久断开连接。
4.删除服务端的数据
clearconfig confirm=Ture ##清除iscsi的所有信息
标签:internet 服务器 created server domain
原文地址:http://12920735.blog.51cto.com/12910735/1936813