RHEL 6.5----SCSI存储
主机名 | 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存储的更多相关文章
- OpenStack Cinder 与各种后端存储技术的集成叙述与实践
先说下下loop设备 loop设备及losetup命令介绍 1. loop设备介绍 在类 UNIX 系统里,loop 设备是一种伪设备(pseudo-device),或者也可以说是仿真设备.它能使我们 ...
- [转载]存储基础:DAS/NAS/SAN存储类型及应用
这篇文章转自博客教主的一篇博客存储基础:DAS/NAS/SAN存储类型及应用, 他是在张骞的这篇博客DAS,NAS,SAN在数据库存储上的应用上做了部分修改和补充. 一. 硬盘接口类型 1. 并行 ...
- 明晰三种常见存储技术:DAS、SAN和NAS
随着企业网络应用的时间和应用的数据量的加大,企业已经感觉到存储容量和性能落后与网络的应用发展需求,特别是流媒体企业,在这种应用条件下满足用户的存储需求的技术应用诞生,DAS.NAS和SAN三种存储技术 ...
- RAC节点两边存储名字不一致导致的故障及相关延伸
起因:一个客户的实际故障,该故障非常典型,其他客户类似的环境也非常多,所以很值得梳理并记录下来. 环境:Oracle 11.2.0.4 RAC(2 nodes)+ RHEL 6.6 共享存储:EMC ...
- DAS、SAN和NAS三种存储方式
DAS存储 DAS存储在我们生活中是非常常见的,尤其是在中小企业应用中,DAS是最主要的应用模式,存储系统被直连到应用的服务器中,在中小企业中,许多的数据应用是必须安装在直连的DAS存储器上. DAS ...
- 存储与服务器的连接方式对比(DAS,NAS,SAN)
存储分类简介 磁盘存储市场上,存储分类根据服务器类型分为:封闭系统的存储和开放系统的存储,封闭系统主要指大型机,AS400等服务器,开放系统指基于包括Windows.UNIX.Linux等操作系统的服 ...
- 存储区域网络(Storage Area Network,简称SAN)
存储区域网络(Storage Area Network,简称SAN)采用网状通道(Fibre Channel ,简称FC,区别与Fiber Channel光纤通道)技术,通过FC交换机连接存储阵列和服 ...
- iSCSI存储的3种连接方式
我们分析了iSCSI存储的系统结构,下面来看iSCSI是如何与服务器.工作站等主机设备来连接的,也就是我们如何建立一个iSCSI网络存储系统. iSCSI设备的主机接口一般默认都是IP接口,可以直接与 ...
- LIO -SCSI target
2010年底,LIO 项目获选成为新的内核态的 SCSI target,取代原有的用户态的 STGT 项目.当时有两个主要的竞争项目(LIO和SCST),都在努力将代码并入主线内核.本文将比较着两个项 ...
- 三种存储方式DAS、NAS、SAN
------------恢复内容开始------------ 一.DAS.NAS.SAN在存储领域的位置 随着主机.磁盘.网络等技术的发展,数据存储的方式和架构也在一直不停改变,本文主要介绍目前主流的 ...
随机推荐
- HDU 6118 度度熊的交易计划 【最小费用最大流】 (2017"百度之星"程序设计大赛 - 初赛(B))
度度熊的交易计划 Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- [翻译]Unity中的AssetBundle详解(三)
构建AssetBundles 在AssetBundle工作流程的文档中,我们有一个示例代码,它将三个参数传递给BuildPipeline.BuildAssetBundles函数.让我们更深入地了解我们 ...
- design.js
//模块式开发 var myNamespace = (function () { var myPrivateVar = 0; var myPrivateMethod = function (foo) ...
- js中数组遍历的几种方法及其区别
参考网站: http://www.cnblogs.com/lvmh/p/6104397.html 第一种最常用的:for循环 for(j = 0; j < arr.length; j++) { ...
- java的数字精确计算问题-BigDecimal
java的数字运算,偶尔会出现精度的问题,以下阐述的 java的BigDecimal类的使用. 例如: System.out.println(0.9+0.3); 结果1.2 System.out.pr ...
- MySql必知必会内容导图
<MySQL必知必会>从介绍简单的数据检索开始,逐步深入一些复杂的内容,包括联结的使用.子查询.正则表达式和基于全文本的搜索.存储过程.游标.触发器.表约束,等等.通过重点突出的章节,条理 ...
- [AHOI 2006] 上学路线
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1266 [算法] 首先 , 用Dijkstra求单源最短路 然后 , 建出这张图G的最 ...
- 【HDU 4722】 Good Numbers
[题目链接] 点击打开链接 [算法] f[i][j]表示第i位,数位和对10取模余j的数的个数 状态转移,计算答案都比较简单,笔者不再赘述 [代码] #include<bits/stdc++.h ...
- bzoj2004公交线路——DP+矩阵加速递推
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2004 求方案数,想到DP: 因为两个站间距离<=p,所以每p个站中所有车一定都会停靠至 ...
- 【旧文章搬运】Windows句柄分配算法(二)
原文发表于百度空间,2009-04-04========================================================================== 在创建句柄 ...