This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
storage:iscsi [2017/08/30 13:33] frank |
storage:iscsi [2018/05/03 17:03] (current) frank |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ==== iSCSI client ==== | ||
| + | === install iscsi-initiator-utils === | ||
| + | # yum install iscsi-initiator-utils | ||
| + | === iscsiadm command === | ||
| <code> | <code> | ||
| list | list | ||
| Line 5: | Line 9: | ||
| logout all | logout all | ||
| # iscsiadm -m node -U all | # iscsiadm -m node -U all | ||
| + | |||
| + | session | ||
| + | # iscsiadm -m session | ||
| + | # iscsiadm -m session -P 3 | ||
| + | |||
| + | discover | ||
| + | # iscsiadm -m discovery -t st -p <IP> | ||
| + | 10.196.241.255:3260,1 iqn.2015-02.oracle.boot:uefi | ||
| + | |||
| + | login | ||
| + | # iscsiadm -m node -T iqn.2015-02.oracle.boot:uefi -l | ||
| + | Logging in to [iface: default, target: iqn.2015-02.oracle.boot:uefi, portal: 10.196.241.255,3260] (multiple) | ||
| + | Login to [iface: default, target: iqn.2015-02.oracle.boot:uefi, portal: 10.196.241.255,3260] successful. | ||
| + | |||
| + | list iSCSI disks | ||
| + | # lsblk | ||
| + | |||
| + | Turn on SCSI/iSCSI error handling lgos | ||
| + | echo -n 1 > /sys/module/libiscsi/parameters/debug_libiscsi_eh | ||
| + | echo -n 0xff > /sys/module/scsi_mod/parameters/scsi_logging_level | ||
| + | |||
| + | Or | ||
| + | scsi_logging_level -s --error 7 --timeout 7 --all 0 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ==== targetcli ==== | ||
| + | |||
| + | http://linux-iscsi.org/wiki/Targetcli | ||
| + | |||
| + | https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch24 | ||
| + | |||
| + | |||
| + | === installation === | ||
| + | * RHEL7/CentOS7 | ||
| + | |||
| + | <code> | ||
| + | yum install targetcli | ||
| + | systemctl status target | ||
| + | systemctl enable target | ||
| + | targetcli | ||
| + | /> 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] | ||
| + | |||
| + | </code> | ||
| + | |||
| + | |||
| + | === Create backstores === | ||
| + | |||
| + | <code> | ||
| + | FILEIO (Linux file-backed storage) write_back and write_thru | ||
| + | /> /backstores/fileio create file1 /home/tgt/disk1.img 100G write_back=false | ||
| + | Created fileio file1 with size 107374182400 | ||
| + | /> ls /backstores/fileio/ | ||
| + | o- fileio ..................................................................................................... [Storage Objects: 1] | ||
| + | o- file1 ................................................................. [/home/tgt/disk1.img (100.0GiB) write-thru deactivated] | ||
| + | o- alua ....................................................................................................... [ALUA Groups: 1] | ||
| + | o- default_tg_pt_gp ........................................................................... [ALUA state: Active/optimized] | ||
| + | |||
| + | BLOCK (Linux BLOCK devices) | ||
| + | /> /backstores/block create name=block1 dev=/dev/sdb | ||
| + | Generating a wwn serial. | ||
| + | Created block storage object block_backend using /dev/sdb. | ||
| + | |||
| + | PSCSI(Linux pass-through SCSI devices) | ||
| + | |||
| + | RAMDISK(Linux RAMDISK_MCP) | ||
| + | </code> | ||
| + | |||
| + | === Configure target === | ||
| + | <code> | ||
| + | /> iscsi/ | ||
| + | /iscsi> create iqn.2015-02.oracle.boot:uefi | ||
| + | Created target iqn.2015-02.oracle.boot:uefi. | ||
| + | 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 .............................................................................................................. [Targets: 1] | ||
| + | o- iqn.2015-02.oracle.boot:uefi ........................................................................................ [TPGs: 1] | ||
| + | o- tpg1 ................................................................................................. [no-gen-acls, no-auth] | ||
| + | o- acls ............................................................................................................ [ACLs: 0] | ||
| + | o- luns ............................................................................................................ [LUNs: 0] | ||
| + | o- portals ...................................................................................................... [Portals: 1] | ||
| + | o- 0.0.0.0:3260 ....................................................................................................... [OK] | ||
| + | |||
| + | </code> | ||
| + | |||
| + | === configure iSCSI portal === | ||
| + | <code> | ||
| + | # create a portal | ||
| + | /iscsi> | ||
| + | /> /iscsi/iqn.2015-02.oracle.boot:uefi/tpg1/portals | ||
| + | /iscsi/iqn.20../tpg1/portals> create | ||
| + | |||
| + | # delete a portal | ||
| + | /iscsi/iqn.20.../tpg1/portals/delete ip_address=0.0.0.0 ip_port=3260 | ||
| + | </code> | ||
| + | |||
| + | === configure LUNs === | ||
| + | <code> | ||
| + | /> iscsi/iqn.2015-02.oracle.boot:uefi/tpg1/luns/ | ||
| + | /iscsi/iqn.20...efi/tpg1/luns> create /backstores/fileio/file1 | ||
| + | Created LUN 0. | ||
| + | </code> | ||
| + | |||
| + | === Create ACL === | ||
| + | <code> | ||
| + | /> /iscsi/iqn.2015-02.oracle.boot:uefi/tpg1/acls | ||
| + | /iscsi/iqn.20...efi/tpg1/acls> create iqn.2015-02.oracle.boot:instance | ||
| + | Created Node ACL for iqn.2015-02.oracle.boot:instance | ||
| + | Created mapped LUN 0. | ||
| + | Created mapped LUN 1. | ||
| + | |||
| </code> | </code> | ||