botang 发表于 2020-3-16 19:54:57

课程第19次:2020-03-16星期一

1. iSCSI:

1.1 target:
# yum list "target*"
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1:24:39 ago on Mon 16 Mar 2020 07:23:38 PM CST.
Available Packages
target-restore.noarch                  2.1.fb69-3.el8                  BaseOS   
targetcli.noarch                     2.1.fb49-1.el8                  AppStream
# yum -y install targetcli.noarch
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1:24:51 ago on Mon 16 Mar 2020 07:23:38 PM CST.
Dependencies resolved.
================================================================================
Package               Arch       Version               Repository   Size
================================================================================
Installing:
targetcli               noarch   2.1.fb49-1.el8          AppStream      73 k
Installing dependencies:
python3-configshell   noarch   1:1.1.fb25-1.el8      BaseOS         74 k
python3-kmod            x86_64   0.9-20.el8            BaseOS         90 k
python3-pyparsing       noarch   2.1.10-7.el8            BaseOS      142 k
python3-rtslib          noarch   2.1.fb69-3.el8          BaseOS      100 k
python3-urwid         x86_64   1.3.1-4.el8             BaseOS      783 k
target-restore          noarch   2.1.fb69-3.el8          BaseOS         23 k

Transaction Summary
================================================================================
Install7 Packages

Total size: 1.3 M
Installed size: 4.7 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing      :                                                      1/1
Installing       : python3-urwid-1.3.1-4.el8.x86_64                     1/7
Installing       : python3-pyparsing-2.1.10-7.el8.noarch                  2/7
Installing       : python3-configshell-1:1.1.fb25-1.el8.noarch            3/7
Installing       : python3-kmod-0.9-20.el8.x86_64                         4/7
Installing       : python3-rtslib-2.1.fb69-3.el8.noarch                   5/7
Installing       : target-restore-2.1.fb69-3.el8.noarch                   6/7
Running scriptlet: target-restore-2.1.fb69-3.el8.noarch                   6/7
Installing       : targetcli-2.1.fb49-1.el8.noarch                        7/7
Running scriptlet: targetcli-2.1.fb49-1.el8.noarch                        7/7
Verifying      : targetcli-2.1.fb49-1.el8.noarch                        1/7
Verifying      : python3-configshell-1:1.1.fb25-1.el8.noarch            2/7
Verifying      : python3-kmod-0.9-20.el8.x86_64                         3/7
Verifying      : python3-pyparsing-2.1.10-7.el8.noarch                  4/7
Verifying      : python3-rtslib-2.1.fb69-3.el8.noarch                   5/7
Verifying      : python3-urwid-1.3.1-4.el8.x86_64                     6/7
Verifying      : target-restore-2.1.fb69-3.el8.noarch                   7/7
Installed products updated.

Installed:
targetcli-2.1.fb49-1.el8.noarch                                             
python3-configshell-1:1.1.fb25-1.el8.noarch                                 
python3-kmod-0.9-20.el8.x86_64                                                
python3-pyparsing-2.1.10-7.el8.noarch                                       
python3-rtslib-2.1.fb69-3.el8.noarch                                          
python3-urwid-1.3.1-4.el8.x86_64                                             
target-restore-2.1.fb69-3.el8.noarch                                          

Complete!
# systemctl enable target
Created symlink /etc/systemd/system/multi-user.target.wants/target.service → /usr/lib/systemd/system/target.service.
# firewall-cmd --permanet --add-port 3260/tcp
usage: see firewall-cmd man page
firewall-cmd: error: unrecognized arguments: --permanet
# firewall-cmd --permanent --add-port 3260/tcp
FirewallD is not running
# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> ls
o- / ..................................................................... [...]
o- backstores .......................................................... [...]
| o- block ..............................................
| o- fileio .............................................
| o- pscsi ..............................................
| o- ramdisk ............................................
o- iscsi ........................................................
o- loopback .....................................................
/> cd backstores
/backstores> ls
o- backstores ............................................................ [...]
o- block ................................................
o- fileio ...............................................
o- pscsi ................................................
o- ramdisk ..............................................
/backstores> cd block
/backstores/block> help

GENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.

The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.

The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.

Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.

COMMAND SYNTAX
==============
Commands are built using the following syntax:

COMMAND_NAME

The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.

The OPTIONS depend on the command. Please use help
COMMAND to get more information.


AVAILABLE COMMANDS
==================
The following commands are available in the
current path:

- bookmarks action
- cd
- create name dev
- delete name
- exit
- get
- help
- ls
- pwd
- refresh
- set
- status
/backstores/block>createshareddisk1 /dev/vol0/lv0
Created block storage object shareddisk1 using /dev/vol0/lv0.
/backstores/block> ls
o- block ..............................................................................
o- shareddisk1 ..........................................
    o- alua ...............................................................................
      o- default_tg_pt_gp ...................................................
/backstores/block> cd ..
/backstores> ls
o- backstores ........................................................................................ [...]
o- block ............................................................................
| o- shareddisk1 ........................................
|   o- alua .............................................................................
|   o- default_tg_pt_gp .................................................
o- fileio ...........................................................................
o- pscsi ............................................................................
o- ramdisk ..........................................................................
/backstores> cd ..
/> ls
o- / ................................................................................................. [...]
o- backstores ...................................................................................... [...]
| o- block ..........................................................................
| | o- shareddisk1 ......................................
| |   o- alua ...........................................................................
| |   o- default_tg_pt_gp ...............................................
| o- fileio .........................................................................
| o- pscsi ..........................................................................
| o- ramdisk ........................................................................
o- iscsi ....................................................................................
o- loopback .................................................................................
/> cd iscsi
/iscsi> ls
o- iscsi ......................................................................................
/iscsi> help

GENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.

The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.

The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.

Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.

COMMAND SYNTAX
==============
Commands are built using the following syntax:

COMMAND_NAME

The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.

The OPTIONS depend on the command. Please use help
COMMAND to get more information.


AVAILABLE COMMANDS
==================
The following commands are available in the
current path:

- bookmarks action
- cd
- create
- delete wwn
- exit
- get
- help
- info
- ls
- pwd
- refresh
- set
- status
- version
/iscsi> createiqn.2020-03.com.example.classroom:shareddisk1
Created target iqn.2020-03.com.example.classroom:shareddisk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi ......................................................................................
o- iqn.2020-03.com.example.classroom:shareddisk1 ...............................................
    o- tpg1 .........................................................................
      o- acls ....................................................................................
      o- luns ....................................................................................
      o- portals ..............................................................................
      o- 0.0.0.0:3260 ...............................................................................
/iscsi> cd
<                                             >                                             
@last                                           iqn.2020-03.com.example.classroom:shareddisk1/
path=                                          
/iscsi> cd iqn.2020-03.com.example.classroom:shareddisk1/tpg1/
iqn.2020-03.com.example.classroom:shareddisk1/tpg1/acls/   
iqn.2020-03.com.example.classroom:shareddisk1/tpg1/luns/   
iqn.2020-03.com.example.classroom:shareddisk1/tpg1/portals/
/iscsi> cd iqn.2020-03.com.example.classroom:shareddisk1/tpg1/
/iscsi/iqn.20...reddisk1/tpg1> ls
o- tpg1 .............................................................................
o- acls ........................................................................................
o- luns ........................................................................................
o- portals ..................................................................................
    o- 0.0.0.0:3260 ...................................................................................
/iscsi/iqn.20...reddisk1/tpg1> cd acls
/iscsi/iqn.20...sk1/tpg1/acls> ls
o- acls ..........................................................................................
/iscsi/iqn.20...sk1/tpg1/acls> help

GENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.

The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.

The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.

Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.

COMMAND SYNTAX
==============
Commands are built using the following syntax:

COMMAND_NAME

The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.

The OPTIONS depend on the command. Please use help
COMMAND to get more information.


AVAILABLE COMMANDS
==================
The following commands are available in the
current path:

- bookmarks action
- cd
- create wwn
- delete wwn
- exit
- get
- help
- ls
- pwd
- refresh
- set
- status
- tag wwn_or_tag new_tag
- untag wwn_or_tag
/iscsi/iqn.20...sk1/tpg1/acls> create iqn.2020-03.com.example.server5:shareddisk1
Created Node ACL for iqn.2020-03.com.example.server5:shareddisk1
/iscsi/iqn.20...sk1/tpg1/acls> create iqn.2020-03.com.example.server4:shareddisk1
Created Node ACL for iqn.2020-03.com.example.server4:shareddisk1
/iscsi/iqn.20...sk1/tpg1/acls> ls
o- acls ..........................................................................................
o- iqn.2020-03.com.example.server4:shareddisk1 ..........................................
o- iqn.2020-03.com.example.server5:shareddisk1 ..........................................
/iscsi/iqn.20...sk1/tpg1/acls> cd ..
/iscsi/iqn.20...reddisk1/tpg1> ls
o- tpg1 .............................................................................
o- acls ........................................................................................
| o- iqn.2020-03.com.example.server4:shareddisk1 ........................................
| o- iqn.2020-03.com.example.server5:shareddisk1 ........................................
o- luns ........................................................................................
o- portals ..................................................................................
    o- 0.0.0.0:3260 ...................................................................................
/iscsi/iqn.20...reddisk1/tpg1> cdluns
/iscsi/iqn.20...sk1/tpg1/luns> ls
o- luns ..........................................................................................
/iscsi/iqn.20...sk1/tpg1/luns> ls
o- luns ..........................................................................................
/iscsi/iqn.20...sk1/tpg1/luns> help

GENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.

The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.

The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.

Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.

COMMAND SYNTAX
==============
Commands are built using the following syntax:

COMMAND_NAME

The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.

The OPTIONS depend on the command. Please use help
COMMAND to get more information.


AVAILABLE COMMANDS
==================
The following commands are available in the
current path:

- bookmarks action
- cd
- create storage_object
- delete lun
- exit
- get
- help
- ls
- pwd
- refresh
- set
- status
/iscsi/iqn.20...sk1/tpg1/luns> create/dev/vol0/lv0
storage object or path not valid
/iscsi/iqn.20...sk1/tpg1/luns> create shareddisk1
storage object or path not valid
/iscsi/iqn.20...sk1/tpg1/luns> create/backstores/block/shareddisk1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2020-03.com.example.server4:shareddisk1
Created LUN 0->0 mapping in node ACL iqn.2020-03.com.example.server5:shareddisk1
/iscsi/iqn.20...sk1/tpg1/luns> ls
o- luns ..........................................................................................
o- lun0 ...........................................
/iscsi/iqn.20...sk1/tpg1/luns> cd ..
/iscsi/iqn.20...reddisk1/tpg1> ls
o- tpg1 .............................................................................
o- acls ........................................................................................
| o- iqn.2020-03.com.example.server4:shareddisk1 ........................................
| | o- mapped_lun0 .........................................................
| o- iqn.2020-03.com.example.server5:shareddisk1 ........................................
|   o- mapped_lun0 .........................................................
o- luns ........................................................................................
| o- lun0 .........................................
o- portals ..................................................................................
    o- 0.0.0.0:3260 ...................................................................................
/iscsi/iqn.20...reddisk1/tpg1> cd portals
/iscsi/iqn.20.../tpg1/portals> ls
o- portals ....................................................................................
o- 0.0.0.0:3260 .....................................................................................
/iscsi/iqn.20.../tpg1/portals> help

GENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.

The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.

The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.

Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.

COMMAND SYNTAX
==============
Commands are built using the following syntax:

COMMAND_NAME

The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.

The OPTIONS depend on the command. Please use help
COMMAND to get more information.


AVAILABLE COMMANDS
==================
The following commands are available in the
current path:

- bookmarks action
- cd
- create
- delete ip_address ip_port
- exit
- get
- help
- ls
- pwd
- refresh
- set
- status
/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.0.254 3260
Using default IP port 3260
Created network portal 192.168.0.254:3260.
/iscsi/iqn.20.../tpg1/portals> ls
o- portals ....................................................................................
o- 192.168.0.254:3260 ...............................................................................
/iscsi/iqn.20.../tpg1/portals> cd /
/> ls
o- / ................................................................................................. [...]
o- backstores ...................................................................................... [...]
| o- block ..........................................................................
| | o- shareddisk1 ........................................
| |   o- alua ...........................................................................
| |   o- default_tg_pt_gp ...............................................
| o- fileio .........................................................................
| o- pscsi ..........................................................................
| o- ramdisk ........................................................................
o- iscsi ....................................................................................
| o- iqn.2020-03.com.example.classroom:shareddisk1 .............................................
|   o- tpg1 .......................................................................
|   o- acls ..................................................................................
|   | o- iqn.2020-03.com.example.server4:shareddisk1 ..................................
|   | | o- mapped_lun0 ...................................................
|   | o- iqn.2020-03.com.example.server5:shareddisk1 ..................................
|   |   o- mapped_lun0 ...................................................
|   o- luns ..................................................................................
|   | o- lun0 ...................................
|   o- portals ............................................................................
|       o- 192.168.0.254:3260 .......................................................................
o- loopback .................................................................................
/> quit
Command not found quit
/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json
# systemctl restart target
#

1.2 initiator:
# systemctl enable iscsi
# systemctl enable iscsd
Failed to enable unit: Unit file iscsd.service does not exist.
# systemctl enable iscsid
Created symlink /etc/systemd/system/multi-user.target.wants/iscsid.service → /usr/lib/systemd/system/iscsid.service.
# systemctl restart iscsid
# systemctl restart iscsi
# cat /proc/partitions
major minor#blocksname

   8      0   52428800 sda
   8      1   307200 sda1
   8      2   18944000 sda2
   8      3    1048576 sda3
   8      4   32128000 sda4
11      0    1048575 sr0
253      0   51064832 dm-0
# iscsiadm -m discovery -t sendtargets -p classroom.example.com:3260
192.168.0.254:3260,1 iqn.2020-03.com.example.classroom:shareddisk1
# iscsiadm-m node -T iqn.2020-03.com.example.classroom:shareddisk1--login
Logging in to (multiple)
Login to successful.
# cat /proc/partitions
major minor#blocksname

   8      0   52428800 sda
   8      1   307200 sda1
   8      2   18944000 sda2
   8      3    1048576 sda3
   8      4   32128000 sda4
11      0    1048575 sr0
253      0   51064832 dm-0
   8       16   52424704 sdb
   8       17          1 sdb1
   8       21    4764672 sdb5
   8       22    4764672 sdb6
   8       23    4764672 sdb7
   8       24    4764672 sdb8
   8       25    4764672 sdb9
   8       26    4764672 sdb10
   8       27    4764672 sdb11
   8       28    4764672 sdb12
   8       29    4764672 sdb13
   8       30    4764672 sdb14
   8       31    4764672 sdb15
# iscsiadm-m node -T iqn.2020-03.com.example.classroom:shareddisk1--logout
Logging out of session
Logout of successful.
# cat /proc/partitions
major minor#blocksname

   8      0   52428800 sda
   8      1   307200 sda1
   8      2   18944000 sda2
   8      3    1048576 sda3
   8      4   32128000 sda4
11      0    1048575 sr0
253      0   51064832 dm-0
# iscsiadm-m node -T iqn.2020-03.com.example.classroom:shareddisk1--login
Logging in to (multiple)
Login to successful.
# isc
isc-hmac-fixupiscsiadm      iscsid          iscsi-iname   iscsistart      iscsiuio      
# iscsiadm-m session -P 7
iscsiadm: Invalid info level 7. Try 0 - 3.
# iscsiadm-m session -P 3
iSCSI Transport Class version 2.0-870
version 6.2.0.876-5
Target: iqn.2020-03.com.example.classroom:shareddisk1 (non-flash)
      Current Portal: 192.168.0.254:3260,1
      Persistent Portal: 192.168.0.254:3260,1
                **********
                Interface:
                **********
                Iface Name: default
                Iface Transport: tcp
                Iface Initiatorname: iqn.2020-03.com.example.server5:shareddisk1
                Iface IPaddress: 192.168.0.105
                Iface HWaddress: default
                Iface Netdev: default
                SID: 2
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE
                *********
                Timeouts:
                *********
                Recovery Timeout: 120
                Target Reset Timeout: 30
                LUN Reset Timeout: 30
                Abort Timeout: 15
                *****
                CHAP:
                *****
                username: <empty>
                password: ********
                username_in: <empty>
                password_in: ********
                ************************
                Negotiated iSCSI params:
                ************************
                HeaderDigest: None
                DataDigest: None
                MaxRecvDataSegmentLength: 262144
                MaxXmitDataSegmentLength: 262144
                FirstBurstLength: 65536
                MaxBurstLength: 262144
                ImmediateData: Yes
                InitialR2T: Yes
                MaxOutstandingR2T: 1
                ************************
                Attached SCSI devices:
                ************************
                Host Number: 33 State: running
                scsi33 Channel 00 Id 0 Lun: 0
                        Attached scsi disk sdb          State: running
#



765686189 发表于 2020-3-16 22:14:49

md5:a2231d62e00a52bcfd7c70be8318fc62
已经转码
页: [1]
查看完整版本: 课程第19次:2020-03-16星期一