LINUX_ISCSI Storage Services

Source: Internet
Author: User

Add 4 more drives to the TARGETD server:

Create a RAID5 and set up 1 backup failure disks:

Mdadm-cv/dev/md0-n 3-l 5-x 1/dev/sd{b,c,d,e}

To create a RAID array configuration file:

Mdadm-ds >/etc/mdadm.conf

Vim/etc/mdadm.conf

Device/dev/sdb/dev/sdc/dev/sdd/dev/sde

array/dev/md0 metadata=1.2 spares=2 name=localhost.localdomain:0 Uuid=5d5e7663:aa6e6ba2:0ece43d3:6b4c14d2

Installing the TARGETD and TARGETCLI kits

Yum install-y targetd targetcli

Start the service

Systemctl Start targetd

Systemctl Enable targetd

Creates a storage object.

Targetcli

To view the current storage directory tree:

/> ls

Enter the/backstores/block directory:

/> Cd/backstores/block

To create a device disk0 using/dev/md0:

/backstores/block> Create disk0/dev/md0

Go to the iSCSI directory:

/> CD/ISCSI

To create an iSCSI target target:

/iscsi> Create iqn.2017-08.domain.com:target01

Enter the LUNs directory to create the device information

/iscsi> CD Iqn.2017-08.domain.com:target01/tpg1/luns

/iscsi/iqn.20...t01/tpg1/luns> Create/backstores/block/disk0

/iscsi/iqn.20...t01/tpg1/luns> ls

O-luns ... [Luns:1]

O-lun0 ... [Block/disk0 (/DEV/MD0)]

Enter the portals directory to create the access IP and port

/iscsi/iqn.20...t01/tpg1/luns> CD. /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 192.168.200.100 3260

Enter the ACLs directory to create client access control

/iscsi/iqn.20.../tpg1/portals> CD. /acls

/iscsi/iqn.20...t01/tpg1/acls> ls

O-acls ..... [acls:0]

/iscsi/iqn.20...t01/tpg1/acls> Create Iqn.2017-08.domain.com:webserver01

/iscsi/iqn.20...t01/tpg1/acls> Create Iqn.2017-08.domain.com:webserver02

Go to the root directory to display all information

/> CD/

/> ls

O/... ... .... ... .... ... .... ... ..... ..... ..... ..... ..... ..... .................... [...]

O-backstores ..... ..... ..... ..... ..... ........................ [...]

| O-block ........ ...................... [Storage Objects:1]

| | O-disk0 ........... [/dev/md0 (16.0GiB) Write-thru activated]

| O-fileio ....... ....................... [Storage objects:0]

| O-pscsi ........ ...................... [Storage objects:0]

| O-ramdisk ....... ....................... [Storage objects:0]

O-iscsi ..... ..... ..... ..... .......................... [Targets:1]

| O-iqn.2017-08.domain.com:target01 ......... .......... [Tpgs:1]

| O-tpg1 ........ ..................... [No-gen-acls, No-auth]

| O-acls ..... ..... ..... ........................... [Acls:2]

| | O-iqn.2017-08.domain.com:webserver01 ..... [Mapped Luns:1]

| | | O-mapped_lun0 ........ ......... [Lun0 block/disk0 (rw)]

| | O-iqn.2017-08.domain.com:webserver02 ..... [Mapped Luns:1]

|   | O-mapped_lun0 ........ ......... [Lun0 block/disk0 (rw)]

| O-luns ..... ..... ..... ........................... [Luns:1]

| | O-lun0 ......... ............... [Block/disk0 (/DEV/MD0)]

| O-portals ........ ........................ [Portals:1]

| O-192.168.200.100:3260 ........ ................... [OK]

O-loopback ..... ..... ..... .......................... [targets:0]

/> Saveconfig

/> Exit

Ss-ntlu | grep 3260

TCP LISTEN 0 256 192.168.200.100:3260

ISCSI Initiator Client Configuration
    1. Installing the Iscsi-initiator-utils Package

Yum Install-y iscsi-initiator-utils

2. Edit the iSCSI Initiator client name file (the name matches the ACLs of the iSCSI server)

Vim/etc/iscsi/initiatorname.iscsi

#webserver01:

Initiatorname=iqn.2017-08.domain.com:webserver01

#webserver02:

Initiatorname=iqn.2017-08.domain.com:webserver02

3. Start the service

Systemctl Restart Iscsid.service

Systemctl Enable Iscsid.service

4. ISCSI Initiator client discovers and connects to the target end storage device

Iscsiadm--mode Discovery--type sendtargets--portal 192.168.200.100

192.168.200.100:3260,1 iqn.2017-08.domain.com:target01

Iscsiadm--mode node--targetname iqn.2017-08.domain.com:target01--portal 192.168.200.100:3260--login

Iscsiadm

--mode discovery or-M discovery "indicates Discovery Lookup

--type sendtargets or-t sendtargets or-T st "indicates the target of the publication

--portal ip:port or-p ip:port used to specify the server IP address

--mode node or-m nodes to manage the target

--login or-L indicates a login connection

--logout means log out connection

5. More than one hard drive/dev/sdb

Fdisk-l

6. Create a file system and mount it

Mkfs.xfs-f/dev/sdb

Mkdir/mnt/iscsi-disk01

mount/dev/sdb/mnt/iscsi-disk01/

7. Configure Auto Mount

Vim/etc/fstab

/dev/sdb/mnt/iscsi-disk01 XFS Defaults,_netdev 0 0

Set to automatically mount when powered on because the iSCSI server transmits data based on the IP network, we must add the parameter _netdev to the Fstab file, and then mount it on behalf of the network

df-h | Grep/dev/sdb

/dev/sdb 16G 33M 16G 1%/mnt/iscsi-disk01

Create a file test

Touch 1 2 3 4

ll

Total 0

-rw-r--r--1 root root 0 13 21:08 1

-rw-r--r--1 root root 0 13 21:08 2

-rw-r--r--1 root root 0 13 21:08 3

-rw-r--r--1 root root 0 13 21:08 4

Umount/dev/sdb

Webserver02 Mount

Mount/dev/sdb/mnt/iscsi-disk01

Ls

1 2 3 4

LINUX_ISCSI Storage Services

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.