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基础服 ...
随机推荐
- Marking as slave lost.
Spark on Yarn提交任务时报ClosedChannelException解决方案_服务器应用_Linux公社-Linux系统门户网站 http://www.linuxidc.com/Linu ...
- SDUT OJ 2054 双向链表的实现 (结构体node指针+遍历 *【模板】)
双向链表 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 学会了单向链表,我们又多了一种解决问题的能力,单链表利用一个指针就能在内 ...
- android 一个TextView设置多种颜色
时候一个文本框为了强调内容需要显示不同颜色,用以下代码可以轻松实现 方法一:(适用于颜色变化多的情况) //为文本框设置多种颜色 textView=(TextView)findViewById(R ...
- codeforces 441C. Valera and Tubes 解题报告
题目链接:http://codeforces.com/problemset/problem/441/C 题目意思:将n * m 的矩阵分成 k 堆.每堆是由一些坐标点(x, y)组成的.每堆里面至少由 ...
- bzoj 2301 [HAOI2011]Problem b(莫比乌斯反演+分块优化)
题意:对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 1≤n≤50000,1≤a≤b≤50000, ...
- JS DOM1核心概要document
Document类型: document对象表示整个html页面,而且,document对象是window对象的一个属性: 文档信息:document.title,表示当前页面的标题: documen ...
- ubuntu下tesseract 4.0安装及参数使用
tesseract是一个开源的OCR引擎,最初是由惠普公司开发用来作为其平板扫描仪的OCR引擎,2005年惠普将其开源出来,之后google接手负责维护.目前稳定的版本是3.0.4.0版本加入了基 ...
- 【hdu 5418】 Victor and world
[题目链接] 点击打开链接 [算法] 状压DP f[i][S]表示走的最后一步在i,状态为S 于是我们可以用最短路径 + 状压DP解决此题,由于不存在负边,所以可以用dijkstra+堆优化 [代码] ...
- COCOS2DX场景切换特效
cocos2d-x 3.0中场景切换特效比较多,而且游戏开发中也经常需要用到这些特效,来使场景切换时不至于那么干巴,遂这里汇总一下,开发中使用. 百牛信息技术bainiu.ltd整理发布于博客园 场景 ...
- 02_通过scrollview实现内容滚动
在ScrollView里面放一个Button和TextView程序直接就挂了. ScrollView它只限制了有几个孩子,没限制有几个孙子.给Button和TextView套上一个爹LinearLay ...