linux 7.4 版本 iscsi搭建共享存储实战

主机:

10.10.6.83 rac1 

10.10.6.84 rac2


---版本

[root@rac1 iscsi]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

我在  rac1 主机上划分了一个50G的空间盘,打算用iscsi服务共享给两台主机rac1,rac2 ,下面是操作步骤


1、查看共享存储用的盘

[root@rac1 iscsi]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e5720
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648   104857599    52222976   8e  Linux LVM
/dev/sda3       104857600   209715199    52428800    5  Extended
/dev/sda5       104859648   209715199    52427776   83  Linux


Disk /dev/mapper/centos-root: 49.2 GB, 49178214400 bytes, 96051200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

这里我用盘/dev/sda5  来做两台主机的共享存储


2、安装iscsi 客户端软件

yum -y installiscsi-initiator-utils

---重启服务

[root@rac2 iscsi]# systemctl restart iscsi

[root@rac2 iscsi]# systemctl enable iscsi


---修改两台主机iscsi客户识别号

[root@rac1 iscsi]# pwd
/etc/iscsi
[root@rac1 iscsi]# ls
initiatorname.iscsi  iscsid.conf
[root@rac1 iscsi]# vi      initiatorname.iscsi 
InitiatorName=iqn.1994-05.com.redhat:rac1


[root@rac2 iscsi]# cat initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:rac2


注意:客户端的 initiator Node Name 配置成与 target ACL 的一致


3、在rac1 主机上 建立iscsi 服务

3.1 安装iscsi软件 

[root@rac1etc]# yum install targetcli*


 3.2 启动target服务

systemctl   start   target

systemctl    enable target


3.3 进入管理控制台

[root@rac1etc]# targetcli


 3.4 建立一个块储存server1,使用上面新添加硬盘/dev/sda5

/backstores/block  create  server1  /dev/sda5


创建完成后,会在 /backstores/block  下面可以看出多了server1


3.5  建立target的id :

注意: iqn.1994-05.com.redhat:rac1 名称的选取一定要与server1 磁盘所对应的InitiatorName一样,(或者修改initiatorname.iscsi 文件内容)

建立一个名称iqn为iqn.1994-05.com.redhat:rac1

/> cd    iscsi

/iscsi>create     iqn.1994-05.com.redhat:rac1



3.6 设置哪些设备可以连接到此iqn上:

cd  /iscsi/iqn.1994-05.com.redhat:rac1/tpg1/acls

create   iqn.1994-05.com.redhat:rac2

create   iqn.1994-05.com.redhat:rac1




3.7  lun 和具体的磁盘联系在一起,前面已经把/dev/sda5磁盘创建成了server1

Cd  /iscsi/ iqn.1994-05.com.redhat:rac1/tpg1/luns

Create     /backstores/block/server1







3.8  配置target监听IP和端口(默认在所有接口IP3260/tcp监听)

Cd /iscsi/ iqn.1994-05.com.redhat:rac1/tpg1/portals

delete 0.0.0.03260

Create  10.10.6.83

Create  10.10.6.84

3.9  保存配置

/iscsi/iqn.20.../tpg1/portals>cd /

/>saveconfig

[root@rac1 iscsi]#  iscsiadm -m discovery -t st -p  10.10.6.83
10.10.6.83:3260,1 iqn.1994-05.com.redhat:rac1

[root@rac2 iscsi]# cat initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:rac2


linux 7.4 版本 iscsi搭建共享存储实战_第1张图片

 4 客户端登陆服务

[root@rac1iscsi]# iscsiadm -m discovery -t st -p 10.10.6.83

10.10.6.83:3260,1iqn.1994-05.com.redhat:rac1

[root@rac1iscsi]# iscsiadm -m node -T iqn.1994-05.com.redhat:rac1 -p 10.10.6.83:3260 -l

Logging in to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260](multiple)

Login to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260]successful.


[root@rac2iscsi]# iscsiadm -m discovery -t st -p 10.10.6.83

10.10.6.83:3260,1iqn.1994-05.com.redhat:rac1

[root@rac2iscsi]# iscsiadm -m node -T iqn.1994-05.com.redhat:rac1 -p 10.10.6.83:3260 -l

Logging in to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260](multiple)

Login to[iface: default, target: iqn.1994-05.com.redhat:rac1, portal: 10.10.6.83,3260]successful.

 


[root@rac1 iscsi]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e5720

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648   104857599    52222976   8e  Linux LVM
/dev/sda3       104857600   209715199    52428800    5  Extended
/dev/sda5       104859648   209715199    52427776   83  Linux

Disk /dev/mapper/centos-root: 49.2 GB, 49178214400 bytes, 96051200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 53.7 GB, 53686042624 bytes, 104855552 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes


磁盘共享成功

你可能感兴趣的:(linux)