网络共享虚拟硬盘 :iscsi

(一)基础知识

DAS,NAS和SAN都代表什么意思?
   直接连接存储(Direct Attached Storage,简称DAS),是通常放置在服务器机箱内部的驱动器,通常是SCSI连接。DAS驱动器也可以放置在外部机箱内,但是通过有限长度的SCSI电缆进行连接的。
   网络连接存储(Network Attached Storage,简称NAS)是单独连接到局域网上的设备,但是仅仅提供基于文件的存储。简单地说,NAS机器是专用的文件服务器,但是它没有运行应用程序的能力,而是分配它们所有的资源,用来文件共享。有时也称为“Filers”。
    存储区域网络(Storage Area Network ,简称SAN)通常用来指专用的**硬盘存储阵列**,通过光纤通道链路连接到不少主机上,这个光纤通道来自一个光纤通道交换机,该交换机可为所有的设备提供高速“Hub”功能。

(二)iscsi的概念

    虚拟磁盘就是在本地电脑里面虚拟出一个远程电脑里面的磁盘。感觉像是在本机上的硬盘一样。其实他没在本机上。
    网络虚拟磁盘iSISC可以加大网吧客户机硬盘容量,高速安全稳定.iSCSI Cake主要用于网吧共享硬盘服务。 
    客户端可以通过局域网连接服务器上的iSCSI Cake服务器,在本地虚拟出一块硬盘,以达到通过网络共享服务器硬盘的效果。网吧业主只需要在服务器上的iSCSI Cake里添加目录和安装游戏软件,客户端的本地虚拟硬盘里就有了相应的游戏软件,不需要到每台机器进行安装。
    iSCSI( Internet Small Computer System Interface 互联网小型计算机系统接口)是由IBM 下属的两大研发机构一一加利福尼亚AImaden和以色列Haifa研究中心共同开发的,是一个供硬件设备使用的、可在IP协议上层运行的SCSI指令集,是一种开放的基于IP协议的工业技术标准。该协议可以用TCP/IP对SCSI指令进行封装,使得这些指令能够通过基于P网络进行传输,从而实现SCSI 和TCP/IP协议的连接。对于局域网环境中的用户来说,采用该标准只需要不多的投资就可以方便、快捷地对信息和数据进行交互式传输及管理。

(三)iscsi的优势
在使用iscsi时,比NFS更加节省资源,时间,过程
图解iscsi:
这里写图片描述

(四)iscsi的配置
1)在server服务端上,先建立lvm设备(动态分配空间):

root@server ~]# fdisk /dev/vda 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x60505aa3.

Command (m for help): p

Disk /dev/vda: 8589 MB, 8589934592 bytes, 16777216 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: 0x60505aa3

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-16777215, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): +500M
Partition 1 of type Linux and of size 500 MiB is set

Command (m for help): p

Disk /dev/vda: 8589 MB, 8589934592 bytes, 16777216 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: 0x60505aa3

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1            2048     1026047      512000   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/vda: 8589 MB, 8589934592 bytes, 16777216 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: 0x60505aa3

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1            2048     1026047      512000   8e  Linux LVM

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@server ~]# partprobe 
[root@server ~]# pvcreate /dev/vda1
  Physical volume "/dev/vda1" successfully created
[root@server ~]# vgcreate iscsi_vg /dev/vda1
  Volume group "iscsi_vg" successfully created
[root@server ~]# vgdisplay 
  --- Volume group ---
  VG Name               iscsi_vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               496.00 MiB
  PE Size               4.00 MiB
  Total PE              124
  Alloc PE / Size       0 / 0   
  Free  PE / Size       124 / 496.00 MiB
  VG UUID               AtkgEm-L3sg-EkWu-zNof-kurk-7ykw-AWv5nG

[root@server ~]# lvcreate -l 124 -n iscsi_lv0 iscsi_vg
  Logical volume "iscsi_lv0" created.
[root@server ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/iscsi_vg/iscsi_lv0
  LV Name                iscsi_lv0
  VG Name                iscsi_vg
  LV UUID                odU0t7-bbVS-JJfS-WHX7-kRXN-dQP1-rI376c
  LV Write Access        read/write
  LV Creation host, time server, 2017-12-12 21:34:14 +0800
  LV Status              available
  # open                 0
  LV Size                496.00 MiB
  Current LE             124
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           252:0

2 安装软件:

yum install targetcli.noarch ##安装iSCSI目标软件包
systemctl enable target.service ##开启target服务

在火墙上开启端口:

这里写图片描述

3 开启服务:

这里写图片描述

4进入iSCSI目标交互式配置模式

[root@server ~]# targetcli       ##进入iSCSI目标交互式配置模式
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 ....................................... [Targets: 0]
/> /backstores/block create server1storage /dev/vg0/iscsi_storage   ##和逻辑卷建立联系,把/dev/vg0/iscsi_storage用server1storage表示
Created block storage object server1storage using /dev/vg0/iscsi_storage.
/> /iscsi create iqn.2017-12.com.example:strage1        ##创建iqn服务的名称(每个发起端和目标需要唯一名称进行标识)
Created target iqn.2017-12.com.example:strage1.
Created TPG 1.
/> ls
o- / ....................................................... [...]
  o- backstores ............................................ [...]
  | o- block ................................ [Storage Objects: 1]
  | | o- server1storage  [/dev/vg0/iscsi_storage (996.0MiB) write-thru deactivated]
  | o- fileio ............................... [Storage Objects: 0]
  | o- pscsi ................................ [Storage Objects: 0]
  | o- ramdisk .............................. [Storage Objects: 0]
  o- iscsi .......................................... [Targets: 1]
  | o- iqn.2017-12.com.example:strage1 ................. [TPGs: 1]
  |   o- tpg1 ............................. [no-gen-acls, no-auth]
  |     o- acls ........................................ [ACLs: 0]
  |     o- luns ........................................ [LUNs: 0]
  |     o- portals .................................. [Portals: 0]
  o- loopback ....................................... [Targets: 0]
/> /iscsi/iqn.2017-12.com.example:strage1/tpg1/luns create /backstores/block/server1storage         ##加密(默认情况下,网络通信是至iSCSI目标上的端口3260/tcp的明文)
Created LUN 0.
/> /iscsi/iqn.2017-12.com.example:strage1/tpg1/acls create iqn.2017-12.com.example:server1storagekey
Created Node ACL for iqn.2017-12.com.example:server1storagekey
Created mapped LUN 0.
/> /iscsi/iqn.2017-12.com.example:strage1/tpg1/portals create 172.25.254.138
Using default IP port 3260
Created network portal 172.25.254.138:3260.
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

出现的问题:在创建portals时报错:

这里写图片描述
原因:因为已经存在了一个IP和端口,需要删除
解决:删除它
这里写图片描述
查看,没有了:
这里写图片描述
新建portals,成功:
这里写图片描述
这时在服务端就设置完成了。
5 我们在客户端设置:
安装软件:
1)
这里写图片描述

2)
vim /etc/iscsi/initiatorname.iscsi  ##进入配置文件
InitiatorName=iqn.2017-12.com.example:server1storagekey ##钥匙
systemctl restart iscsi ##重启服务

iscsiadm -m discovery -t st -p 172.25.254.138 ##识别查询设备
iscsiadm -m node -T iqn.2017-12.com.example:strage1 -p 172.25.254.138 -l ##远程连接存储块
mkfs.xfs /dev/sda   ##格式化硬盘
mount /dev/sda /mnt/   ##挂载硬盘,进行远程存储。

这时我们就可以当作自己的硬盘使用了。我们可以在挂载目录里创建文件。
这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

6实现自动化挂载:
在客户端:

vim /etc/fstab
10 UUID=2da90fa4-582e-4c16-863a-bd6d83587e8f /mnt xfs defaults,_netdev  0  0   ##尽量使用uuid挂载,因为在每次开机时,这个服务会发生漂移!!。

注意:一定是先启动网络再挂载。

7 删除iscsi设备:
1)在服务端:

[root@server ~]# targetcli 
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> clearconfig confirm=True  ##确定删除。
All configuration cleared
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

2)在客户端:

在客户端删除:
iscsiadm -m node -T iqn.2017-12.com.example:strage1 -p 172.25.254.138 -u ##退出iSCSI目标,以暂时断开连接。
iscsiadm -m node -T iqn.2017-12.com.example:strage1 -p 172.25.254.138 -o delete ##删除iSCSI目标的本地记录,以永久断开连接。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第1章安装WindowsServer2012R254分钟5节 1-1IT运维职位需要掌握的技能04:40 1-2介绍Windows版本06:39 1-3安装WindowsServer2012R19:35 1-4熟悉操作环境11:58 1-5高级启动选项11:27 第2章配置WindowsServer2012环境2小时32分钟12节 2-1取消增强的IE安全设置06:25 2-2设置IE安全首页和12:36 2-3安装桌面体验09:19 2-4安装管理工具09:35 2-5使用MMC整合管理工具02:53 2-6Windows上注册表24:55 2-7Windows上的服务18:57 2-8系统配置工具MSconfig09:47 2-9Windows高级安全防火墙10:19 2-10Windows高级防火墙220:34 2-11系统设置16:45 2-12管理设备10:18 第3章管理用户和组1小时35分钟9节 3-1用户SID和用户令牌09:32 3-2管理用户查看用户令牌11:36 3-3将用户添加到组04:04 3-4用户账户控制14:13 3-5更改密码 使用密码重置盘重设密码15:10 3-6使用WindowsPE重设管理员密码08:16 3-7镜像账户和缓存的网络凭证11:58 3-8管理保存的网络凭证08:51 3-9用户配置文件11:42 第4章搭建域环境1小时47分钟12节 4-1工作中和域适用场景12:31 4-2介绍如何搭建域环境08:20 4-3DNS定位域控制器05:08 4-4安装配置活动目录和DNS12:13 4-5安装活动目录后的检查02:51 4-6将计算机加入域07:42 4-7强制域控制器向DNS注册SRV记录07:16 4-8体验集成身份验证16:06 4-9集成身份验证如何实现13:39 4-10域控制器和集成身份验证06:43 4-11体验统一管理09:48 4-12介绍软件学院域环境05:09 第5章NTFS管理数据3小时16节 5-1介绍文件系统09:44 5-2NTFS权限应用规则10:01 5-3文件夹权限详解14:54 5-4高级NTFS权限06:28 5-5修改继承的权限06:56 5-6设置提交试卷文件夹权限14:27 5-7允许用户创建私有空间的文件夹权限05:39 5-8不允许修改提交的文件06:18 5-9文件和文件夹的所有权13:45 5-10加密文件系统(EFS)原理详解14:35 5-11使用EFS加密文件16:35 5-12Bitlocker加密硬盘21:22 5-13数据压缩10:34 5-14移动文件对压缩和加密状态的影响08:04 5-15磁盘限额09:09 5-16卷影副本11:34 第6章搭建文件服务器1小时36分钟12节 6-1文件服务器要求17:17 6-2共享权限和NTFS权限12:29 6-3多次共享和隐藏共享04:31 6-4管理默认共享02:52 6-5发布共享文件夹到活动目录04:05 6-6访问共享文件夹方法03:56 6-7限制文件夹大小08:25 6-8介绍分布式文件系统DFS06:52 6-9准备DFS环境06:43 6-10安装和配置DFS18:04 6-11验证DFS容错02:39 6-12DFS妙用解决实际问题08:24 第7章性能优化41分钟4节 7-1任务管理器监控内存和CPU13:34 7-2资源监视器监控性能07:53 7-3性能监视器监控和跟踪性能13:23 7-4管理Windows日志07:04 第8章本地安全策略2小时20分钟12节 8-1密码策略14:28 8-2账户锁定策略12:18 8-3审核策略18:21 8-4给手机发短信报告安全事件14:15 8-5用户权利指派16:04 8-6安全选项12:24 8-7Guest身份和空密码访问11:39 8-8软件限制策略11:55 8-9启用高级审核策略11:28 8-10跟踪用户登录和关闭自动播放06:13 8-11禁止打开注册表和命令提示符03:19 8-12登录注销脚本08:00 第9章配置网络打印机57分钟10节 9-1本地打印机和网络打印机08:32 9-2安装打印服务器09:48 9-3设置打印机权限和打印时间06:53 9-4使用组策略部署打印机05:03 9-5使用脚本部署打印机04:10 9-6启用打印池04:49 9-7设置打印机优先级06:02 9-8将打印机发布到活动目录03:05 9-9Internet打印05:43 9-10添加网络接口打印机02:59 第10章磁盘管理3小时15分钟19节 10-1硬盘物理结构07:51 10-2主分区和逻辑分区12:10 10-3计算机启动过程14:53 10-4操作系统启动过程15:28 10-5基本磁盘管理11:42 10-6管理盘符和路径08:46 10-7介绍简单卷和条带卷08:31 10-8介绍镜像卷和RAID-510:30 10-9创建简单卷和条带卷07:19 10-10创建RAID-5和镜像卷06:45 10-11修复失败的镜像卷和RAID-505:40 10-12移动动态磁盘04:26 10-13介绍存储池和虚拟磁盘06:04 10-14创建存储池和虚拟磁盘16:14 10-15磁盘碎片整理19:36 10-16详解iSCSI网络存储10:10 10-17安装网络存储服务14:14 10-18配置网络存储服务器08:25 10-19WindowsStorageServer201206:21 第11章 网络负载均衡和流量控制1小时4分钟6节 11-1介绍NIC组合05:00 11-2配置网卡(NIC)组合12:46 11-3网络负载均衡应用场景13:30 11-4安装配置NLB16:05 11-5介绍QoS流量控制08:28

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值