ISCSI存储
slave-147作为服务端
需要安装的软件
[root@slave-147 ~]# yum install -y scsi-target-utils
slave-148和slave-149作为客户端
需要安装的软件
[root@slave-148 ~]# yum install iscsi-initiator-utils
创建共享分区
[root@slave-147 ~]# fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba211077
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +5G
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
同样步骤再创建sdb2.
格式化为ext4文件系统:
[root@slave-147 ~]# mkfs.ext4 /dev/sdb1
[root@slave-147 ~]# mkfs.ext4 /dev/sdb2
因为我在安装系统时,磁盘创建成了LVM,可能是这个原因,导致在这里直接改/etc/tgt/targets.conf文件不生效。
所以这里我也将新建的sdb1和sdb2创建成了LVM格式:
[root@slave-147 ~]# pvcreate /dev/sdb{1,2}
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
[root@slave-147 ~]# pvscan
PV /dev/sdb1 lvm2 [5.01 GiB]
PV /dev/sdb2 lvm2 [5.01 GiB]
Total: 2 [10.02 GiB] / in use: 0 [0 ] / in no VG: 2 [10.02 GiB]
[root@slave-147 ~]# vgcreate vg_01 /dev/sdb{1,2}
Volume group "vg_01" successfully created
[root@slave-147 ~]# lvcreate -L 10G vg_01
Logical volume "lvol0" created
[root@slave-147 ~]# lvscan
ACTIVE '/dev/vg_01/lvol0' [10.00 GiB] inherit
[root@slave-147 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_01/lvol0 //地址要记住,修改targets.conf时用
LV Name lvol0
VG Name vg_01
LV UUID BAnblY-DKHO-89bT-SoRS-daCR-E76l-XeW94v
LV Write Access read/write
LV Creation host, time slave-147, 2018-03-29 13:38:44 +0800
LV Status available
# open 0
LV Size 10.00 GiB
Current LE 2560
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@slave-147 ~]# vim /etc/tgt/targets.conf
#<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>
<target iqn.2018-01.cn.xueji.www:target_san1>
backing-store /dev/vg_01/lvol0
initiator-address 192.168.75.148
vendor_id xueji
product_id target1
</target>
重启tgtd服务
[root@slave-147 ~]# /etc/init.d/tgtd restart
查看:
[root@slave-147 ~]# tgt-admin --show
Target 1: iqn.2018-01.cn.xueji.www:target_san1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 10737 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vg_01/lvol0
Backing store flags:
Account information:
ACL information:
192.168.75.148
客户端:
安装ISCSI
[root@slave-148 ~]# yum install -y iscsi-initiator-utils
[root@slave-148 ~]# /etc/init.d/iscsi start //没有任何输出,这里需要我们发现target存储,再启动客户端服务,才会生效
[root@slave-148 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.75.147:3260
Starting iscsid: [ OK ] [ OK ]
192.168.75.147:3260,1 iqn.2018-01.cn.xueji.www:target_san1
[root@slave-148 ~]# /etc/init.d/iscsid status
iscsid (pid 2801) is running...
[root@slave-148 ~]# yum install -y tree //用于查询目录树
[root@slave-148 ~]# tree /var/lib/iscsi/ //发现target后,会在该目录下生成树结构
/var/lib/iscsi/
├── ifaces
├── isns
├── nodes
│ └── iqn.2018-01.cn.xueji.www:target_san1
│ └── 192.168.75.147,3260,1
│ └── default
├── send_targets
│ └── 192.168.75.147,3260
│ ├── iqn.2018-01.cn.xueji.www:target_san1,192.168.75.147,3260,1,default -> /var/lib/iscsi/nodes/iqn.2018-01.cn.xueji.www:target_san1/192.168.75.147,3260,1
│ └── st_config
├── slp
└── static
10 directories, 2 files
重启服务,查看是否发现硬盘
[root@slave-148 ~]# /etc/init.d/iscsid restart
Stopping iscsid:
Starting iscsid: [ OK ]
[root@slave-148 ~]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]
[root@slave-148 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 15.8G 0 part /
sr0 11:0 1 3.6G 0 rom /mnt/cdrom
sdb 8:16 0 10G 0 disk
使用ISCSI
[root@slave-148 ~]# 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 0x48b9f524.
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 4 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): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x48b9f524
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-10240, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-10240, default 10240): +1G
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@slave-148 ~]# mkfs.ext4 /dev/sdb1
[root@slave-148 ~]# mkdir /sdb1
[root@slave-148 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 15.8G 0 part /
sr0 11:0 1 3.6G 0 rom /mnt/cdrom
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 1G 0 part
[root@slave-148 ~]# mount /dev/sb1 /sdb1/
[root@slave-148 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 4.1G 11G 28% /
tmpfs 996M 72K 996M 1% /dev/shm
/dev/sda1 194M 34M 151M 19% /boot
/dev/sr0 3.6G 3.6G 0 100% /mnt/cdrom
[root@slave-148 sdb1]# touch slave-148.txt
[root@slave-148 sdb1]# ll
total 16
drwx------ 2 root root 16384 Mar 29 14:22 lost+found
-rw-r--r-- 1 root root 0 Mar 29 14:25 slave-148.txt
为了验证,我们再以同样的方式添加一台客户端
首先将slave-148上的iscsi停掉,这里要注意,必须先停掉,再去添加,否则会出错。具体原因还有待研究。
[root@slave-148 ~]# /etc/init.d/iscsi stop
Stopping iscsi: [ OK ]
在master-147上:
<target iqn.2018-01.cn.xueji.www:target_san1>
backing-store /dev/vg_01/lvol0
initiator-address 192.168.75.148
initiator-address 192.168.75.149 //在原有的基础上加上这行
vendor_id xueji
product_id target1
</target>
[root@slave-147 ~]# /etc/init.d/tgtd restart
Stopping SCSI target daemon: [ OK ]
Starting SCSI target daemon: [ OK ]
[root@slave-147 ~]# tgt-admin --show
Target 1: iqn.2018-01.cn.xueji.www:target_san1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 10737 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vg_01/lvol0
Backing store flags:
Account information:
ACL information:
192.168.75.148
192.168.75.149
在slave-149上
[root@slave-149 ~]# /etc/init.d/iscsi start
[root@slave-149 ~]# /etc/init.d/iscsid start
[root@slave-149 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.75.147:3260Starting iscsid: [ OK ]
192.168.75.147:3260,1 iqn.2018-01.cn.xueji.www:target_san1
[root@slave-149 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 15.8G 0 part /
sr0 11:0 1 3.6G 0 rom /mnt/cdrom
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 1G 0 part
使用
[root@slave-149 ~]# mkdir /sdb1
[root@slave-149 ~]# fdisk /dev/sdb
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 (1-4)
p
Partition number (1-4): 2
First cylinder (1026-10240, default 1026):
Using default value 1026
Last cylinder, +cylinders or +size{K,M,G} (1026-10240, default 10240): +1G
Command (m for help): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x48b9f524
Device Boot Start End Blocks Id System
/dev/sdb1 1 1025 1049584 83 Linux
/dev/sdb2 1026 2050 1049600 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@slave-149 ~]# mkfs.ext4 /dev/sdb2
[root@slave-149 ~]# mount /dev/sdb2 /sdb2
[root@slave-149 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 3.9G 11G 26% /
tmpfs 996M 72K 996M 1% /dev/shm
/dev/sda1 194M 34M 151M 19% /boot
/dev/sr0 3.6G 3.6G 0 100% /mnt/cdrom
/dev/sdb1 1008M 34M 924M 4% /sdb1
/dev/sdb2 1008M 34M 924M 4% /sdb2
进入到sdb1中查看
[root@slave-149 sdb1]# ll
total 16
drwx------ 2 root root 16384 Mar 29 14:57 lost+found
-rw-r--r-- 1 root root 0 Mar 29 15:02 slave-148.txt
在slave-148上面查看
[root@slave-148 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.75.147:3260192.168.75.147:3260,1 iqn.2018-03.cn.xueji.www:target_san1
[root@slave-148 ~]# /etc/init.d/iscsid restart
Stopping iscsid:
Starting iscsid: [ OK ]
[root@slave-148 ~]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]
[root@slave-148 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 15.8G 0 part /
sr0 11:0 1 3.6G 0 rom /mnt/cdrom
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 1G 0 part
└─sdb2 8:18 0 1G 0 part
到sdb1中查看
[root@slave-148 sdb1]# ll
total 16
drwx------ 2 root root 16384 Mar 29 14:57 lost+found
-rw-r--r-- 1 root root 0 Mar 29 15:02 slave-148.txt
-rw-r--r-- 1 root root 0 Mar 29 15:03 slave-149.tx
同步这块,还不是很清楚,在slave-148上创建了测试数据后,不能立刻在slave-149上查到相关数据,要重新发现,重启slave-149上的服务才可以,这点可能是我做的有问题,后面在折腾下。今天先记录到这里~
ISCSI存储的更多相关文章
- 有了iscsi存储怎么让主机识别以及使用创建lvm
1.查找安装包:rpm -ivh iscsi-initiator-utils去sf.net下载iscsitarget包make kernel,usr,install开启服务 (0)查看iscsi发现记 ...
- 通过SCVMM分配iSCSI存储
除了使用基于SMB3.0应用程序的文件共享外,还可以使用iSCSI目标服务器的SAN存储,然后在SCVMM控制台中添加基于SMI-S类型的存储,步骤如下: 1.将一台安装了 iSCSI目标 功能的Wi ...
- linux杂谈(十七):iscsi存储分离技术
1.iscsi简单介绍 iSCSI利用了TCP/IP的port 860 和 3260 作为沟通的渠道.透过两部计算机之间利用iSCSI的协议来交换SCSI命令,让计算机能够透过快速的局域网集线来 ...
- 通过Windows Server 2008 R2建立iSCSI存储
名词解释:iSCSI技术是一种由IBM公司研究开发的,是一个供硬件设备使用的可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行 SCSI协议,使其能够在诸如高速千兆以太网上 ...
- iSCSI存储的3种连接方式
我们分析了iSCSI存储的系统结构,下面来看iSCSI是如何与服务器.工作站等主机设备来连接的,也就是我们如何建立一个iSCSI网络存储系统. iSCSI设备的主机接口一般默认都是IP接口,可以直接与 ...
- vSphere ESXi主机配置iSCSI存储
vSphere ESXi主机配置iSCSI存储 vSphere ESXi主机一般连接的存储类型有光纤存储.iSCSI存储两类.本次案例为iSCSI存储连接ESXi主机的配置. 案例环境:ESXi主机通 ...
- linux下挂载ISCSI存储设备
安装 首先要在存储设备上做好RAID,设置好iSCSI 目标方(target). 这里主要说明iSCSI initiator的安装. 不同的操作系统对应各自的iSCSI initiator,以Redh ...
- Linux FC/iSCSI存储设备管理系列(一):Linux系统设备驱动入门
Linux FC/iSCSI存储设备管理系列(一):Linux系统设备驱动入门 转载请在文首保留原文出处:EMC中文支持论坛 - https://community.emc.com/go/chines ...
- 基于使用ISCSI存储的ibmmq通过heartbeat实现HA方案以及碰到的问题总结
一.背景 ibmmq是一种传统架构的mq产品,运行稳定,有其自身优点,但在高可用(HA)这一块需要使用公司根据自身需求选用高可用(HA)产品,但由于市面HA商业产品较贵,所以使用linux操作系统级的 ...
- 配置软ISCSI存储
说明:这里是Linux服务综合搭建文章的一部分,本文可以作为单独使用RedHat Enterprise Linux 7搭建软ISCSI的参考. 注意:这里所有的标题都是根据主要的文章(Linux基础服 ...
随机推荐
- InspectIT_EUM 实现原理概述
在Git上查看 InspectIT 实现原理概述: 实现原理详解: 1.jsAgent如何注入到浏览器 通过ASM框架修改HttpService.service()方法,加入相关逻辑,对每一个Htt ...
- HDU 6122 今夕何夕 【数学公式】 (2017"百度之星"程序设计大赛 - 初赛(A))
今夕何夕 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- (linux)main.c中的初始化
main.c中的初始化 head.s在最后部分调用main.c中的start_kernel() 函数,从而把控制权交给了它. 所以启动程序从start_kernel()函数继续执行.这个函数是main ...
- ubuntu主板信息
root:~# sudo dmidecode |grep -A16 "System Information$"sudo: 无法解析主机:phone-TPOWER-X79System ...
- poj 1258 Agri-Net 解题报告
题目链接:http://poj.org/problem?id=1258 题目意思:给出 n 个 farm,每个farm 之间通过一定数量的fiber 相连,问使得所有farm 直接或间接连通的 最少 ...
- 【POJ 2406】 Power Strings
[题目链接] 点击打开链接 [算法] KMP 如果字符串中存在循环节,则next[len] = (循环节个数 - 1) * 循环节长度 循环节个数 = len / (len - next[len]) ...
- HNOI2017 day1 T2 影魔
题目大意: 影魔,奈文摩尔,据说有着一个诗人的灵魂.事实上,他吞噬的诗人灵魂早已成千上万.千百年来,他收集了各式各样的灵魂,包括诗人.牧师.帝王.乞丐.奴隶.罪人,当然,还有英雄. 每一个灵魂,都有着 ...
- 【转】设置cocos2dx 屏幕分辨率
[转载连接:]http://www.cnblogs.com/onlycxue/p/3500026.html 做手机上的软件首先要考虑的就是屏幕分辨率怎么解决.coco2dx已经有了很好的解决方法. 用 ...
- direction
基本上,大家只要关心下面这两个属性值就好了: direction: ltr; // 默认值 direction: rtl; 其中,ltr是初始值,表示left-to-right,就是从左往右的意思,再 ...
- @font-face 用fontsquirrel把ttf文件获取别的文件格式
@font-face是css3的一个模块,但是@font-face这个功能早在IE4就支持了,他主要是把自己定义的Web字体嵌入到你的网页中, @font-face { font-family: &l ...