标签:internet 服务器 domain target enable
iSCSI(Internet SCSI):支持从客户端通过IP向远程服务器上的SCSI存储设备发送SCSI命令
SCSI 结构基于客户/服务器模式,其通常应用环境是:设备互相靠近,并且这些设备由 SCSI 总线连接。iSCSI 的主要功能是在 TCP/IP 网络上的主机系统(启动器 initiator)和存储设备(目标器 target)之间进行大量数据的封装和可靠传输过程。此外,iSCSI 提供了在 IP 网络封装 SCSI 命令,且运行在 TCP 上。
限定名称格式:iqn.yyyy-mm.{reverse domain}:label
一、服务器端配置如下:
1.安装并启动服务
[root@localhost Desktop]# yum install targetcli -y #安装iSCSI目标软件包 [root@localhost Desktop]# systemctl start target #启动target服务 [root@localhost Desktop]# systemctl enable target #设置服务开机自启动
2.进入iSCSI交互式配置模式
[root@localhost Desktop]# targetcli #输入targetcli命令 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 ..................................................... [Targets: 0] /> /backstores/block create pt.example.disk1 /dev/sda4 #使用/dev/sda4创建ISCSI远程存储块pt.example.disk1 Created block storage object pt.example.disk1 using /dev/sda4. /> /iscsi create iqn.2016-03.pt.example1:storage #创建要分享的ISCSI文件名(格式必须是iqn.yyyy-mm.{reverse domain}:label) Created target iqn.2016-03.pt.example1:storage. Created TPG 1. /> /iscsi/iqn.2016-03.pt.example1:storage/tpg1/acls create iqn.2016-03.pt.example2:desktop #指定访问ISCSI设备块的ACL权限(即允许initiator name为iqn.2016-03.pt.example2:desktop的客户端可以访问) Created Node ACL for iqn.2016-03.pt.example2:desktop /> /iscsi/iqn.2016-03.pt.example1:storage/tpg1/luns create /backstores/block/pt.example.disk1 #将创建的ISCSI远程存储块加入进来 Created LUN 0. Created LUN 0->0 mapping in node ACL iqn.2016-03.pt.example2:desktop /> /iscsi/iqn.2016-03.pt.example1:storage/tpg1/portals create 172.25.254.209 #打开访问所使用的端口 Using default IP port 3260 Created network portal 172.25.254.209:3260. /> ls #完成后如下所示 o- / ..................................................................... [...] o- backstores .......................................................... [...] | o- block .............................................. [Storage Objects: 1] | | o- pt.example.disk1 ............ [/dev/sda4 (1.0GiB) write-thru activated] | o- fileio ............................................. [Storage Objects: 0] | o- pscsi .............................................. [Storage Objects: 0] | o- ramdisk ............................................ [Storage Objects: 0] o- iscsi ........................................................ [Targets: 1] | o- iqn.2016-03.pt.example1:storage ............................... [TPGs: 1] | o- tpg1 ........................................... [no-gen-acls, no-auth] | o- acls ...................................................... [ACLs: 1] | | o- iqn.2016-03.pt.example2:desktop .................. [Mapped LUNs: 1] | | o- mapped_lun0 .................. [lun0 block/pt.example.disk1 (rw)] | o- luns ...................................................... [LUNs: 1] | | o- lun0 ......................... [block/pt.example.disk1 (/dev/sda4)] | o- portals ................................................ [Portals: 1] | o- 172.25.254.209:3260 .......................................... [OK] o- loopback ..................................................... [Targets: 0] /> exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json
设置防火墙
[root@localhost Desktop]# firewall-cmd --permanent --add-port=3260/tcp #将要使用的端口加入到防火墙允许之中 success [root@localhost Desktop]# firewall-cmd --reload #重载防火墙的设置 success
二、客户端配置如下:
[root@localhost Desktop]# yum install iscsi-initiator-utils -y #安装iSCSI发起端软件包 [root@localhost Desktop]# vim /etc/iscsi/initiatorname.iscsi #设置发起端的IQN InitiatorName=iqn.2016-03.pt.example2:desktop [root@localhost Desktop]# iscsiadm -m discovery -t st -p 172.25.254.209 #获得可以访问共享的块 172.25.254.209:3260,1 iqn.2016-03.pt.example1:storage [root@localhost Desktop]# iscsiadm -m node -T iqn.2016-03.pt.example1:storage -p 172.25.254.209 -l #连接服务端的ISCSI目标块到本机 Logging in to [iface: default, target: iqn.2016-03.pt.example1:storage, portal: 172.25.254.209,3260] (multiple) Login to [iface: default, target: iqn.2016-03.pt.example1:storage, portal: 172.25.254.209,3260] successful. [root@localhost Desktop]# fdisk -l #查看磁盘,多了/dev/sdb Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000c235a Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 4605951 2097152 82 Linux swap / Solaris /dev/sda3 4605952 35796991 15595520 83 Linux Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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 Disk label type: dos Disk identifier: 0x00000000 Device Boot Start End Blocks Id System
然后就可以正常使用所得到的ISCSI资源,正常格式化,并挂载。
########中断使用ISCSI目标#########
先将挂载进行卸载,确保没有使用目标所提供的任何设备
[root@localhost Desktop]# iscsiadm -m node -T iqn.2016-03.pt.example1:storage -p 172.25.254.209 -u #退出ISCSI目标,以暂时断开连接 [root@localhost Desktop]# iscsiadm -m node -T iqn.2016-03.pt.example1:storage -p 172.25.254.209 -o -delete #删除本地连接ISCSI目标的本地记录,以永久断开连接
本文出自 “ptallrights” 博客,请务必保留此出处http://ptallrights.blog.51cto.com/11151122/1793228
标签:internet 服务器 domain target enable
原文地址:http://ptallrights.blog.51cto.com/11151122/1793228