linux 配置IPSAN存储
一 SAN存储
1.1 SAN存储介绍
存储区域网络(Storage Area Network,简称SAN)采用网状通道(Fibre Channel ,简称FC,区别与Fiber Channel光纤通道)技术,通过FC交换机连接存储阵列和服务器主机,建立专用于数据存储的区域网络。
1.2 SAN存储分类
常见的分类是FC-SAN和IP-SAN两种。
FC-SAN通过光纤通道协议转发scsi协议;IP-SAN通过TCP协议转发scsi协议,也就是IP 地址。
存储设备是指一台或多台用以存储计算机数据的磁盘设备,通常指磁盘阵列,主要厂商EMC、日立等。
二 配置ip-SAN
2.1 ip-san服务器规划
下面配置IP-SAN存储实战
服务名称 |
服务器地址 |
操作系统 |
服务端 :node01 |
10.0.80.7 |
Centos 7 |
客户端 :node02 |
10.0.80.12 |
Centos 7 |
2.2 配置服务端
2.2.1设置主机名,安装target服务
[root@localhost ~]# hostnamectl set-hostname node01
[root@node01 ~]# yum install targetcli –y
[root@node01 ~]# systemctl status target
target.service - Restore LIO kernel target configuration
Loaded: loaded (/usr/lib/systemd/system/target.service; disabled)
Active: active (exited) since 一 2016-09-05 12:44:41 CST; 16s ago
Process: 14953 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS)
Main PID: 14953 (code=exited, status=0/SUCCESS)
9月 05 12:44:41 node01 systemd[1]: Starting Restore LIO kernel target configuration...
9月 05 12:44:41 node01 systemd[1]: Started Restore LIO kernel target configuration.
2.2.2 新建存储分区
通过vmvare新增加一块10G的硬盘
[root@node01 ~]# fdisk /dev/sdb #新建9G的分区
[root@node01 ~]# partprobe /dev/sdb # 重新加载分区信息表
2.2.3 创建存储对象
[root@node01 ~]# targetcli
targetcli shell version 2.1.fb41
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 0]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 0]
o- loopback ......................................................................................................... [Targets: 0]
/> cd backstores/block
/backstores/block>
/backstores/block> create share /dev/sdb
/dev/sdb /dev/sdb1
/backstores/block> create share /dev/sdb1 # 创建共享target名share
Created block storage object share using /dev/sdb1.
/backstores/block>
2.2.4 创建iqn共享名
/iscsi>
/iscsi> create iqn.2016-09.com.node01.www:server #创建iqn唯一标示
Created target iqn.2016-09.com.node01.www:server.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
2.2.5 创建acl指定可访问iscisi可访问的客户端
/iscsi> cd iqn.2016-09.com.node01.www:server/
/iscsi/iqn.20...01.www:server> ls
o- iqn.2016-09.com.node01.www:server ..................................................................................... [TPGs: 1]
o- tpg1 ................................................................................................... [no-gen-acls, no-auth]
o- acls .............................................................................................................. [ACLs: 0]
o- luns .............................................................................................................. [LUNs: 0]
o- portals ........................................................................................................ [Portals: 1]
o- 0.0.0.0:3260 ......................................................................................................... [OK]
/iscsi/iqn.20...01.www:server> cd tpg1/
tpg1/acls/ tpg1/luns/ tpg1/portals/
/iscsi/iqn.20...01.www:server> cd tpg1/acls
/iscsi/iqn.20...ver/tpg1/acls> create iqn.2016-09.com.node02.www:client #创建acl指定访问端
Created Node ACL for iqn.2016-09.com.node02.www:client
/iscsi/iqn.20...ver/tpg1/acls>
2.2.6 创建逻辑访问单元
/> cd iscsi/iqn.2016-09.com.node01.www:server/tpg1/luns
/iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/share #创建lun
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2016-09.com.node02.www:client
/iscsi/iqn.20...ver/tpg1/luns>
2.2.7 创建portals监控的ip
/> cd iscsi/iqn.2016-09.com.node01.www:server/tpg1/portals/
/iscsi/iqn.20.../tpg1/portals> ls
o- portals ............................................................................................................ [Portals: 1]
o- 0.0.0.0:3260 ............................................................................................................. [OK]
/iscsi/iqn.20.../tpg1/portals> delete 0.0.0.0 3260
Deleted network portal 0.0.0.0:3260
/iscsi/iqn.20.../tpg1/portals> create 10.0.80.7 # 创建portal
Using default IP port 3260
Created network portal 10.0.80.7:3260.
/iscsi/iqn.20.../tpg1/portals>
iscsi/iqn.20.../tpg1/portals> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@node01 ~]#
2.2.8 开放防火墙服务端口
[root@node01 ~]# firewall-cmd --add-port=3260/tcp --permanent
success
[root@node01 ~]# firewall-cmd --reload
success
[root@node01 ~]#
2.3 配置客户端
2.3.1 安装iscsi服务
[root@localhost ~]# hostnamectl set-hostname node02
[root@node02 ~]# yum install -y iscsi*
[root@node02 ~]# systemctl restart iscsi
[root@node02 ~]# systemctl enable iscsi
2.3.2 配置客户端的iqn
[root@node02 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:8a63cad4f079 # 默认配置
[root@node02 ~]# vi /etc/iscsi/initiatorname.iscsi
[root@node02 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2016-09.com.node02.www:client # 更改后的配置
[root@node02 ~]#
2.3.3 发现服务端
[root@node02 ~]# iscsiadm -t st -m discovery -p 10.0.80.7
10.0.80.7:3260,1 iqn.2016-09.com.node01.www:server # 如果现实为server的iqn则发现成功
2.3.4 连接服务端
[root@node02 ~]# iscsiadm -m node -T iqn.2016-09.com.node01.www:server -p 10.0.80.7 -l
Logging in to [iface: default, target: iqn.2016-09.com.node01.www:server, portal: 10.0.80.7,3260] (multiple)
Login to [iface: default, target: iqn.2016-09.com.node01.www:server, portal: 10.0.80.7,3260] successful.
[root@node02 ~]#
【注】:显示有successful字样表示连接成功
2.3.4 查看磁盘信息表
[root@node02 ~]# 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 4.9G 0 part /data
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 12.9G 0 part /
sdb 8:16 0 9G 0 disk # 通过iscisi识别的磁盘sdb大小为9G
sr0 11:0 1 4G 0 rom /mnt/iso
2.3.5 分区并创创建挂载目录挂载
[root@node02 ~]# fdisk /dev/sdb
[root@node02 ~]# fdisk –l
设备 Boot Start End Blocks Id System
/dev/sdb1 8192 16785407 8388608 83 Linux
[root@node02 ~]# mkdir iscsi
[root@node02 ~]# mkfs.xfs /dev/sdb1
root@node02 ~]# cat >>/etc/fstab<<EOF
> /dev/sdb1 /root/iscsi xfs defaults 0 0
> EOF
[root@node02 ~]# mount –a # 挂载写入配置文件后一定要mount –a测试确保不报错
[root@node02 ~]#
2.3.6 查看验证
[root@node02 ~]# df -h /root/iscsi/
文件系统 容量 已用 可用 已用% 挂载点
/dev/sdb1 8.0G 33M 8.0G 1% /root/iscsi
[root@node02 ~]#