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在存储领域的位置 随着主机.磁盘.网络等技术的发展,数据存储的方式和架构也在一直不停改变,本文主要介绍目前主流的 ...
随机推荐
- 20170228 ALV method中用E消息,会退出到初始界面;STOP 会dump;
再回车就处理界面了, 所以,Handel_data_change 做数据检查时,如果需要报错要用到, CALL METHOD er_data_changed->add_protocol_entr ...
- pyenv 安装本地版本
最近在用pyenv安装python的时候发现官网特别慢,经常出现拒绝访问的情况.看了一些解决方法,发现可以使用本地的python源码进行安装,让pyenv从本地下载就可以了~步骤如下: 首先从官网下载 ...
- Redis使用基本套路
Redis的数据,通常都是来自于数据库. 存入Redis当中,可以快速的查询.不用每次都关联查询,然后其他处理什么的. 通常可以把一些,不经常变的数据存储其中. 避免数据变动,而Redis缓存数据不变 ...
- 一步一步学Silverlight 2系列(12):数据与通信之WebClient
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- web开发中的mysql使用
一.单机mysql与mysql集群 1. 单机mysql很好理解,在一台物理机上安装好mysql服务端程序,使用这一台机器的硬件(cpu,内存,硬盘)进行数据的处理. 2.mysql集群 MySQL集 ...
- iOS中键盘的收起
在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法之外,还有另外三种方法: 重载UIViewController中的touchesBegin方 ...
- Name That Number
链接 分析:找出每一个字母对应的数字,然后看字典里面那个与其匹配 /* ID: **** PROG: namenum LANG: C++ */ #include<iostream> #in ...
- MYSQL数据库学习----查询
查询语句是MYSQL数据库中用到的最多的语句. 查询语句分为几种 单表查询 集合函数查询 连接查询 子查询 合并查询 正则表达式查询 一:单表查询 SELECT 属性 FROM 表名 [WHERE 查 ...
- 堆、栈的区别 <转载>
本篇非作者原创,转子链接,仅供学习记录. 一.预备知识—程序的内存分配 一个由C/C++编译的程序占用的内存分为以下几个部分 1.栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值 ...
- HDU 5878 I Count Two Three (预处理+二分查找)
题意:给出一个整数nnn, 找出一个大于等于nnn的最小整数mmm, 使得mmm可以表示为2a3b5c7d2^a3^b5^c7^d2a3b5c7d. 析:预处理出所有形为2a3 ...