迷彩 潜伏 隐蔽 伪装
分类:
2012-07-09 23:53:44
原文地址:红帽企业存储管理之iscsi简单应用 作者:xjzhujunjie
红帽企业存储管理之iscsi简单应用
共享存储:
Ø das :direct attached storage 直接附加存储
n scsi 磁盘柜 7 15
Ø nas : network attached storage网络附加存储 (带有自己的操作系统)
n samba nfs 文件级的共享
Ø san : 存储区域网络
n fc-san(fiber channer storage area network光纤)fc-switch
u target initiator 认证(ip—账号 --cheap)
HA:
解决方法: stonith (也叫fence)
模块:hp,ibm,sun 机器模块设备
块存储:ext2,ext3(本地文件系统 没有锁机制,没有推送机制)
群集文件系统:有锁机制和推送机制-- redhat:gfs(1-2) oracle:(ocfs2)
iscsi存储管理:
target (tgtd)(服务器)
scsi-target-utils.i386 3260 认证(ip-chanper)
如:iqn.2012-05.com.a.node1:target
管理:tgtadm --lld [driver] --op [operation] --mode [mode] [OPTION]...
--lld [driver] --op new --mode target --tid=[id] --targetname [name]
--lld [driver] --op new --mode=logicalunit --tid=[id] --lun=[lun]
--backing-store [path]
initiator (客户端)
红帽企业存储管理之iscsi简单应用案例:
应用拓扑图:
应用实现步骤:
一.Target-server服务器配置
配置本地yum数据库
[root@target-server ~]# vim /etc/yum.repos.d/server.repo
name=Red Hat Enterprise Linux clusterstorage
[root@target-server ~]# yum list all |grep scsi-target
This system is not registered with RHN.
[root@target-server ~]# yum install scsi-target-utils
[root@target-server ~]# rpm -ql scsi-target-utils
/etc/rc.d/init.d/tgtd #服务器控制脚本
#设置target开机启动,并启动tgtd服务
[root@target-server ~]# chkconfig tgtd on
[root@target-server ~]# chkconfig --list tgtd
[root@target-server ~]# service tgtd start
[root@target-server ~]# netstat -tupln |grep tgtd
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 3893/tgtd
tcp 0 0 :::3260 :::* LISTEN 3893/tgtd
[root@target-server ~]# fdisk -l
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1033 8193150 83 Linux
/dev/sda3 1034 1224 1534207+ 82 Linux swap / Solaris
[root@target-server ~]# fdisk /dev/sda
[root@target-server ~]# fdisk -l
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1033 8193150 83 Linux
/dev/sda3 1034 1224 1534207+ 82 Linux swap / Solaris
/dev/sda4 1225 1347 987997+ 83 Linux
[root@target-server ~]# cat /proc/partitions
8 0 12582912 sda
8 1 104391 sda1
8 2 8193150 sda2
8 3 1534207 sda3
[root@target-server ~]# partprobe /dev/sda
[root@target-server ~]# cat /proc/partitions
8 0 12582912 sda
8 1 104391 sda1
8 2 8193150 sda2
8 3 1534207 sda3
8 4 987997 sda4
#配置target,新建target设备和逻辑单元设备
[root@target-server ~]# tgtadm --lld iscsi --op new --mode target --tid 1 --targetname iqn.2012-05-22.com.junjie.node1:target
[root@target-server ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2012-05-22.com.junjie.node1:target
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
Account information:
ACL information:
[root@target-server ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /dev/sda4
[root@target-server ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2012-05-22.com.junjie.node1:target
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 1012 MB
Online: Yes
Removable media: No
Backing store: /dev/sda4
Account information:
ACL information:
[root@target-server ~]# tgtadm --lld iscsi --op bind --mode target --tid 1 --initiator-address 192.168.101.0/24
[root@target-server ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2012-05-22.com.junjie.node1:target
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 1012 MB
Online: Yes
Removable media: No
Backing store: /dev/sda4
Account information:
ACL information:
192.168.101.0/24
[root@target-server ~]# vim /etc/tgt/targets.conf
二.Initiator-1(存储的客户端)配置
Initiator-1(存储的客户端)
配置本地yum数据库:
[root@initiator-1 ~]# vim /etc/yum.repos.d/server.repo
name=Red Hat Enterprise Linux clusterstorage
安装配置
[root@initiator-1 ~]# yum install -y iscsi-initiator-utils
[root@initiator-1 ~]# vim /etc/iscsi/initiatorname.iscsi
[root@initiator-1 ~]# chkconfig iscsi on
[root@initiator-1 ~]# service iscsi start
Turning off network shutdown. Starting iSCSI daemon: [ OK ]
Setting up iSCSI targets: iscsiadm: No records found!
[ OK ]
[root@initiator-1 ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.101.210
192.168.101.210:3260,1 iqn.2012-05-22.com.junjie.node1:target
[root@initiator-1 ~]# iscsiadm --mode node --targetname iqn.2012-05-22.com.junjie.node1:target --portal 192.168.101.210:3260 --login
Logging in to [iface: default, target: iqn.2012-05-22.com.junjie.node1:target, portal: 192.168.101.210,3260]
Login to [iface: default, target: iqn.2012-05-22.com.junjie.node1:target, portal: 192.168.101.210,3260]: successful
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1033 8193150 83 Linux
/dev/sda3 1034 1224 1534207+ 82 Linux swap / Solaris
此时就相当于本地磁盘(可以随意使用,可以格式化,挂载等)
[root@initiator-1 ~]# fdisk /dev/sdb
[root@initiator-1 ~]# fdisk -l
Disk /dev/sdb: 1011 MB, 1011709440 bytes
32 heads, 61 sectors/track, 1012 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1012 987681+ 83 Linux
[root@initiator-1 ~]# partprobe /dev/sdb
[root@initiator-1 ~]# mkfs -t ext3 /dev/sdb1
[root@initiator-1 ~]# mkdir /mnt/1
[root@initiator-1 ~]# mount /dev/sdb1 /mnt/1/
[root@initiator-1 ~]# cd /mnt/1/
[root@initiator-1 1]# mkdir d1 d2 d3
[root@initiator-1 1]# touch f1 f2 f3
[root@initiator-1 1]# ll
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d1
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d2
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d3
-rw-r--r-- 1 root root 0 Apr 1 11:37 f1
-rw-r--r-- 1 root root 0 Apr 1 11:37 f2
-rw-r--r-- 1 root root 0 Apr 1 11:37 f3
drwx------ 2 root root 16384 Apr 1 11:34 lost+found
三.Initiator-2(存储的客户端)配置
Initiator-2(存储的客户端)
配置本地yum数据库:
[root@initiator-2 ~]# vim /etc/yum.repos.d/server.repo
name=Red Hat Enterprise Linux clusterstorage
安装配置
[root@initiator-2 ~]# yum install -y iscsi-initiator-utils
[root@initiator-2 ~]# vim /etc/iscsi/initiatorname.iscsi
[root@initiator-2 ~]# service iscsi start
Turning off network shutdown. Starting iSCSI daemon: [ OK ]
[ OK ]
Setting up iSCSI targets: iscsiadm: No records found!
[root@initiator-2 ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.101.210
192.168.101.210:3260,1 iqn.2012-05-22.com.junjie.node1:target
[root@initiator-2 ~]# iscsiadm --mode node --targetname iqn.2012-05-22.com.junjie.node1:target --portal 192.168.101.210:3260 --login
Logging in to [iface: default, target: iqn.2012-05-22.com.junjie.node1:target, portal: 192.168.101.210,3260]
Login to [iface: default, target: iqn.2012-05-22.com.junjie.node1:target, portal: 192.168.101.210,3260]: successful
[root@initiator-2 ~]# fdisk -l
Disk /dev/sdb: 1011 MB, 1011709440 bytes
32 heads, 61 sectors/track, 1012 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1012 987681+ 83 Linux
[root@initiator-2 ~]#
此时就相当于本地磁盘(可以随意使用,可以格式化,挂载等)
[root@initiator-2 ~]# mkdir /mnt/1
[root@initiator-2 ~]# mount /dev/sdb1 /mnt/1/
[root@initiator-2 ~]# cd /mnt/1/
[root@initiator-2 1]# ll
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d1
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d2
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d3
-rw-r--r-- 1 root root 0 Apr 1 11:37 f1
-rw-r--r-- 1 root root 0 Apr 1 11:37 f2
-rw-r--r-- 1 root root 0 Apr 1 11:37 f3
drwx------ 2 root root 16384 Apr 1 11:34 lost+found
由于该文件系统是块存储:ext2,ext3本地文件系统,故没有锁机制,也没有推送机制
4.1测试推送功能
在initiator-2上创建qq文件
[root@initiator-2 1]# echo "01" >f1
[root@initiator-2 1]# touch qq
[root@initiator-2 1]# ll
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d1
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d2
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d3
-rw-r--r-- 1 root root 3 Apr 1 12:03 f1
-rw-r--r-- 1 root root 0 Apr 1 11:37 f2
-rw-r--r-- 1 root root 0 Apr 1 11:37 f3
drwx------ 2 root root 16384 Apr 1 11:34 lost+found
-rw-r--r-- 1 root root 0 Apr 1 12:03 qq
在initiator-1上没有发现qq文件
[root@initiator-1 1]# ll
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d1
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d2
drwxr-xr-x 2 root root 4096 Apr 1 11:37 d3
-rw-r--r-- 1 root root 0 Apr 1 11:37 f1
-rw-r--r-- 1 root root 0 Apr 1 11:37 f2
-rw-r--r-- 1 root root 0 Apr 1 11:37 f3
drwx------ 2 root root 16384 Apr 1 11:34 lost+found
[root@initiator-1 1]#
4.2测试锁机制功能
经过测试可以知道:块存储:ext2,ext3本地文件系统,故没有锁机制,也没有推送机制
iscsiadm --mode node -T iqn.2011-09-28:disk1 -p 192.168.0.254:3260 --logout(在service iscsi restart后又会注册)
iscsiadm --mode node -T iqn.2011-09-28:disk1 -p 192.168.0.254:3260 -o delete
《完》
--xjzhujunjie--2012/05/06