Configure and deploy ISCSI shared storage

Keywords: RPM vim yum

;

Install ISCSI server side

1. Install ISCSI server side
1) Install dependencies
[root@centos01 ~]# yum -y install sg3_utils
2) Install dependent tools
[root@centos01 ~]# rpm -ivh /usr/src/perl-Config-General-2.61-1.el7.noarch.rpm
3) Install ISCSI server
[root@centos01 ~]# rpm -ivh /usr/src/scsi-target-utils-1.0.55-4.el7.x86_64.rpm
Set up ISCSI server-side startup and power on automatic startup
2. Set up ISCSI server-side startup and power on automatic startup
1) Start ISCSI server side
[root@centos01 ~]# systemctl start tgtd
2) Set the startup of ISCSI server
[root@centos01 ~]# systemctl enable tgtd
3) Listening port number
[root@centos01 ~]# netstat -anptu |grep 3260

Add five hard disks

Partition the hard disk into four primary partitions, each with a size of 5 G, and convert the partition type to LVM
[root@centos01 ~]# fdisk /dev/sdb

Create LVM on ISCSI server

3. Create LVM on ISCSI server
1) Create physical volume
[root@centos01 ~]# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4
2) Creating a volume group yun03 adding physical volumes to a volume group
[root@centos01 ~]# vgcreate yun03 /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4
3) Create logical volume
[root@centos01 ~]# lvcreate -L 15G -n 03 yun03
Configuring RAID5 volumes and two methods
4. The first way to configure RAID5 volume is to use hard disk partition
Partition / dev/sdc, / dev/sdb, / dev/sde, / dev/sdf respectively, and convert them to fd


! [insert picture description here]( https://img-blog.csdnimg.cn/20200608112340115.png

1) Create RAID5 volume

[root@centos01 ~]# mdadm -Cv /dev/md0 -a yes -n4 -l5 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1

Configure the second way to create RAID5 volumes

mdadm -Cv /dev/md0 -a yes -n4 -l5 /dev/sd[cdef] this command uses multiple partitions continuously as above, using the hard disk

2) Generate RAID5 profile

[root@centos01 ~]# mdadm -Dvs /dev/md0 > /etc/mdadm.conf
[root@centos01 ~]# echo "DEVICE /dev/sdc1,/dev/sdd1,/dev/sde1,/dev/sdf1" >> /etc/mdadm.conf
//Configure the ISCSI server side to share LVM volumes and RAID5 volumes
1,Modify the hosts file
[root@centos01 ~]# vim /etc/hosts
192.168.100.10  store.benet.com
2,establish ISCSI Shared storage, shared LVM Logical volume
1}Create a shared point
[root@centos01 ~]# tgtadm -L iscsi -o new -m target -t 1 -T iqn.2020.05.com.benet.store:lvm
2)take iqn Label binding to storage device lvm On logical volume
[root@centos01 ~]# tgtadm -L iscsi -o new -m logicalunit -t 1 -l 1 -b /dev/yun03/03
3)Set access control list to allow client access
[root@centos01 ~]# tgtadm -L iscsi -o bind -m target -t 1 -I 192.168.100.20
4)see ISCSI Shared storage
[root@centos01 ~]# tgtadm -L iscsi -o show -m target
3,establish ISCSI Shared storage, shared RAID5 volume
1)Create a shared point
[root@centos01 ~]# tgtadm -L iscsi -o new -m target -t 2 -T iqn.2020.05.com.benet.store:RAID
2)take iqn Label bundle to storage device RAID5 On disk
[root@centos01 ~]# tgtadm -L iscsi -o new -m logicalunit -t 2 -l 2 -b /dev/md0
3)Setting the access control list to allow clients 192.168.100.20
[root@centos01 ~]# tgtadm -L iscsi -o bind -m target -t 2 -I 192.168.100.30

//Saving the configured iscsi shared storage
4,Save configured iscsi Shared storage
1)modify iscsi Master profile
[root@centos01 ~]# vim /etc/tgt/targets.conf
<target iqn.2020.05.com.benet.store:lvm>
  direct-store /dev/yun03/03
  initiator-address 192.168.100.20
</target>
 
<target iqn.2020.05.com.benet.store:RAID>
  direct-store /dev/md0
  initiator-address 192.168.100.30
</target>
2)Restart iscsi Server side
[root@centos01 ~]# systemctl restart tgtd


Configure ISCSI client
1. Install ISCSI client
1) Install client

[root@centos02 ~]# yum -y install iscsi-initiator-utils
2)Start client service settings power on auto start
[root@centos02 ~]# systemctl start iscsi
[root@centos02 ~]# systemctl enable iscsi
2,Client connection ISCSI Server side
1)Scan server side
[root@centos02 ~]# iscsiadm -m discovery -t st -p 192.168.100.10
2)Access scanned share points
[root@centos02 ~]#  iscsiadm -m node -T iqn.2020.05.com.benet.store:lvm –login



3) Format mounted file system

 [root@centos02 ~]# mkfs -t xfs /dev/sdb
[root@centos02 ~]# mount /dev/sdb /mnt/


4) Disconnect shared storage

[root@centos02 ~]# iscsiadm -m node -T iqn.2020.05.com.benet.store:lvm –logout
Fdisk View no

Clients connect to ISCSI servers to access RAID5 volumes

1)Scan server side
	[root@centos03 ~]# iscsiadm -m discovery -t st -p 192.168.100.10
2)Client access scan share point
	[root@centos03 ~]# iscsiadm -m node -T iqn.2020.05.com.benet.store:RAID  --login


3) Format mount file system
[root@centos03 ~]# mkfs -t xfs /dev/sdb
[root@centos03 ~]# mount /dev/sdb /mnt/

4) Disconnect shared storage

	[root@centos03 ~]# iscsiadm -m node -T iqn.2020.05.com.benet.store:RAID –logout

Set up client auto mount

[root@centos02 ~]# vim /etc/fstab
/dev/sdb                                  /mnt                    xfs     defaults,_netdev 0 0


Restart client
[root@centos02 ~]# reboot
View mount

Posted by powerpants on Sun, 07 Jun 2020 20:49:08 -0700