> > > >
on RHEL/Centos/Fedora -- do an ' yum install targetcli'
Installing targetcli
THis is what I did on a fresh Fedora install
]# yum install targetcli
Loaded plugins: langpacks, presto, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package targetcli.noarch 0:2.0rc1.fb19-1.fc18 will be installed
--> Processing Dependency: python-rtslib >= 2.1.fb26 for package: targetcli-2.0rc1.fb19-1.f
--> Processing Dependency: python-configshell for package: targetcli-2.0rc1.fb19-1.fc18.noa
--> Running transaction check
---> Package python-configshell.noarch 1:1.1.fb6-1.fc18 will be installed
--> Processing Dependency: python-urwid for package: 1:python-configshell-1.1.fb6-1.fc18.no
--> Processing Dependency: python-simpleparse for package: 1:python-configshell-1.1.fb6-1.f
---> Package python-rtslib.noarch 0:2.1.fb28-1.fc18 will be installed
--> Processing Dependency: python-kmod for package: python-rtslib-2.1.fb28-1.fc18.noarch
--> Running transaction check
---> Package python-kmod.x86_64 0:0.1-4.fc18 will be installed
---> Package python-simpleparse.x86_64 0:2.1.1-5.fc18 will be installed
---> Package python-urwid.x86_64 0:1.1.1-1.fc18 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================
Package Arch Version Repo
===========================================================================================
Installing:
targetcli noarch 2.0rc1.fb19-1.fc18 upda
Installing for dependencies:
python-configshell noarch 1:1.1.fb6-1.fc18 upda
python-kmod x86_64 0.1-4.fc18 fedo
python-rtslib noarch 2.1.fb28-1.fc18 upda
python-simpleparse x86_64 2.1.1-5.fc18 fedo
python-urwid x86_64 1.1.1-1.fc18 fedo
Transaction Summary
===========================================================================================
Install 1 Package (+5 Dependent packages)
Total download size: 1.0 M
Installed size: 4.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): python-kmod-0.1-4.fc18.x86_64.rpm
(2/6): python-configshell-1.1.fb6-1.fc18.noarch.rpm
(3/6): targetcli-2.0rc1.fb19-1.fc18.noarch.rpm
(4/6): python-simpleparse-2.1.1-5.fc18.x86_64.rpm
(5/6): python-urwid-1.1.1-1.fc18.x86_64.rpm
python-rtslib-2.1.fb28-1.fc18. FAILED
ftp://ftp.uci.edu/mirrors/fedora/linux/updates/18/x86_64/python-rtslib-2.1.fb28-1.fc18.noarout on ftp://ftp.uci.edu/mirrors/fedora/linux/updates/18/x86_64/python-rtslib-2.1.fb28-1.fc
Trying other mirror.
(6/6): python-rtslib-2.1.fb28-1.fc18.noarch.rpm
-------------------------------------------------------------------------------------------
Total 32 kB/s
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : python-simpleparse-2.1.1-5.fc18.x86_64
Installing : python-kmod-0.1-4.fc18.x86_64
Installing : python-rtslib-2.1.fb28-1.fc18.noarch
Installing : python-urwid-1.1.1-1.fc18.x86_64
Installing : 1:python-configshell-1.1.fb6-1.fc18.noarch
Installing : targetcli-2.0rc1.fb19-1.fc18.noarch
Verifying : python-urwid-1.1.1-1.fc18.x86_64
Verifying : python-rtslib-2.1.fb28-1.fc18.noarch
Verifying : python-kmod-0.1-4.fc18.x86_64
Verifying : targetcli-2.0rc1.fb19-1.fc18.noarch
Verifying : python-simpleparse-2.1.1-5.fc18.x86_64
Verifying : 1:python-configshell-1.1.fb6-1.fc18.noarch
Installed:
targetcli.noarch 0:2.0rc1.fb19-1.fc18
Dependency Installed:
python-configshell.noarch 1:1.1.fb6-1.fc18 python-kmod.x86_64 0:0.1-4.fc18
python-rtslib.noarch 0:2.1.fb28-1.fc18 python-simpleparse.x86_64 0:2.1.
python-urwid.x86_64 0:1.1.1-1.fc18
Complete!
Configuration an iSCSI target
Creating an backing device
We can use LVM of a file as a backing store.
[root@fedora-storage target]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
1g-1-win2k8clu.vol rootvg -wi-ao---- 1.00g
1g-2-win2k8clu.vol rootvg -wi-ao---- 1.00g
5g-1-win2k8clu.vol rootvg -wi-ao---- 5.00g
5g-2-win2k8clu.vol rootvg -wi-ao---- 5.00g
We have created 4 LV's.
They will be used as backing stores.
Clear exsisitng config
This will clear all current config's (backing storges, portals, etc..)
# targetcli clearconfig confirm=true
All configuration cleared
create backing stores
targetadmin
bash: targetadmin: command not found...
[root@localhost host2]# targetcli
targetcli shell version 2.0rc1.fb19
Copyright 2011 by RisingTide Systems LLC and others.
For help on commands, type 'help'.
/> ls
o- / ................................................................................ [...]
o- backstores ..................................................................... [...]
| o- block ........................................................... [0 Storage Object]
| o- fileio .......................................................... [0 Storage Object]
| o- pscsi ........................................................... [0 Storage Object]
| o- ramdisk ......................................................... [0 Storage Object]
o- iscsi .................................................................... [0 Targets]
o- loopback ................................................................. [0 Targets]
/> cd backstores
/backstores> ls
o- backstores ....................................................................... [...]
o- block ............................................................. [0 Storage Object]
o- fileio ............................................................ [0 Storage Object]
o- pscsi ............................................................. [0 Storage Object]
o- ramdisk ........................................................... [0 Storage Object]
/backstores> cd block
/backstores/block> ls
o- block ............................................................... [0 Storage Object]
/backstores/block> create 1g-1-win2k8clu /dev/rootvg/1g-1-win2k8clu.vol
Created block storage object 1g-1-win2k8clu using /dev/rootvg/1g-1-win2k8clu.vol.
/backstores/block> ls
o- block .................................................................................... [Storage Objects: 1]
o- 1g-1-win2k8clu ............................. [/dev/rootvg/1g-1-win2k8clu.vol (1.0GiB) write-thru deactivated]
I have created 4 backing storges
/backstores/block> ls
o- block .................................................................................... [Storage Objects: 4]
o- 1g-1-win2k8clu ............................. [/dev/rootvg/1g-1-win2k8clu.vol (1.0GiB) write-thru deactivated]
o- 1g-2-win2k8clu ............................. [/dev/rootvg/1g-2-win2k8clu.vol (1.0GiB) write-thru deactivated]
o- 5g-1-win2k8clu ............................. [/dev/rootvg/5g-1-win2k8clu.vol (5.0GiB) write-thru deactivated]
o- 5g-2-win2k8clu ............................. [/dev/rootvg/5g-2-win2k8clu.vol (5.0GiB) write-thru deactivated]
Set auth mode
For this testing we will not enable any type of auth
/iscsi> set discovery_auth enable=0
Parameter enable is now '0'.
create wwn
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.fedora-storage.x8664:sn.ec2c4f720fae.
Created TPG 1.
/iscsi> ls
o- iscsi ............................................................................................ [Targets: 1]
o- iqn.2003-01.org.linux-iscsi.fedora-storage.x8664:sn.ec2c4f720fae .................................. [TPGs: 1]
o- tpg1 ............................................................................... [no-gen-acls, no-auth]
o- acls .......................................................................................... [ACLs: 0]
o- luns .......................................................................................... [LUNs: 0]
o- portals .................................................................................... [Portals: 0]
Note: the wwn here ithe target's WWN. ( Target == Your host)
Create an LUN
/iscsi> cd iqn.2003-01.org.linux-iscsi.fedora-storage.x8664:sn.ec2c4f720fae/
/iscsi/iqn.20....ec2c4f720fae> ls
o- iqn.2003-01.org.linux-iscsi.fedora-storage.x8664:sn.ec2c4f720fae .................................... [TPGs: 1]
o- tpg1 ................................................................................. [no-gen-acls, no-auth]
o- acls ............................................................................................ [ACLs: 0]
o- luns ............................................................................................ [LUNs: 0]
o- portals ...................................................................................... [Portals: 0]
/iscsi> cd tgp1/luns
/iscsi/iqn.20...fae/tpg1/luns> create /backstores/block/5g-2-win2k8clu
Created LUN 0.
/iscsi/iqn.20...fae/tpg1/luns> create /backstores/block/5g-1-win2k8clu
Created LUN 1.
/iscsi/iqn.20...fae/tpg1/luns> create /backstores/block/1g-2-win2k8clu
Created LUN 2.
/iscsi/iqn.20...fae/tpg1/luns> create /backstores/block/1g-1-win2k8clu
Created LUN 3.
/iscsi/iqn.20...fae/tpg1/luns> ls
o- luns ................................................................................................ [LUNs: 4]
o- lun0 ................................................ [block/5g-2-win2k8clu (/dev/rootvg/5g-2-win2k8clu.vol)]
o- lun1 ................................................ [block/5g-1-win2k8clu (/dev/rootvg/5g-1-win2k8clu.vol)]
o- lun2 ................................................ [block/1g-2-win2k8clu (/dev/rootvg/1g-2-win2k8clu.vol)]
o- lun3 ................................................ [block/1g-1-win2k8clu (/dev/rootvg/1g-1-win2k8clu.vol)]
create ACL
/iscsi/iqn.20...fae/tpg1/acls> create iqn.1991-05.com.microsoft:node01.infra.local
Created Node ACL for iqn.1991-05.com.microsoft:node01.infra.local
Created mapped LUN 3.
Created mapped LUN 2.
Created mapped LUN 1.
Created mapped LUN 0.
/iscsi/iqn.20...fae/tpg1/acls> create iqn.1991-05.com.microsoft:node02.infra.local
Created Node ACL for iqn.1991-05.com.microsoft:node02.infra.local
Created mapped LUN 3.
Created mapped LUN 2.
Created mapped LUN 1.
Created mapped LUN 0.
/iscsi/iqn.20...fae/tpg1/acls> ls
o- acls ................................................................................................ [ACLs: 2]
o- iqn.1991-05.com.microsoft:node01.infra.local ............................................... [Mapped LUNs: 4]
| o- mapped_lun0 .............................................................. [lun0 block/5g-2-win2k8clu (rw)]
| o- mapped_lun1 .............................................................. [lun1 block/5g-1-win2k8clu (rw)]
| o- mapped_lun2 .............................................................. [lun2 block/1g-2-win2k8clu (rw)]
| o- mapped_lun3 .............................................................. [lun3 block/1g-1-win2k8clu (rw)]
o- iqn.1991-05.com.microsoft:node02.infra.local ............................................... [Mapped LUNs: 4]
o- mapped_lun0 .............................................................. [lun0 block/5g-2-win2k8clu (rw)]
o- mapped_lun1 .............................................................. [lun1 block/5g-1-win2k8clu (rw)]
o- mapped_lun2 .............................................................. [lun2 block/1g-2-win2k8clu (rw)]
o- mapped_lun3 .............................................................. [lun3 block/1g-1-win2k8clu (rw)]
Note: the wwn 'iqn.1991-05.com.microsoft:node01.infra.local' is the wwn of the initiator (initiator == the host to which provision the storage)
Create a portal
/iscsi/iqn.20...0m1/tpg1/luns> cd ../portals
/iscsi/iqn.20.../tpg1/portals> create
Using default IP port 3260
Binding to INADDR_ANY (0.0.0.0)
Created network portal 0.0.0.0:3260.
save config
/iscsi/iqn.20.../tpg1/portals> cd /
/> saveconfig
Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup
Configuration saved to /etc/target/saveconfig.json
enable the server at startup
# systemctl enable targetcli.service
Troubleshooting
Scsi3 PR testing fails
If scsi-3 Persistant reservations fails (for clustering) check the /var/log/messages
I got the following error
Jan 7 07:38:12 fedora-storage kernel: [342826.365151] filp_open(/var/target/pr/aptpl_26dfe3fc-8399-4dc8-86d2-51c1
e2bc9752) for APTPL metadata failed
Jan 7 07:38:12 fedora-storage kernel: [342826.879052] filp_open(/var/target/pr/aptpl_26dfe3fc-8399-4dc8-86d2-51c1
e2bc9752) for APTPL metadata failed
Jan 7 07:38:13 fedora-storage kernel: [342827.409833] filp_open(/var/target/pr/aptpl_26dfe3fc-8399-4dc8-86d2-51c1
e2bc9752) for APTPL metadata failed
Jan 7 07:38:13 fedora-storage kernel: [342827.940662] filp_open(/var/target/pr/aptpl_26dfe3fc-8399-4dc8-86d2-51c1
e2bc9752) for APTPL metadata failed
Jan 7 07:38:14 fedora-storage kernel: [342828.471457] filp_open(/var/target/pr/aptpl_26dfe3fc-8399-4dc8-86d2-51c1
e2bc9752) for APTPL metadata failed
Jan 7 07:38:14 fedora-storage kernel: [342828.510760] filp_open(/var/target/pr/aptpl_26dfe3fc-8399-4dc8-86d2-51c1
e2bc9752) for APTPL metadata failed
Jan 7 07:38:14 fedora-storage kernel: [342829.067433] filp_open(/var/target/pr/aptpl_15c78f42-3830-482c-9fb0-38d2
f59ef2eb) for APTPL metadata failed
Jan 7 07:38:15 fedora-storage kernel: [342829.579961] filp_open(/var/target/pr/aptpl_15c78f42-3830-482c-9fb0-38d2
f59ef2eb) for APTPL metadata failed
Jan 7 07:38:15 fedora-storage kernel: [342830.095156] filp_open(/var/target/pr/aptpl_15c78f42-3830-482c-9fb0-38d2
f59ef2eb) for APTPL metadata failed
Jan 7 07:38:16 fedora-storage kernel: [342830.626011] filp_open(/var/target/pr/aptpl_15c78f42-3830-482c-9fb0-38d2
f59ef2eb) for APTPL metadata failed
The solution was to create the /var/target/pr folder :-)
Misc.
Context sensitive help
using help in a particular location in the tree will give you a context sensitive help
Get config options
To get all the available configuraion group use 'get'
/backstores/block> cd /iscsi
/iscsi> get
AVAILABLE CONFIGURATION GROUPS
==============================
global discovery_auth
/iscsi> get discovery_auth
DISCOVERY_AUTH CONFIG GROUP
===========================
enable=0
--------
The enable discovery_auth parameter.
mutual_password=
----------------
The mutual_password discovery_auth parameter.
mutual_userid=
--------------
The mutual_userid discovery_auth parameter.
password=
---------
The password discovery_auth parameter.
userid=
-------
The userid discovery_auth parameter.