2020欧洲杯官方投注-2020欧洲杯官方投注网址Linux幼功学习-使用iSCSI服务配置互连网存款和储蓄

使用iSCSI服务配置网络存款和储蓄

iSCSI本事完成了物理硬盘设备与TCP/IP互连网协议的并行结合,使得客户能够透过互连网方便地采访远程机房提供的共享存储能源.上面介绍怎么着在Linux上陈设iSCSI服务端程序,并各自付与Linux系统和Windows系统来拜会远程的囤积能源.

2020欧洲杯官方投注-2020欧洲杯官方投注网址 1

实验境况

主机名称 操作系统 IP地址
iSCSI服务端 RHEL7 192.168.56.15
iSCSI客户端 CentOS7 192.168.56.5
windows7客户端 windows7 192.168.56.100

1.安装iSCSI服务

[root@iSCSI-Server ~]# yum install targetd targetcli -y

//启动iSCSI服务并加入开机自启动
[root@iSCSI-Server ~]# systemctl start targetd && systemctl enable targetd
Created symlink from /etc/systemd/system/multi-user.target.wants/targetd.service to /usr/lib/systemd/system/targetd.service.

2.配备iSCSI服务分享能源

//我们要添加sdb这块磁盘
[root@iSCSI-Server ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk 
├─sda1   8:1    0  500M  0 part /boot
├─sda2   8:2    0    1G  0 part [SWAP]
└─sda3   8:3    0 48.5G  0 part /
sdb      8:16   0    2T  0 disk 
sr0     11:0    1  3.8G  0 rom  /mnt

[root@iSCSI-Server ~]# targetcli 
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb46
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]
/> cd /backstores/block 
Created block storage object disk0 using /dev/sdb.
/backstores/block> ls
o- block ............................................................ [Storage Objects: 1]
  o- disk0 .................................... [/dev/sdb (2.0TiB) write-thru deactivated]
    o- alua ............................................................. [ALUA Groups: 1]
      o- default_tg_pt_gp ................................. [ALUA state: Active/optimized]
/backstores/block> 

3.创建iSCSI target名称及布局分享财富

/backstores/block> cd /
/> cd iscsi 
/iscsi> create 
Created target iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi .................................................................... [Targets: 1]
  o- iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412 ............ [TPGs: 1]
    o- tpg1 ....................................................... [no-gen-acls, no-auth]
      o- acls .................................................................. [ACLs: 0]
      o- luns .................................................................. [LUNs: 0]
      o- portals ............................................................ [Portals: 1]
        o- 0.0.0.0:3260 ............................................................. [OK]
/iscsi> cd iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412
/iscsi/iqn.20....a5b591427412> ls
o- iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412 .............. [TPGs: 1]
  o- tpg1 ......................................................... [no-gen-acls, no-auth]
    o- acls .................................................................... [ACLs: 0]
    o- luns .................................................................... [LUNs: 0]
    o- portals .............................................................. [Portals: 1]
      o- 0.0.0.0:3260 ............................................................... [OK]
/iscsi/iqn.20....a5b591427412> cd tpg1
/iscsi/iqn.20...91427412/tpg1> ls
o- tpg1 ........................................................... [no-gen-acls, no-auth]
  o- acls ...................................................................... [ACLs: 0]
  o- luns ...................................................................... [LUNs: 0]
  o- portals ................................................................ [Portals: 1]
    o- 0.0.0.0:3260 ................................................................. [OK]
/iscsi/iqn.20...91427412/tpg1> cd luns 
/iscsi/iqn.20...412/tpg1/luns> create /backstores/block/disk0 
Created LUN 0.
/iscsi/iqn.20...412/tpg1/luns> ls
o- luns ........................................................................ [LUNs: 1]
  o- lun0 .................................... [block/disk0 (/dev/sdb) (default_tg_pt_gp)]
/iscsi/iqn.20...412/tpg1/luns> 

4.安装访问调控列表(ACL).

/iscsi/iqn.20...412/tpg1/luns> cd ..
/iscsi/iqn.20...91427412/tpg1> ls
o- tpg1 ........................................................... [no-gen-acls, no-auth]
  o- acls ...................................................................... [ACLs: 0]
  o- luns ...................................................................... [LUNs: 1]
  | o- lun0 .................................. [block/disk0 (/dev/sdb) (default_tg_pt_gp)]
  o- portals ................................................................ [Portals: 1]
    o- 0.0.0.0:3260 ................................................................. [OK]
/iscsi/iqn.20...91427412/tpg1> 
/iscsi/iqn.20...91427412/tpg1> cd acls 
/iscsi/iqn.20...412/tpg1/acls> ls
o- acls ........................................................................ [ACLs: 0]
/iscsi/iqn.20...412/tpg1/acls> create iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412:client
Created Node ACL for iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412:client
Created mapped LUN 0.
/iscsi/iqn.20...412/tpg1/acls> 

5.设置iSCSI服务端的监听IP地址和端口号.

/iscsi/iqn.20...412/tpg1/acls> cd ..
/iscsi/iqn.20...91427412/tpg1> ls
o- tpg1 ........................................................... [no-gen-acls, no-auth]
  o- acls ...................................................................... [ACLs: 1]
  | o- iqn.2003-01.org.linux-iscsi.iscsi-server.x8664:sn.a5b591427412:client  [Mapped LUNs: 1]
  |   o- mapped_lun0 ............................................. [lun0 block/disk0 (rw)]
  o- luns ...................................................................... [LUNs: 1]
  | o- lun0 .................................. [block/disk0 (/dev/sdb) (default_tg_pt_gp)]
  o- portals ................................................................ [Portals: 1]
    o- 0.0.0.0:3260 ................................................................. [OK]
/iscsi/iqn.20...91427412/tpg1> cd portals/
/iscsi/iqn.20.../tpg1/portals> ls
o- portals .................................................................. [Portals: 1]
  o- 0.0.0.0:3260 ................................................................... [OK]
/iscsi/iqn.20.../tpg1/portals> create 192.168.56.15
/iscsi/iqn.20.../tpg1/portals> cd /
/> saveconfig 
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@iSCSI-Server ~]# 

6.配置妥贴后检查布署新闻,重启iSCSI服务端程序并布署防火墙计策.

[root@iSCSI-Server ~]# systemctl restart targetd

//防火墙可以如下配置
[root@iSCSI-Server ~]# firewall-cmd --permanent --add-port=3260/tcp
[root@iSCSI-Server ~]# firewall-cmd --reload

咱俩为何要在巨型仓库储存领域中使用iSCSI适配器

配置Windows客户端.

1.运作iSCSI发起程序.

在Windows7操作系统中早已暗许安装了iSCSI客商端程序,大家只要求在调控面板中找到系统和安全标签,然后点击管理工具,进入到管理工具页面后点击iSCSI发起程序.在率先次运营iSCSI发起程序时,系统会唤醒Mirosoft iSCSI服务端未运行,点击按键就可以自行运行并运转iSCSI发起程序.

2.扫描发掘iSCSI服务端上可用的积存能源.

随意是Windows系统照旧Linux系统,要想利用iSCSI分享存款和储蓄能源都必需先举行围观发掘操作.运维iSCSI发起程序后在目标选项卡的目标文本框写入iSCSI服务器的IP地址,然后点击快速连接按钮.

在弹出的快速链接提醒框中可观看分享的硬盘存储财富,点击完成开关就可以.

iSCSI 是豆蔻梢头种块级其余磋商,用于通过TCP/IP网络共享原来存款和储蓄设备2020欧洲杯官方投注-2020欧洲杯官方投注网址,,能够用早就存在的IP和以太网如网卡、沟通机、路由器等经过iSCSI协议分享和访谈存款和储蓄。iSCSI target是后生可畏种由长途iSCSI服务器(target卡塔 尔(英语:State of Qatar)提供的长途硬盘。

配置Linux客户端.

iscsiadm是用以管理、查询、插入、更新或删除iSCSI数据库配置文件的命令行工具,客商供给先接收那些工具扫描开掘远程iSCSI服务端,然后查看找到的服务端上有哪些可用的共享存款和储蓄财富.

-m discovery参数的目标是扫描并发掘可用的存款和储蓄能源
-t st参数为实践扫描操作的花色
-p 192.168.56.15参数为iSCSI服务端的IP地址

-m node参数为将顾客端所在主机作为意气风发台节点服务器
-T 参数为要使用的存款和储蓄能源
-p 192.168.56.15参数为对方iSCSI服务器IP的地点
--login或-l参数进行登入验证

//安装iSCSI客户端服务程序initiator.默认RHEL7已经安装了.
[root@iSCSI-Client ~]# yum install iscsi-initiator-utils -y

//编辑名称文件
[root@iS
CSI-Client ~]# vim /etc/iscsi/initiatorname.iscsi 

//重启客户端服务程序
[root@iSCSI-Client ~]# systemctl restart iscsid
[root@iSCSI-Client ~]# systemctl enable iscsid
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service.

//先发现再登录
[root@iSCSI-Client ~]# iscsiadm -m discovery -t st -p 192.168.56.15
192.168.56.15:3260,1 iqn.2003-01.org.linux-iscsi.qdlinux.x8664:sn.f32bb7ada923

//使用iscsiadm命令发现远程服务器上可用的存储资源后,接下来准备登陆iSCSI服务器
[root@iSCSI-Client ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.qdlinux.x8664:sn.f32bb7ada923 -p 192.168.56.15 --login

登录成功后翻看一下意识多了一块磁盘

[root@iSCSI-Client ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk 
├─sda1   8:1    0  500M  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 47.5G  0 part /
sdb      8:16   0    2T  0 disk 
sdc      8:32   0    2T  0 disk 
sr0     11:0    1  4.2G  0 rom  /mnt

[root@iSCSI-Client ~]# file /dev/sdc
/dev/sdc: block special

//查看设备UUID
[root@iSCSI-Client ~]# blkid
/dev/sda1: UUID="2b924cf3-3741-4489-afda-20ad6c3b8366" TYPE="xfs" 
/dev/sda2: UUID="c8ad89d6-ca56-4120-a4b6-5d9c54976bbb" TYPE="swap" 
/dev/sda3: UUID="780d3cde-84a6-4f98-a800-94b0dc7f57f9" TYPE="xfs" 
/dev/sr0: UUID="2018-05-03-20-55-23-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/sdc: UUID="28619840-b497-49ca-92c6-c530a850dd40" TYPE="xfs" 

//开机自动挂载,由于iSCSI基于TCP/IP网络传输数据的
//因此必须在fstab配置文件中加上`_netdev`参数
//表示当系统联网后再进行挂载操作,以免系统开机时间过长或开机失败.
[root@iSCSI-Client ~]# vim /etc/fstab 
UUID=28619840-b497-49ca-92c6-c530a850dd40 /iscsi                  xfs      defaults,_netdev 0 0

[root@iSCSI-Client ~]# mount -a
[root@iSCSI-Client ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        48G  4.6G   43G  10% /
devtmpfs        472M     0  472M   0% /dev
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           488M  8.0M  480M   2% /run
tmpfs           488M     0  488M   0% /sys/fs/cgroup
/dev/sr0        4.2G  4.2G     0 100% /mnt
/dev/sda1       497M  148M  350M  30% /boot
tmpfs            98M     0   98M   0% /run/user/0
/dev/sdc        2.0T   33M  2.0T   1% /iscsi

//如果不再需要使用iSCSI共享设备资源了,可以使用iscsiadm命令的-u参数将其卸载.
[root@iSCSI-Client ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.qdlinux.x8664:sn.f32bb7ada923 -u
Logging out of session [sid: 1, target: iqn.2003-01.org.linux-iscsi.qdlinux.x8664:sn.f32bb7ada923, portal: 192.168.56.15,3260]
Logout of [sid: 1, target: iqn.2003-01.org.linux-iscsi.qdlinux.x8664:sn.f32bb7ada923, portal: 192.168.56.15,3260] successful.

主服务器设置

  • 操作系统 – CentOS 6.5 (Final)
  • iSCSI 目标器 IP – 192.168.0.200
  • 应用的端口 : TCP 860, 3260
  • 配置文件 : /etc/tgt/targets.conf

缘何必要iSCSI?

在设想化中,大家必要仓库储存具备惊人的冗余性、稳固性,iSCSI以低本钱的方法提供了这么些特色。与应用光导纤维通道的SAN比起来,大家得以行使已经存在的配备举例NIC、以太网交流机等建筑四个低本钱的SAN。

以后本身开头使用iSCSI 指标器安装并配备安全存款和储蓄。本篇中,大家依据上边包车型大巴步骤:

  • 咱俩须求隔绝多个体系来安装iSCSI 指标器和提倡程序(顾客端卡塔 尔(英语:State of Qatar)。
  • 在巨型仓库储存情形中能够加上七个硬盘,可是此地大家除了核心的安装盘之外只行使了八个外加的驱动器。
  • 此间我们只利用了2块硬盘,三个用以着力的服务器安装,别的贰个用以存款和储蓄(LUN卡塔 尔(英语:State of Qatar),这么些大家会在这里个体系的第二篇描述。

本文由2020欧洲杯官方投注-2020欧洲杯官方投注网址发布于win7,转载请注明出处:2020欧洲杯官方投注-2020欧洲杯官方投注网址Linux幼功学习-使用iSCSI服务配置互连网存款和储蓄

相关阅读