1. 小红帽首页
  2. Linux资源
  3. Linux实验教程

使用iSCSI服务部署网络存储(服务端)

既然要使用iSCSI存储技术为远程用户提供共享存储资源,首先要保障用于存放资源的服务器的稳定性及可用性,否则一旦在使用过程中出现故障,那么维护的难道相较于本地硬盘设备要更加的复杂,更加的困难。因此,以下实验将采用RAID10磁盘阵列组为大家讲解iSCSI网络存储教程。

1.首先使用mdadm创建RAID磁盘阵列。

mdadm -Cv /dev/md0 -n 4 -l 10 /dev/sd[b-e]

[root@www_rhce_net ~]# ll /dev/sd*

brw-rw----. 1 root disk 8, 0 Dec 21 2018 /dev/sda

brw-rw----. 1 root disk 8, 1 Dec 21 2018 /dev/sda1

brw-rw----. 1 root disk 8, 2 Dec 21 2018 /dev/sda2

brw-rw----. 1 root disk 8, 16 Dec 21 2018 /dev/sdb

brw-rw----. 1 root disk 8, 32 Dec 21 2018 /dev/sdc

brw-rw----. 1 root disk 8, 48 Dec 21 2018 /dev/sdd

brw-rw----. 1 root disk 8, 64 Dec 21 2018 /dev/sde

[root@www_rhce_net ~]# mdadm -Cv /dev/md0 -n 4 -l 10 /dev/sd[b-e]

mdadm: layout defaults to n2

mdadm: layout defaults to n2

mdadm: chunk size defaults to 512K

mdadm: size set to 20954624K

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.

mdadm -D /dev/md0

[root@www_rhce_net ~]# mdadm -D /dev/md0

/dev/md0:

Version : 1.2

Creation Time : Thu Dec 20 16:35:50 2018

Raid Level : raid10

Array Size : 41909248 (39.97 GiB 42.92 GB)

Used Dev Size : 20954624 (19.98 GiB 21.46 GB)

Raid Devices : 4

Total Devices : 4

Persistence : Superblock is persistent

Update Time : Thu Dec 20 16:36:04 2018

State : clean, resyncing

Active Devices : 4

Working Devices : 4

Failed Devices : 0

Spare Devices : 0

Layout : near=2

Chunk Size : 512K

Resync Status : 8% complete

Name : www_rhce_net:0 (local to host www_rhce_net)

UUID : ba31b64c:69923f4c:7b82d8e1:076b7d64

Events : 1

Number Major Minor RaidDevice State

0 8 16 0 active sync /dev/sdb

1 8 32 1 active sync /dev/sdc

2 8 48 2 active sync /dev/sdd

3 8 64 3 active sync /dev/sde

2.配置iSCSI服务端, 服务端(target)、客户端(initiator)

1)、配置yum仓库及安装iSCSI服务端程序以及配置命令工具。

[root@www_rhce_net ~]# yum install -y httpd

Loaded plugins: langpacks, product-id, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

rhce | 4.1 kB 00:00

(1/2): rhce/group_gz | 134 kB 00:00

(2/2): rhce/primary_db | 3.4 MB 00:00

......省略部分输出......

Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7
libyaml.x86_64 0:0.1.4-10.el7
lvm2-python-libs.x86_64 7:2.02.105-14.el7
pyparsing.noarch 0:1.5.6-9.el7
python-configshell.noarch 1:1.1.fb11-3.el7
python-kmod.x86_64 0:0.9-4.el7
python-rtslib.noarch 0:2.1.fb46-1.el7
python-setproctitle.x86_64 0:1.1.6-5.el7
python-urwid.x86_64 0:1.1.1-3.el7

Complete!

安装完iSCSI的服务端程序targetd,把服务程序加入到开机启动项中及重启服务程序。

[root@www_rhce_net ~]# systemctl start targetd

[root@www_rhce_net ~]# systemctl enable targetd

ln -s '/usr/lib/systemd/system/targetd.service' '/etc/systemd/system/multi-user.target.wants/targetd.service'

2)、配置iSCSI的服务端共享资源。

[root@www_rhce_net ~]# targetcli

Warning: Could not load preferences file /root/.targetcli/prefs.bin.

targetcli shell version 2.1.fb34

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> create disk0 /dev/md0

Created block storage object disk0 using /dev/md0.

/backstores/block> cd /

/> ls

o- / ................................................................................................................. [...]

o- backstores ...................................................................................................... [...]

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

| | o- disk0 ................................................................. [/dev/md0 (40.0GiB) write-thru deactivated]

| o- fileio ......................................................................................... [Storage Objects: 0]

| o- pscsi .......................................................................................... [Storage Objects: 0]

| o- ramdisk ........................................................................................ [Storage Objects: 0]

o- iscsi .................................................................................................... [Targets: 0]

o- loopback ................................................................................................. [Targets: 0]

/>

3)、创建iSCSItarget名称及配置共享资源。

/> cd iscsi

/iscsi> create

Created target iqn.2003-01.org.linux-iscsi.www_rhce_net.x8664:sn.e3831b732522.

Created TPG 1.

/iscsi> cdiqn.2003-01.org.linux-iscsi.www_rhce_net.x8664:sn.e3831b732522 

/iscsi/iqn.20....e3831b732522> ls

o-iqn.2003-01.org.linux-iscsi.www_rhce_net.x8664:sn.e3831b732522  [INVALID WWN]

o- tpg1 ............................................... [no-gen-acls, no-auth]

o- acls .......................................................... [ACLs: 0]

o- luns .......................................................... [LUNs: 0]

o- portals .................................................... [Portals: 0]

/iscsi/iqn.20....e3831b732522> cd tpg1/luns

/iscsi/iqn.20...f8b/tpg1/luns> create /backstores/block/disk0

Created LUN 0.

4)、设置访问控制列表(ACL)。

/iscsi/iqn.20....e3831b732522/tpg1/luns> cd .. 

/iscsi/iqn.20...1b732522/tpg1> cd acls

/iscsi/iqn.20...522/tpg1/acls> create iqn.2003-01.org.linux-iscsi.rhce.x8664:sn.e3831b732522:client

Created Node ACL for iqn.2003-01.org.linux-iscsi.rhce.x8664:sn.e3831b732522:client

Created mapped LUN 0.

5)、设置iSCSI服务端的监听IP地址及端口号。

/iscsi/iqn.20...522/tpg1/acls> cd ..

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

/iscsi/iqn.20.../tpg1/portals> create 192.168.10.10

Using default IP port 3260

Created network portal 192.168.10.10:3260.

6)、配置完成后,重启iSCSI服务端并配置防火策略。

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

o- / ..................................................................... [...]

o- backstores .......................................................... [...]

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

| | o- disk0 ....................... [/dev/md0 (40.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.2003-01.org.linux-iscsi.rhce.x8664:sn.e3831b732522 ........ [TPGs: 1]

| o- tpg1 ........................................... [no-gen-acls, no-auth]

| o- acls ...................................................... [ACLs: 1]

| | o- iqn.2003-01.org.linux-iscsi.rhce.x8664:sn.e3831b732522:client [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.10.10:3260 ........................................... [OK]

o- loopback ..................................................... [Targets: 0]

/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@www_rhce_net]# systemctl restart targetd

[root@www_rhce_net]# firewall-cmd --permanent --add-port=3260/tcp

success

[root@www_rhce_net]# firewall-cmd --reload

success

iSCSI服务端的配置到此就配置完成了!小伙伴,你学会了吗?

发布者:rhce_net,转转请注明出处:https://www.rhce.net/641.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论列表(1条)

  • mkdir
    mkdir 2018年12月21日 上午9:52

    学习了!哈哈哈!