为什么80%的码农都做不了架构师?>>>   

实验机器
服务器端:192.168.1.33(virtual)
XP客户端: 192.168.1.35
RHEL6客户端:192.168.1.45 (virtual)

----------

服务器端:

1、给33机器添加一块硬盘。(普通的文件(file)、逻辑卷(LVM)、物理硬盘分区(partition))

[root@virt ~]# fdisk -l | grep sdb
Disk /dev/sdb: 5368 MB, 5368709120 bytes

2、安装iscsi服务器端。

yum install scsi-target-utils

3、编辑iscsi

<target bd.kl>
backing-store /dev/sdb #后加入的硬盘
initiator-address 192.168.1.45 #指定IP
initiator-address 192.168.1.35 #指定IP
</target>

4、检查是否加载成功

[root@virt ~]# tgt-admin --show
Target 1: bd.klSystem information:Driver: iscsiState: readyI_T nexus information:LUN information:LUN: 0Type: controllerSCSI ID: IET     00010000SCSI SN: beaf10Size: 0 MB, Block size: 1Online: YesRemovable media: NoPrevent removal: NoReadonly: NoBacking store type: nullBacking store path: NoneBacking store flags:Account information:ACL information:192.168.1.45192.168.1.35

这服务端就开启了~

----------

客户端:

1、扫描 iscsiadm -m discovery -t st -p 192.168.1.33

[root@ns ~ 17:29 #18]# iscsiadm  -m  discovery  -t  sendtargets  \
-p 192.168.1.33192.168.1.33:3260,1 bd.kl

2、连接 iscsiadm -m node -T bd.kl -p 192.168.1.33

[root@ns ~ 20:02 #20]#  iscsiadm -m node -T bd.kl -p 192.168.1.33 -l
Logging in to [iface: default, target: bd.kl, portal: 192.168.1.33,3260] (multiple)
Login to [iface: default, target: bd.kl, portal: 192.168.1.33,3260] successful.

3、已经挂载上,用fdisk查看

[root@ns ~ 20:03 #21]# fdisk -lDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2611    20970496   83  LinuxDisk /dev/sdb: 5368 MB, 5368709120 bytes
166 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 10292 * 512 = 5269504 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x47ef00d7Device Boot      Start         End      Blocks   Id  System

或者用驱动查看

[root@ns ~ 20:04 #22]# dmesg|tail
scsi 6:0:0:0: RAID              IET      Controller       0001 PQ: 0 ANSI: 5
scsi 6:0:0:0: Attached scsi generic sg2 type 12
scsi 6:0:0:1: Direct-Access     IET      VIRTUAL-DISK     0001 PQ: 0 ANSI: 5
sd 6:0:0:1: Attached scsi generic sg3 type 0
sd 6:0:0:1: [sdb] 10485760 512-byte logical blocks: (5.36 GB/5.00 GiB)
sd 6:0:0:1: [sdb] Write Protect is off
sd 6:0:0:1: [sdb] Mode Sense: 49 00 00 08
sd 6:0:0:1: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUAsdb:
sd 6:0:0:1: [sdb] Attached SCSI disk

很清晰是SCSI硬盘。

4、开始挂载

fdisk分区。。。fdisk /dev/sdb -> p -> n -> -> w -> q

分完了,看一下

[root@ns ~ 20:09 #27]# fdisk /dev/sdb -lDisk /dev/sdb: 5368 MB, 5368709120 bytes
166 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 10292 * 512 = 5269504 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x47ef00d7Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1018     5238597   83  Linux
[root@ns ~ 20:11 #30]# mkdir -p /Volume/sdb
[root@ns ~ 20:12 #32]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1309649 blocks
65482 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@ns ~ 20:11 #31]# vi /etc/fstab
/dev/sdb1               /Volume/sdb             ext4    defaults        0 0

挂载最后一步

[root@ns ~ 20:13 #33]# mount -a

成功。

5、卸载SCSI硬盘,如果不卸载开机会启动不了。

[root@ns ~ 20:13 #34]# iscsiadm -m node -T bd.kl -p 192.168.1.33 --logout
Logging out of session [sid: 4, target: bd.kl, portal: 192.168.1.33,3260]
Logout of [sid: 4, target: bd.kl, portal: 192.168.1.33,3260] successful.

如果真的没卸载重启启动不起来,那么

进入单用户模式

[root@virt ~]# chkconfig | grep iscsi
iscsi           0:off   1:off   2:off   3:on    4:on    5:on    6:off
iscsid          0:off   1:off   2:off   3:on    4:on    5:on    6:off
[root@virt ~]# chkconfig --level 345 iscsi off
[root@virt ~]# chkconfig --level 345 iscsid off

然后进去了再挂载。

OVER.

客户端为WINDOWS

1、下载

在http://www.microsoft.com/en-us/download/details.aspx?id=18986下载

Microsoft iSCSI Software Initiator

安装后

完成。

如果没有识别的话去设备管理删掉问好的那个SCSI。直接点卸载或删除。

----------------------

下边写一下部分注释的配置文件。

ISCSI-SERVER/etc/tgt/targets.conf# This is a sample config file for tgt-admin.
# The files ending with '.conf' in this directory will be included.
#
# The "#" symbol disables the processing of a line.#只有一个逻辑单元的简单例子,默认允许所有的initiators发起访问。
# Sample target with one LUN only. Defaults to allow access for all initiators:#<target iqn.2008-09.com.example:server.target1>
#    backing-store /dev/LVM/somedevice
#</target>与上面的相同,但是使用direct-store替代backing-srore
# Similar, but we use "direct-store" instead of "backing-store".
# "direct-store" reads drive parameters with sg_inq command and sets them to
//direct-store 读取设备sg_inq参数
# the target.
# Parameters fatched with sg_inq are:
# - Vendor identification
# - Product identification
# - Product revision level
# - Unit serial number (if present)
# We also specify "incominguser".一个指定了incominguser的例子
#<target iqn.2008-09.com.example:server.target2>
#    direct-store /dev/sdd
#    incominguser someuser secretpass12
#</target>一个含有多个逻辑单元的例子,禁止了write-cache(tgtd 默认允许write-cache),设备供应商设置为"MyVendor"
# An example with multiple LUNs, disabled write-cache (tgtd enables write-cache
# by default) and vendor identification set to "MyVendor"#<target iqn.2008-09.com.example:server.target3>
#    backing-store /dev/LVM/somedevice1 # Becomes LUN 1
#    backing-store /dev/LVM/somedevice2 # Becomes LUN 2
#    backing-store /dev/LVM/somedevice3 # Becomes LUN 3
#    write-cache off
#    vendor_id MyCompany Inc.
#</target>与上相同,但我们从磁盘本身读取vendor_id, product_id, product_rev 和scsi_sn
# Similar to the one above, but we fetch vendor_id, product_id, product_rev and
# scsi_sn from the disks.
# Vendor identification (vendor_id) is replaced in all disks by "MyVendor"
其中vendor_id参数被设置的MyCompany Inc替代磁盘原有的参数。#<target iqn.2008-09.com.example:server.target4>
#    direct-store /dev/sdb  # Becomes LUN 1
#    direct-store /dev/sdc  # Becomes LUN 2
#    direct-store /dev/sdd  # Becomes LUN 3
#    write-cache off
#    vendor_id MyCompany Inc.
#</target># Note that "first-device-first-lun numbering" will work only for simple
# scenarios above, where _only_ direct-store _or_ backing-store is used.
# If you mix backing-store and direct-store, then all backing-store entries
# are processed before direct-store-entries.值得注意第一个LUN设备,即为LUN0,这种情况只适合以上简单的情景。即只有 direct-store,或backing-store时。
如果要向以下这种混用,backing-store参数的逻辑单元号要在direct-store前面。#<target iqn.2008-09.com.example:server.target4>
#    direct-store /dev/sdb  # Becomes LUN 3
#    backing-store /dev/sdc # Becomes LUN 1
#    direct-store /dev/sdd  # Becomes LUN 4
#    backing-store /dev/sde # Becomes LUN 2
#</target># Even more complicated example - each device has different parameters.
甚至更复杂混乱的例子-每个设备都有不同的参数
# You can use indentation to make the config file more readable.
可以使用缩格让配置文件读起来更方便些。
# Note that LUNs will be assigned more or less randomly here (and still
# backing-store get LUNs assigned before drect-store).
注意在这里逻辑单元会被或多或少地随意地分配号码,但即便这样backing-store的逻辑单元号仍然在drect-store之前。
# You can specify multiple mode_page parameters (they are commented out
# in this example).
你可以指定复杂的mode_page参数,在例子中被注释出来。
# Note that some parameters (write-cache, scsi_sn) were specified "globally".
注意一些参数(如:write-cache,scsi_sn)具有全局参数的特性。
# "Global" parameters will be applied to all LUNs; they can be overwritten
# "locally", per LUN.
全局参数被视为适用所用的逻辑单元,他们可以被每个逻辑单元局部的配置文件所替代
# If lun is not specified, it will be allocated automatically (first available).
如果逻辑单元号码没有被指定,他将会被自动指定。#<target iqn.2008-09.com.example:server.target5>#    <direct-store /dev/sdd>
#   vendor_id VENDOR1
#   removable 1
#   device-type cd
#   lun 1
#    </direct-store>#    <direct-store /dev/sda>
#   vendor_id VENDOR2
#   lun 2
#    </direct-store>#    <backing-store /dev/sdb1>
#   vendor_id back1
#   scsi_sn SERIAL
#   write-cache on# lun 3       # lun is commented out - will be allocated automatically//lun 3被注释上了,他将会被自动指定
#   </backing-store>#    <backing-store /dev/sdd1>
#   vendor_id back2#mode_page 8:0:18:0x10:0:0xff....#mode_page 8:0:18:0x10:0:0xff....#bs-type aio
#   lun 15
#    </backing-store># Some more parameters which can be specified locally or globally:
更多的可被用于局部的和全局的参数如下:#scsi_id ...#scsi_sn ...#vendor_id ...#product_id ...#product_rev ...#sense_format ...#removable ...#online ...#path ...#mode_page 8:0:18:0x10:0:0xff....#mode_page 8:0:18:0x10:0:0xff....#device-type ...#bs-type ...    # backing store type - default rdwr, can be aio, mmap, etc...#allow-in-use yes  # if specified globally, can't be overwritten locally#    write-cache off
#    scsi_sn multipath-10# Parameters below are only global. They can't be configured per LUN.
如下的参数只能用于全局参数,而不能被用于局部
# Only allow connections from 192.168.100.1 and 192.168.200.5
只允许从192.168.100.1和192.168.200.5进行连接
#    initiator-address 192.168.100.1
#    initiator-address 192.168.200.5# Tuning parameters (global, per target)#MaxRecvDataSegmentLength 8192#MaxXmitDataSegmentLength 8192#HeaderDigest None#DataDigest None#InitialR2T Yes#MaxOutstandingR2T 1#ImmediateData Yes#FirstBurstLength 65536#MaxBurstLength 262144#DataPDUInOrder Yes#DataSequenceInOrder Yes#ErrorRecoveryLevel 0#IFMarker No#OFMarker No#DefaultTime2Wait 2#DefaultTime2Retain 20#OFMarkInt Reject#IFMarkInt Reject#MaxConnections 1# Allowed incoming users
允许访问的用户
#    incominguser user1 secretpass12
#    incominguser user2 secretpass23# Outgoing user
#    outgoinguser userA secretpassA#</target># The device will have lun 1 unless you specify something else
#<target iqn.2008-09.com.example:server.target6>
#    backing-store /dev/LVM/somedevice
#    lun 10
#</target># Devices which are in use (by system: mounted, for swap, part of RAID, or by
# userspace: dd, by tgtd for another target etc.) can't be used, unless you use
# --force flag or add 'allow-in-use yes' option
被使用中的设备(系统占用:挂载,使用中的交换分区,RAID的一部分,或用户空间:
dd, 或被其他的目标所使用)是不能被使用的,除非使用--force 或者添加allow-in-use yes参数#<target iqn.2008-09.com.example:server.target7>
#    backing-store /dev/LVM/somedevice
#    allow-in-use yes
#</target>#<target iqn.2008-09.com.example:server.target8>
#    <backing-store /dev/LVM/somedevice>
#    scsi_sn serial1
#    </backing-store>#    <backing-store /dev/LVM/somedevice2>
#    scsi_sn serial2
#    </backing-store>#    allow-in-use yes
#</target># Not supported configurations, and therefore, commented out:
不支持的配置方式,因此被注释上了。#<target iqn.2008-09.com.example:server.target9>
#    backing-store /dev/LVM/somedevice1
#    backing-store /dev/LVM/somedevice2
#    lun 10
#    lun 11
#</target>#<target iqn.2008-09.com.example:server.target10>
#    <direct-store /dev/sdd>
#    vendor_id VENDOR1
#    </direct-store>
#
#    direct-store /dev/sdc
#</target># This one will break the parser:
这个会中断解析
#<target iqn.2008-09.com.example:server.target11>
#    <direct-store /dev/sdd>
#    vendor_id VENDOR1
#    </direct-store>
#
#    direct-store /dev/sdc
#
#    <direct-store /dev/sdd>
#    vendor_id VENDOR1
#    </direct-store>
#</target>

转载于:https://my.oschina.net/HankCN/blog/116105

ISCSI LINUX(RHEL)的搭建与配置相关推荐

  1. Linux RHEL 7.9网卡配置bond0(主备模式)

    Linux RHEL 7.9网卡配置bond0(主备模式) 一.实验环境准备及规划 系统:RHEL 7.9 网卡bond0(主备模式):ens33ens37bond0:192.168.100.40 v ...

  2. Linux下SVN搭建与配置

    Linux下SVN+rsync服务器的搭建与配置 SVN作为单独服务器 一:安装与测试 1:安装 http://subversion.tigris.org/downloads/subversion-1 ...

  3. linux服务器的搭建配置与应用,linux服务器的搭建与配置

    tftp       :通过tftp能进行文件的传输,适用于给目标机文件下载. nfs      用于实现linux和linux之间实现资源的共享. samba  实现linux和window之间文件 ...

  4. Linux 服务器环境搭建及配置

    环境搭建(源码) 1.配置 JDK 1.8 运行环境 (1).新建文件夹. mkdir /opt/java (2).进入安装 jdk 的位置. cd /opt/java/ (3).利用 WinSCP ...

  5. linux中yum搭建与配置

    服务器配置: 1.把光盘中的内容全部拷到/var/ftp/Server/中 mount /dev/cdrom /mnt    //挂载光盘 rpm -ivh /mnt/Packages/vsftpd- ...

  6. Linux下svn搭建配置流程

    Linux下svn搭建配置流程     一.    源文件编译安装.源文件共两个,为: 1.   下载subversion源文件 subversion-1.6.1.tar.gz http://d136 ...

  7. Linux下svn搭建配置

    Linux下svn搭建配置 1.安装svn客户端    yum install subversion    svnserve --version                       :如果成功 ...

  8. linux中apache服务器的搭建与配置

    linux下apache服务器的搭建与配置 下面我们来介绍一下apache服务器的搭建以及配置 apache它是一种web服务器,我们可以通过apache将我们的网页挂载上去,然后提供给用户访问 首先 ...

  9. linux中ftp服务器的搭建和配置

    linux中的ftp服务的搭建及配置 1 ftp概述 2 ftp服务的搭建 2.1 ftp的客户端 2.2 FTP的服务端 2.2.1 服务端软件vsftpd的下载 2.2.2 vsftp的环境配置 ...

  10. linux ftp服务器防火墙设置,【许望】linux(RHEL) 下 FTP(vsftpd) 服务器的防火墙配置...

    linux(RHEL) 下 FTP(vsftpd) 服务器的防火墙配置 FTP服务器在与客户端通讯的过程中会用到两个端口,一个是控制端口,通常是21/tcp,一个是数据端口,运行在主动模式下的FTP服 ...

最新文章

  1. 扔掉okhttp、httpClient,来试试这款轻量级HTTP客户端神器?
  2. Ubuntu软件的安装和使用
  3. Spring系列之BeanPostProcessor分析
  4. 【Hibernate】Hibernate系列6之HQL查询
  5. Linux系统编程10:进程入门之系统编程中最重要的概念之进程进程的相关操作使用fork创建进程
  6. linux 监控java内存_Linux下实用的JAVA内存泄露监控命令及工具
  7. fragment的懒加载
  8. 大数据挖掘处理技术有哪些
  9. Thrift搭建分布式微服务(四)
  10. wireshark: You don‘t have permission to capture on that device
  11. 没注意开源软件的文档和对应版本号,悲剧了
  12. VHDL学习:两种方式实现四选一选择器
  13. 视频转换器怎样将QSV格式转换MP4视频
  14. oeasy教您玩转vim - 43 - # 替换模式
  15. Infor咨询服务调研报告-市场现状、市场份额、市场定位及未来发展趋势
  16. Unity的五个窗口面板
  17. 通过DCF模型对股票进行估值
  18. Dubbo3的Triple协议踩坑记录
  19. m基于FPGA的GPS收发系统开发,包括码同步,载波同步,早迟门跟踪环,其中L1采用QPSK,L2采用BPSK
  20. esp32 Micropython驱动ST7735 1.8寸TFT屏幕 中文显示;时间显示、网络network实时时间获取utptime;urequests、upip等包安装

热门文章

  1. 1854: [Scoi2010]游戏
  2. Restful 风格
  3. mybatis学习笔记(五):mybatis 逆向工程
  4. 基于IBM Bluemix的数据缓存应用实例
  5. 11.9 noip模拟试题
  6. 用js小类库获取浏览器的高度和宽度信息
  7. 3、electron打包生成exe文件
  8. Linux系统知识汇总
  9. Data Services Designer将数据从sql server抽取到hana
  10. Node js模块系统