主机名 IP
master 192.168.30.130
node-1 192.168.30.131
node-2 192.168.30.132

安装并启动

[root@master ~]# ll /etc/tgt/targets.conf
-rw------- root root Sep /etc/tgt/targets.conf
[root@master ~]# /etc/init.d/tgtd start
Starting SCSI target daemon: [ OK ]
[root@master ~]# chkconfig tgtd on
[root@master ~]# grep /etc/services
iscsi-target /tcp # iSCSI port
iscsi-target /udp # iSCSI port [root@master ~]# netstat -antup | grep
tcp 0.0.0.0: 0.0.0.0:* LISTEN /tgtd
tcp ::: :::* LISTEN /tgtd
[root@master ~]# netstat -antup | grep tgtd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /tgtd
tcp ::: :::* LISTEN /tgtd

将master作为存储服务器,添加一块新硬盘

[root@master ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb
[root@master ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x3c41883c.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u'). Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder, +cylinders or +size{K,M,G} (-, default ): +5G Command (m for help): p Disk /dev/sdb: 21.5 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x3c41883c Device Boot Start End Blocks Id System
/dev/sdb1 + Linux Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks. [root@master ~]# ls /dev/sdb*
/dev/sdb /dev/sdb1
[root@master ~]# mkfs.ext4 /dev/sdb1

修改配置文件

[root@master ~]# vim /etc/tgt/targets.conf
#找到这段内容,在其下方添加83-88一段内容
#<target iqn.-.com.example:server.target4>
# direct-store /dev/sdb # Becomes LUN
# direct-store /dev/sdc # Becomes LUN
# direct-store /dev/sdd # Becomes LUN
# write-cache off
# vendor_id MyCompany Inc.
#</target> <target iqn.-.cn.xuegod.www:target_san1>
backing-store /dev/sdb1
initiator-address 192.168.30.131
initiator-address 192.168.30.132
vendor_id sishen
product_id target-
</target>

重启服务

[root@master ~]# tgt-admin --show
Target : iqn.-.cn.sishen.www:target_san1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN:
Type: controller
SCSI ID: IET
SCSI SN: beaf10
Size: MB, Block size:
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN:
Type: disk
SCSI ID: IET
SCSI SN: beaf11
Size: MB, Block size:
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
Account information:
ACL information:
192.168.30.131
192.168.30.132

在客户端安装

[root@node- ~]# yum install -y iscsi-initiator-utils
[root@node- ~]# /etc/init.d/iscsid start #直接启动没有反应
[root@node- ~]# iscsiadm -m discovery -t sendtargets -p 192.168.30.130:3260 #执行完这步会有提示
Starting iscsid: [ OK ]
192.168.30.130:, iqn.-.cn.sishen.www:target_san1
[root@node- ~]# /etc/init.d/iscsi status
No active sessions
[root@node- ~]# /etc/init.d/iscsid status
iscsid (pid ) is running...
[root@node- ~]# /etc/init.d/iscsid restart
Stopping iscsid:
Starting iscsid: [ OK ]
[root@node- ~]# /etc/init.d/iscsid status
iscsid (pid ) is running...

安装tree命令查看发现的目录树

[root@node- ~]# yum install -y tree
[root@node- ~]# tree /var/lib/iscsi/
/var/lib/iscsi/
├── ifaces
├── isns
├── nodes
│   └── iqn.-.cn.sishen.www:target_san1
│   └── 192.168.30.130,,
│   └── default
├── send_targets
│   └── 192.168.30.130,
│   ├── iqn.-.cn.sishen.www:target_san1,192.168.30.130,,,default -> /var/lib/iscsi/nodes/iqn.-.cn.sishen.www:target_san1/192.168.30.130,,
│   └── st_config
├── slp
└── static directories, files

在客户端查看

一定要先启动iscsid在启动iscsi,

[root@node- ~]# /etc/init.d/iscsid start
[root@node- ~]# /etc/init.d/iscsi start
[root@node- ~]# iscsiadm -m discovery -t sendtargets -p 192.168.30.130:
Starting iscsid: [ OK ]
192.168.30.130:, iqn.-.cn.sishen.www:target_san1
[root@node- ~]# tree /var/lib/iscsi/
/var/lib/iscsi/
├── nodes
│   └── iqn.-.cn.sishen.www:target_san1
│   └── 192.168.30.130,,
│   └── default
└── send_targets
└── 192.168.30.130,
├── iqn.-.cn.sishen.www:target_san1,192.168.30.130,,,default -> /var/lib/iscsi/nodes/iqn.-.cn.sishen.www:target_san1/192.168.30.130,,
└── st_config directories, files

关闭顺序

[root@node- ~]# /etc/init.d/iscsi stop
Stopping iscsi: [ OK ]
[root@node- ~]# /etc/init.d/iscsid stop
Stopping iscsid: [ OK ]

查看默认的开机启动项

[root@node- ~]# grep chkconfig /etc/init.d/iscsid
# chkconfig:
[root@node- ~]# grep chkconfig /etc/init.d/iscsi
# chkconfig:
设置开机启动
[root@node- ~]# chkconfig iscsi on
[root@node- ~]# chkconfig iscsid on

在客户端查看是否设备

[root@node- ~]# /etc/init.d/iscsid restart
Stopping iscsid:
Starting iscsid: [ OK ]
[root@node- ~]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]
[root@node- ~]# ll /dev/sdb
brw-rw---- root disk , Jun : /dev/sdb
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
sdb : 5G disk

iscsi的卸载和登录

reboot后再次查看
[root@node- ~]# ll /dev/sd*
brw-rw---- root disk , May : /dev/sda
brw-rw---- root disk , May : /dev/sda1
brw-rw---- root disk , May : /dev/sda2
brw-rw---- root disk , May : /dev/sda3
brw-rw---- root disk , May : /dev/sdb 卸载
[root@node- ~]# iscsiadm -m node -T iqn.-.cn.sishen.www:target_san1 -u
Logging out of session [sid: , target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,]
Logout of [sid: , target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] successful.
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
再次登录
[root@node- ~]# iscsiadm -m node -T iqn.-.cn.sishen.www:target_san1 -l
Logging in to [iface: default, target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] (multiple)
Login to [iface: default, target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] successful.
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
sdb : 5G disk

也可以通过停止iscsi服务来卸载iscsi设备

[root@node- ~]# /etc/init.d/iscsi stop
Stopping iscsi: [ OK ]
[root@node- ~]# ls /dev/sdb
ls: cannot access /dev/sdb: No such file or directory
[root@node- ~]# /etc/init.d/iscsi start
Starting iscsi: [ OK ]
[root@node- ~]# ls /dev/sdb
/dev/sdb

在停止了iscsi服务后,如果执行

[root@node- ~]# rm -rf /var/lib/iscsi/*
#这样会彻底推出iscsi设备

在客户端使用iscsi设备

[root@node- ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x68cb068f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u'). Command (m for help): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder, +cylinders or +size{K,M,G} (-, default ):
Using default value Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
sdb : 5G disk
└─sdb1 : 5G part
[root@node- ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41. (-May-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
Stride= blocks, Stripe width= blocks
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , , , , Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.
[root@node- ~]# mount /dev/sdb1 /opt/
[root@node- ~]# cp /etc/passwd /opt/
[root@node- ~]# df -h /opt/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 .0G 139M .6G % /opt

在另一客户端

[root@node- ~]# yum install -y iscsi-initiator-utils
[root@node- ~]# iscsiadm -m discovery -t sendtargets -p 192.168.30.130:
Starting iscsid: [ OK ]
192.168.30.130:, iqn.-.cn.sishen.www:target_san1
[root@node- ~]# /etc/init.d/iscsid start
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
[root@node- ~]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
sdb : 5G disk
└─sdb1 : 1G part
[root@node- ~]# iscsiadm -m discovery -t sendtargets -p 192.168.30.130:
Starting iscsid: [ OK ]
192.168.30.130:, iqn.-.cn.sishen.www:target_san1
[root@node- ~]# /etc/init.d/iscsid start
[root@node- ~]# /etc/init.d/iscsi start
Starting iscsi: [ OK ]
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
sdb : 5G disk
└─sdb1 : 5G part
[root@node- ~]# mount /dev/sdb1 /opt/
[root@node- ~]# ll /opt/
total
drwx------ root root Jun : lost+found
-rw-r--r-- root root Jun : passwd

卸载iscsi设备

[root@node- ~]# iscsiadm -m node -T iqn.-.cn.sishen.www:target_san1 -u
Logging out of session [sid: , target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,]
Logout of [sid: , target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] successful.
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
[root@node- ~]# iscsiadm -m node -T iqn.-.cn.sishen.www:target_san1 -l
Logging in to [iface: default, target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] (multiple)
Login to [iface: default, target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] successful.
[root@node- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 : .6G rom /media/cdrom
sda : 20G disk
├─sda1 : 200M part /boot
├─sda2 : 2G part [SWAP]
└─sda3 : .8G part
└─vg_master-LogVol00 (dm-) : .8G lvm /
sdc : 5G disk
└─sdc1 : 1G part

遇到的问题

[root@node- ~]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]
[root@node- ~]# mount /dev/sdb1 /sdb1/
mount: you must specify the filesystem type
[root@node- ~]# df -h /sdb1
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1014M 34M 930M % /sdb1
[root@node- ~]# cd /sdb1/
[root@node- sdb1]# ls
ls: reading directory .: Input/output error
[root@node- sdb1]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]
[root@node- sdb1]# /etc/init.d/iscsid restart
Not stopping iscsid: iscsi sessions still active [WARNING]
Starting iscsid:
[root@node- sdb1]# /etc/init.d/iscsid restart
Not stopping iscsid: iscsi sessions still active [WARNING]
Starting iscsid:
[root@node- sdb1]# cd
[root@node- ~]# /etc/init.d/iscsid restart
Not stopping iscsid: iscsi sessions still active [WARNING]
Starting iscsid:

错误日志

。。。。。。。。
May :: node- kernel: scsi :::: Direct-Access sishen target- PQ: ANSI:
May :: node- kernel: sd :::: Attached scsi generic sg3 type
May :: node- kernel: sd :::: [sdc] -byte logical blocks: (5.37 GB/5.00 GiB)
May :: node- kernel: sd :::: [sdc] Write Protect is off
May :: node- kernel: sd :::: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
May :: node- kernel: sdc: sdc1
May :: node- kernel: sd :::: [sdc] Attached SCSI disk
May :: node- iscsid: Connection2: to [target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] through [iface: default] is operational now
May :: node- kernel: sd :::: [sdc] Synchronizing SCSI cache
May :: node- kernel: scsi5 : iSCSI Initiator over TCP/IP
May :: node- kernel: scsi :::: RAID IET Controller PQ: ANSI:
May :: node- kernel: scsi :::: Attached scsi generic sg2 type
May :: node- kernel: scsi :::: Direct-Access sishen target- PQ: ANSI:
May :: node- kernel: sd :::: Attached scsi generic sg3 type
May :: node- kernel: sd :::: [sdc] -byte logical blocks: (5.37 GB/5.00 GiB)
May :: node- kernel: sd :::: [sdc] Write Protect is off
May :: node- kernel: sd :::: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
May :: node- kernel: sdc: sdc1
May :: node- kernel: sd :::: [sdc] Attached SCSI disk
May :: node- iscsid: Connection2: to [target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] through [iface: default] is shutdown.
May :: node- iscsid: Connection3: to [target: iqn.-.cn.sishen.www:target_san1, portal: 192.168.30.130,] through [iface: default] is operational now
May :: node- rhsmd: In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.

暂时还不清楚什么原因

RHEL 6.5----SCSI存储的更多相关文章

  1. OpenStack Cinder 与各种后端存储技术的集成叙述与实践

    先说下下loop设备 loop设备及losetup命令介绍 1. loop设备介绍 在类 UNIX 系统里,loop 设备是一种伪设备(pseudo-device),或者也可以说是仿真设备.它能使我们 ...

  2. [转载]存储基础:DAS/NAS/SAN存储类型及应用

    这篇文章转自博客教主的一篇博客存储基础:DAS/NAS/SAN存储类型及应用, 他是在张骞的这篇博客DAS,NAS,SAN在数据库存储上的应用上做了部分修改和补充.   一. 硬盘接口类型 1. 并行 ...

  3. 明晰三种常见存储技术:DAS、SAN和NAS

    随着企业网络应用的时间和应用的数据量的加大,企业已经感觉到存储容量和性能落后与网络的应用发展需求,特别是流媒体企业,在这种应用条件下满足用户的存储需求的技术应用诞生,DAS.NAS和SAN三种存储技术 ...

  4. RAC节点两边存储名字不一致导致的故障及相关延伸

    起因:一个客户的实际故障,该故障非常典型,其他客户类似的环境也非常多,所以很值得梳理并记录下来. 环境:Oracle 11.2.0.4 RAC(2 nodes)+ RHEL 6.6 共享存储:EMC ...

  5. DAS、SAN和NAS三种存储方式

    DAS存储 DAS存储在我们生活中是非常常见的,尤其是在中小企业应用中,DAS是最主要的应用模式,存储系统被直连到应用的服务器中,在中小企业中,许多的数据应用是必须安装在直连的DAS存储器上. DAS ...

  6. 存储与服务器的连接方式对比(DAS,NAS,SAN)

    存储分类简介 磁盘存储市场上,存储分类根据服务器类型分为:封闭系统的存储和开放系统的存储,封闭系统主要指大型机,AS400等服务器,开放系统指基于包括Windows.UNIX.Linux等操作系统的服 ...

  7. 存储区域网络(Storage Area Network,简称SAN)

    存储区域网络(Storage Area Network,简称SAN)采用网状通道(Fibre Channel ,简称FC,区别与Fiber Channel光纤通道)技术,通过FC交换机连接存储阵列和服 ...

  8. iSCSI存储的3种连接方式

    我们分析了iSCSI存储的系统结构,下面来看iSCSI是如何与服务器.工作站等主机设备来连接的,也就是我们如何建立一个iSCSI网络存储系统. iSCSI设备的主机接口一般默认都是IP接口,可以直接与 ...

  9. LIO -SCSI target

    2010年底,LIO 项目获选成为新的内核态的 SCSI target,取代原有的用户态的 STGT 项目.当时有两个主要的竞争项目(LIO和SCST),都在努力将代码并入主线内核.本文将比较着两个项 ...

  10. 三种存储方式DAS、NAS、SAN

    ------------恢复内容开始------------ 一.DAS.NAS.SAN在存储领域的位置 随着主机.磁盘.网络等技术的发展,数据存储的方式和架构也在一直不停改变,本文主要介绍目前主流的 ...

随机推荐

  1. Hashed Indexes Geospatial Index

    Indexes — MongoDB Manual https://docs.mongodb.com/manual/indexes/ 地理索引 哈希索引

  2. Cocos2d-js异步图片加载

    这里说的是在需要的使用加载图片,比如游戏中的某个关卡的图片,不用在游戏一开始就加载(万一用户玩不到那关,岂不是很冤,流量费了那么多),否则 载入速度也慢.这种方式加载资源要用到cc.loader官方文 ...

  3. (C)字节对齐#pragma pack()

    1. 为什么要进行对齐 对于结构体,编译器会自动进行成员变量对齐处理,是为了提高运算效率. 缺省情况下是自然对齐方式. 2. 自然对齐 即默认对齐,按照结构体的成员中size最大的成员进行对齐. 例: ...

  4. react native 之页面布局

     第一章 flexbox 布局 1.flexDirection:'row', 水平 flexDirection:'column',垂直 需要在父元素上设置这种属性才能实现flex. flex:1 会撑 ...

  5. css3中我们不知道的一些属性

    1.图片作为边框:border-image; 2.圆角问题:border-radius:上.下.左.右: 3.字体的阴影与自动换行: 阴影: h1 {text-shadow: 5px 5px 5px ...

  6. 【前端】Nodejs给没有引号的json数据添加引号

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/node_json.html 我们经常会遇到一些json数据需要放到json文件中,然后动态加载的场景. 但是也经常 ...

  7. 基于 Laravel 5 构建的、支持模块化和多语言的 CMS —— AsgardCMS

    1.简介 AsgardCMS 是基于 Laravel 5 构建的.支持模块化和多语言的CMS. 官网:https://asgardcms.com/ Github:https://github.com/ ...

  8. HDU 2077 汉诺塔IV (递推)

    题意:... 析:由于能最后一个是特殊的,所以前n-1个都是不变的,只是减少了最后一个盘子的次数,所以根据上一个题的结论 答案就是dp[n-1] + 2. 上一题链接:http://www.cnblo ...

  9. Codeforces - 773A - Success Rate - 二分 - 简单数论

    https://codeforces.com/problemset/problem/773/A 一开始二分枚举d,使得(x+d)/(y+d)>=p/q&&x/(y+d)<= ...

  10. hdoj5671 BestCoder Round #81 (div.2)

    对于交换行.交换列的操作,分别记录当前状态下每一行.每一列是原始数组的哪一行.哪一列即可. 对每一行.每一列加一个数的操作,也可以两个数组分别记录.注意当交换行.列的同时,也要交换增量数组. 输出时通 ...