当前位置:喜价首页攻略家电RHEL7ISCSI怎么样?RHEL7ISCSI配置

RHEL7ISCSI怎么样?RHEL7ISCSI配置

  • ISCSI服务器:192.168.10.10
  • ISCSI客户端:192.168.10.20
  • 在ISCSI服务器添加两块硬盘:/dev/sdb /de/sdc

一.在服务端安装

[root@localhost ~]# yum install targetd targetcli

二.配置服务端

1.创建块设备

[root@localhost ~]# targetcliWarning: Could not load preferences file /root/.targetcli/prefs.bin.targetcli shell version2.1.fb34Copyright 2011-2013by Datera, Inc and others.Forhelpon commands, type help ./> lso- / .................................................................... [...]  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]/> cd backstores/block /backstores/block> create disk0 /dev/sdbCreated blockstorageobject disk0 using /dev/sdb./backstores/block> create disk1 /dev/sdcCreated blockstorageobject disk1 using /dev/sdc.

2.创建target目标

/>cd iscsi /iscsi> create iqn.2016-02.xyz.abc:identifierCreated target iqn.2016-02.xyz.abc:identifier.Created TPG 1.

3.创建LUN

/iscsi> cd iqn.2016-02.xyz.abc:identifier/tpg1/luns /iscsi/iqn.20...ier/tpg1/luns> create /backstores/block/disk0Created LUN 0./iscsi/iqn.20...ier/tpg1/luns> create /backstores/block/disk1Created LUN 1.

4.创建ACL

/iscsi/iqn.20...ier/tpg1/acls>createiqn.2016-02.xyz.abc:identifierCreatedNodeACLforiqn.2016-02.xyz.abc:identifierCreatedmappedLUN1.CreatedmappedLUN0./iscsi/iqn.20.../tpg1/portals>create192.168.10.10UsingdefaultIPport3260Creatednetworkportal192.168.10.10:3260.

5.exit保存退出

/>lso-/.............................................................................................[...]o-backstores..................................................................................[...]|o-block......................................................................[StorageObjects:2]||o-disk0................................................[/dev/sdb(2.0GiB)write-thruactivated]||o-disk1................................................[/dev/sdc(2.0GiB)write-thruactivated]|o-fileio.....................................................................[StorageObjects:0]|o-pscsi......................................................................[StorageObjects:0]|o-ramdisk....................................................................[StorageObjects:0]o-iscsi................................................................................[Targets:1]|o-iqn.2016-02.xyz.abc:identifier........................................................[TPGs:1]|o-tpg1...................................................................[no-gen-acls,no-auth]|o-acls..............................................................................[ACLs:1]||o-iqn.2016-02.xyz.abc:identifier...........................................[MappedLUNs:2]||o-mapped_lun0.....................................................[lun0block/disk0(rw)]||o-mapped_lun1.....................................................[lun1block/disk1(rw)]|o-luns..............................................................................[LUNs:2]||o-lun0.............................................................[block/disk0(/dev/sdb)]||o-lun1.............................................................[block/disk1(/dev/sdc)]|o-portals........................................................................[Portals:1]|o-192.168.10.10:3260...................................................................[OK]o-loopback.............................................................................[Targets:0]/>exitGlobalprefauto_save_on_exit=trueLast10configssavedin/etc/target/backup.Configurationsavedto/etc/target/saveconfig.json

配置开机自动启动

systemctlstatustarget.servicesystemctlenabletarget.service

三.客户端配置

1.安装

[root@localhost ~]# yum install iscsi-initiator-utils

2.编辑配置文件

[root@localhost ~]# vi /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2016-02.xyz.abc:identifier

3.查看

[root@localhost ~]# iscsiadm-mdiscovery-tst-p 192.168.10.10192.168.10.10:3260,1 iqn.2016-02.xyz.abc:identifier

4.使用

[root@localhost~]#iscsiadm-mnode-Tiqn.2016-02.xyz.abc:identifier-p192.168.10.10--loginLogginginto[iface:default,target:iqn.2016-02.xyz.abc:identifier,portal:192.168.10.10,3260](multiple)Loginto[iface:default,target:iqn.2016-02.xyz.abc:identifier,portal:192.168.10.10,3260]successful.

5.格式化

[root@localhost ~]# mkfs.xfs /dev/sdb[root@localhost ~]# mkfs.xfs /dev/sdc

6.写入/etc/fstab

[root@localhost~]#blkid|egrep (sdb|sdc) /dev/sdb:UUID="c2b6b91a-7197-4e8b-90b3-ad8c09ff931f"TYPE="xfs"/dev/sdc:UUID="8df58e2f-3105-4d2e-9a01-c7931af91a3e"TYPE="xfs"[root@localhost~]#vim/etc/fstab/dev/mapper/rhel-root/xfsdefaults11UUID=8d922f42-25a9-42aa-aee2-6e29b1ac7f1a/bootxfsdefaults12/dev/mapper/rhel-swapswapswapdefaults00/dev/cdrom/media/cdromiso9660defaults00UUID=c2b6b91a-7197-4e8b-90b3-ad8c09ff931f/iscsi1xfsdefaults,_netdev00UUID=8df58e2f-3105-4d2e-9a01-c7931af91a3e/iscsi2xfsdefaults,_netdev00

7.挂载

[root@localhost~]#mkdir/iscsi1/iscsi2[root@localhost~]#mount-a[root@localhost~]#df-hFilesystemSizeUsedAvailUse%Mountedon/dev/mapper/rhel-root18G940M17G6%/devtmpfs484M0484M0%/devtmpfs490M0490M0%/dev/shmtmpfs490M6.7M484M2%/runtmpfs490M0490M0%/sys/fs/cgroup/dev/sr03.5G3.5G0100%/media/cdrom/dev/sda1497M87M411M18%/boot/dev/sdb2.0G33M2.0G2%/iscsi1/dev/sdc2.0G33M2.0G2%/iscsi2

iscsiadm的使用方法

查看服务器共享的设备iscsiadm-mdiscovery-tst-p 192.168.10.10显示已发现节点信息iscsiadm-mnode登陆iscsiadm-mnode-Tiqn.2016-2.xyz.abc:identifier-p 192.168.120.198l登出iscsiadm-mnode-Tiqn.2016-2.xyz.abc:identifier-p 192.168.120.198-u删除目标器节点信息:iscsiadm-mnode-odelete-Tiqn.2016-2.xyz.abc:identifier-p 192.168.10.10
全部评论(0)