IP SAN (iscsi)

192.168.1.253  Server 


[ 192.168.1.40  192.168.1.145 ] SAN 
  storage1  storage2


1,准备好存储设备 (可以是一个分区,也可以是DD出来的一个文件)
[root@storage2 ~]# fdisk /dev/sda
[root@storage2 ~]# partprobe /dev/sda
[root@storage2 ~]# ls /dev/sda6
/dev/sda6
[root@storage2 ~]# fdisk -l | grep sda6
/dev/sda6           26033       28465    19543041   83  Linux
2,配置ISCSI方式共享
 [root@storage2 ~]# yum -y install scsi-target-utils
 [root@storage2 ~]# vim /etc/tgt/targets.conf
  1 default-driver iscsi
  2 # Sample target with one LUN only. Defaults to al    low access for all initiators:
  3 
  4 <target iqn.2012-08.storage2:target1>
  5     backing-store /dev/sda6
  6 </target>
[root@storage2 ~]# service tgtd start 
[root@storage2 ~]# tgt-admin --show  | grep Backing
            Backing store type: rdwr
            Backing store path: None
            Backing store type: rdwr
            Backing store path: /dev/sda6
[root@storage2 ~]# tgt-admin --update all --force   更改了配置文件后  手动更新文件


-- 使用存储的前端服务器----------------------
1,装包
[root@teacher ~]# yum -y install iscsi-initiator-utils
2,发现存储
[root@teacher ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.145:3260
192.168.1.145:3260,1 iqn.2012-08.storage2:target1
发现成功后,数据保存 在/var/lib/iscsi目录下
[root@teacher ~]# tree /var/lib/iscsi/
/var/lib/iscsi/
|-- ifaces
|-- isns
|-- nodes
|   `-- iqn.2012-08.storage2:target1
|       `-- 192.168.1.145,3260,1
|           `-- default
|-- send_targets
|   `-- 192.168.1.145,3260
|       |-- iqn.2012-08.storage2:target1,192.168.1.145,3260,1,default -> /var/lib/iscsi/nodes/iqn.2012-08.storage2:target1/192.168.1.145,3260,1
|       `-- st_config
|-- slp
`-- static

10 directories, 2 files

[root@teacher ~]# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c5742

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       25509   204796620   83  Linux
/dev/sda3           25510       25764     2048287+  82  Linux swap / Solaris
/dev/sda4           25765       60801   281434702+   5  Extended
/dev/sda5           25779       25804      208813+  83  Linux
/dev/sda6           25765       25778      112423+  83  Linux
/dev/sda7           25805       25811       56196   83  Linux
/dev/sda8           25812       25818       56196   83  Linux
/dev/sda9           25819       25825       56196   83  Linux
/dev/sda10          25826       25832       56196   83  Linux
/dev/sda11          25833       25839       56196   83  Linux
/dev/sda12          25840       25846       56196   83  Linux
/dev/sda13          25847       25853       56196   83  Linux
/dev/sda14          25854       25860       56196   83  Linux
/dev/sda15          25861       25867       56196   83  Linux
/dev/sda16          25868       26390     4200966   83  Linux

Partition table entries are not in disk order
3,登入到发现的存储,成功后fdisk -l命令可以查看到多出一个磁盘(块设备 )
[root@teacher ~]# iscsiadm -m node -T iqn.2012-08.storage2:target1 -l
Logging in to [iface: default, target: iqn.2012-08.storage2:target1, portal: 192.168.1.145,3260]
Login to [iface: default, target: iqn.2012-08.storage2:target1, portal: 192.168.1.145,3260]: successful
[root@teacher ~]# 

[root@teacher ~]# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c5742

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       25509   204796620   83  Linux
/dev/sda3           25510       25764     2048287+  82  Linux swap / Solaris
/dev/sda4           25765       60801   281434702+   5  Extended
/dev/sda5           25779       25804      208813+  83  Linux
/dev/sda6           25765       25778      112423+  83  Linux
/dev/sda7           25805       25811       56196   83  Linux
/dev/sda8           25812       25818       56196   83  Linux
/dev/sda9           25819       25825       56196   83  Linux
/dev/sda10          25826       25832       56196   83  Linux
/dev/sda11          25833       25839       56196   83  Linux
/dev/sda12          25840       25846       56196   83  Linux
/dev/sda13          25847       25853       56196   83  Linux
/dev/sda14          25854       25860       56196   83  Linux
/dev/sda15          25861       25867       56196   83  Linux
/dev/sda16          25868       26390     4200966   83  Linux

Partition table entries are not in disk order

Disk /dev/sdb: 20.0 GB, 20012073984 bytes
64 heads, 32 sectors/track, 19085 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

[root@teacher ~]# service iscsi start 读取/var/lib/iscsi/中的数据进行登入
[root@teacher ~]# service iscsi stop  登出
[root@teacher ~]# service iscsid start  发现存储之前,必须 先启动这个服务 


5,使用存储  制作 LVM -- 格式化 -- 挂载
[root@teacher ~]# pvcreate  /dev/sdb
  Physical volume "/dev/sdb" successfully created
[root@teacher ~]# pvcreate  /dev/sdc
  Physical volume "/dev/sdc" successfully created
[root@teacher ~]# vgcreate vg_san1  /dev/sdb /dev/sdc
  Volume group "vg_san1" successfully created
[root@teacher ~]# vgs
  VG      #PV #LV #SN Attr   VSize  VFree 
  vg_san1   2   0   0 wz--n- 19.12G 19.12G
[root@teacher ~]# lvcreate  -L 10G -n lv_san1  vg_san1
  Logical volume "lv_san1" created
[root@teacher ~]# lvs
  LV      VG      Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_san1 vg_san1 -wi-a- 10.00G                                      
[root@teacher ~]# mkfs.ext3 /dev/vg_san1/lv_san1 
[root@teacher ~]# mount -t ext3 /dev/vg_san1/lv_san1  /var/www/html/
[root@teacher ~]# df -Th /var/www/html/
文件系统      类型    容量  已用 可用 已用% 挂载点
/dev/mapper/vg_san1-lv_san1
              ext3    9.9G  151M  9.2G   2% /var/www/html
[root@teacher ~]# ls -l /dev/vg_san1/lv_san1 
lrwxrwxrwx 1 root root 27 08-15 11:09 /dev/vg_san1/lv_san1 -> /dev/mapper/vg_san1-lv_san1
[root@teacher ~]# 




2,配置ISCSI方式共享
 [root@storage2 ~]# yum -y install scsi-target-utils
 [root@storage2 ~]# vim /etc/tgt/targets.conf
  1 default-driver iscsi
  2 # Sample target with one LUN only. Defaults to al    low access for all initiators:
  3 
  4 <target iqn.2012-08.storage2:target1>
  5     backing-store /dev/sda6
  6 </target>
[root@storage2 ~]# service tgtd start 
[root@storage2 ~]# tgt-admin --show  | grep Backing
            Backing store type: rdwr
            Backing store path: None
            Backing store type: rdwr
            Backing store path: /dev/sda6
[root@storage2 ~]# tgt-admin --update all --force   更改了配置文件后  手动更新文件


-- 使用存储的前端服务器----------------------
1,装包
[root@teacher ~]# yum -y install iscsi-initiator-utils
2,发现存储
[root@teacher ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.145:3260
192.168.1.145:3260,1 iqn.2012-08.storage2:target1
发现成功后,数据保存 在/var/lib/iscsi目录下
[root@teacher ~]# tree /var/lib/iscsi/
/var/lib/iscsi/
|-- ifaces
|-- isns
|-- nodes
|   `-- iqn.2012-08.storage2:target1
|       `-- 192.168.1.145,3260,1
|           `-- default
|-- send_targets
|   `-- 192.168.1.145,3260
|       |-- iqn.2012-08.storage2:target1,192.168.1.145,3260,1,default -> /var/lib/iscsi/nodes/iqn.2012-08.storage2:target1/192.168.1.145,3260,1
|       `-- st_config
|-- slp
`-- static

10 directories, 2 files

[root@teacher ~]# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c5742

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       25509   204796620   83  Linux
/dev/sda3           25510       25764     2048287+  82  Linux swap / Solaris
/dev/sda4           25765       60801   281434702+   5  Extended
/dev/sda5           25779       25804      208813+  83  Linux
/dev/sda6           25765       25778      112423+  83  Linux
/dev/sda7           25805       25811       56196   83  Linux
/dev/sda8           25812       25818       56196   83  Linux
/dev/sda9           25819       25825       56196   83  Linux
/dev/sda10          25826       25832       56196   83  Linux
/dev/sda11          25833       25839       56196   83  Linux
/dev/sda12          25840       25846       56196   83  Linux
/dev/sda13          25847       25853       56196   83  Linux
/dev/sda14          25854       25860       56196   83  Linux
/dev/sda15          25861       25867       56196   83  Linux
/dev/sda16          25868       26390     4200966   83  Linux

Partition table entries are not in disk order
3,登入到发现的存储,成功后fdisk -l命令可以查看到多出一个磁盘(块设备 )
[root@teacher ~]# iscsiadm -m node -T iqn.2012-08.storage2:target1 -l
Logging in to [iface: default, target: iqn.2012-08.storage2:target1, portal: 192.168.1.145,3260]
Login to [iface: default, target: iqn.2012-08.storage2:target1, portal: 192.168.1.145,3260]: successful
[root@teacher ~]# 

[root@teacher ~]# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c5742

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       25509   204796620   83  Linux
/dev/sda3           25510       25764     2048287+  82  Linux swap / Solaris
/dev/sda4           25765       60801   281434702+   5  Extended
/dev/sda5           25779       25804      208813+  83  Linux
/dev/sda6           25765       25778      112423+  83  Linux
/dev/sda7           25805       25811       56196   83  Linux
/dev/sda8           25812       25818       56196   83  Linux
/dev/sda9           25819       25825       56196   83  Linux
/dev/sda10          25826       25832       56196   83  Linux
/dev/sda11          25833       25839       56196   83  Linux
/dev/sda12          25840       25846       56196   83  Linux
/dev/sda13          25847       25853       56196   83  Linux
/dev/sda14          25854       25860       56196   83  Linux
/dev/sda15          25861       25867       56196   83  Linux
/dev/sda16          25868       26390     4200966   83  Linux

Partition table entries are not in disk order

Disk /dev/sdb: 20.0 GB, 20012073984 bytes
64 heads, 32 sectors/track, 19085 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

[root@teacher ~]# service iscsi start 读取/var/lib/iscsi/中的数据进行登入
[root@teacher ~]# service iscsi stop  登出
[root@teacher ~]# service iscsid start  发现存储之前,必须 先启动这个服务 


5,使用存储  制作 LVM -- 格式化 -- 挂载
[root@teacher ~]# pvcreate  /dev/sdb
  Physical volume "/dev/sdb" successfully created
[root@teacher ~]# pvcreate  /dev/sdc
  Physical volume "/dev/sdc" successfully created
[root@teacher ~]# vgcreate vg_san1  /dev/sdb /dev/sdc
  Volume group "vg_san1" successfully created
[root@teacher ~]# vgs
  VG      #PV #LV #SN Attr   VSize  VFree 
  vg_san1   2   0   0 wz--n- 19.12G 19.12G
[root@teacher ~]# lvcreate  -L 10G -n lv_san1  vg_san1
  Logical volume "lv_san1" created
[root@teacher ~]# lvs
  LV      VG      Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_san1 vg_san1 -wi-a- 10.00G                                      
[root@teacher ~]# mkfs.ext3 /dev/vg_san1/lv_san1 
[root@teacher ~]# mount -t ext3 /dev/vg_san1/lv_san1  /var/www/html/
[root@teacher ~]# df -Th /var/www/html/
文件系统      类型    容量  已用 可用 已用% 挂载点
/dev/mapper/vg_san1-lv_san1
              ext3    9.9G  151M  9.2G   2% /var/www/html
[root@teacher ~]# ls -l /dev/vg_san1/lv_san1 
lrwxrwxrwx 1 root root 27 08-15 11:09 /dev/vg_san1/lv_san1 -> /dev/mapper/vg_san1-lv_san1
[root@teacher ~]# 



IP SAN (iscsi)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值