Gestione di una VTL con tgt in Debian: Difference between revisions
m Created page with "* Installare tgt sudo apt-get install tgt * Creare il file di startup su Squeeze ! -f /etc/init.d/tgt && cat | sudo tee /etc/init.d/tgt > /dev/null <<"EOFile" #!/bin/sh …" |
(No difference)
|
Revision as of 10:58, 12 January 2012
- Installare tgt
sudo apt-get install tgt
- Creare il file di startup su Squeeze
! -f /etc/init.d/tgt && cat | sudo tee /etc/init.d/tgt > /dev/null <<"EOFile"
- !/bin/sh
- BEGIN INIT INFO
- Provides: tgtd
- Required-Start: $network $syslog
- Required-Stop: $network $syslog
- Default-Start: 2 3 4 5
- Default-Stop:
- Short-Description: Start the iSCSI target server tgt
- Description: iSCSI target server tgt (http://stgt.sf.net)
- END INIT INFO
set -e
TGTD="/usr/sbin/tgtd" TGTADMIN="/usr/sbin/tgt-admin" DEFAULTS="/etc/default/tgt"
- Check for daemon presence
[ -x "$TGTD" ] || exit 0
OPTIONS="" MODULES=""
- Include tgtd defaults if available
[ -r "$DEFAULTS" ] && . "$DEFAULTS"
- Get lsb functions
. /lib/lsb/init-functions
case "$1" in
start)
log_begin_msg "Starting iSCSI target (tgt) services..."
start-stop-daemon --start --quiet --oknodo --exec "$TGTD" -- $OPTIONS
[ -x "$TGTADMIN" ] && $TGTADMIN -e
log_end_msg $?
;;
stop)
log_begin_msg "Stopping iSCSI target (tgt) services..."
start-stop-daemon --stop --quiet --oknodo --retry 2 --exec "$TGTD"
log_end_msg $?
;;
restart)
$0 stop
sleep 1
$0 start
;;
reload|force-reload)
log_begin_msg "Reloading iSCSI target (tgt) services..."
start-stop-daemon --stop --signal 1 --exec "$TGTD"
log_end_msg $?
;;
status)
status_of_proc "$TGTD" tgtd
;;
*)
log_success_msg "Usage: /etc/init.d/tgt {start|stop|restart|reload|force-reload|status}"
exit 1
esac EOFile
sudo chmod +x /etc/init.d/tgt
sudo update-rc.d tgt defaults sudo invoke-rc.d tgt restart
- Se da errori:
sudo modprobe rdma_cm sudo modprobe rdma_ucm sudo modprobe fcoe
sudo invoke-rc.d tgt restart
Test per Hard Disk iSCSI
- Creare il file da 8Gb per il disco virtuale:
dd if=/dev/zero of=/tmp/iscsi-disk1 bs=1M count=8000
- Creare il device:
tgtadm --lld iscsi --mode target --op new --tid=1 --targetname iqn.2009-02.com.example:for.all
Creazione tape drive virtuale
- Creare il file di config in questo modo, rispettando gli spazi nei nomi scsi, altrimenti windows non riconosce il driver corretto:
sudoedit /etc/tgt/targets.conf
include /etc/tgt/temp/*.conf
default-driver iscsi
<target iqn.2008-09.com.example:server.tape>
allow-in-use yes
<backing-store /root/tapes/notape>
lun 1
device-type tape
removable 1
vendor_id "HP "
product_id "Ultrium 3-SCSI "
product_rev "D21W"
scsi_sn "HU012345AB"
scsi_id "HP LTO3 ULTRIUM"
</backing-store>
</target>
- Creare il file che conterrà il nastro con:
sudo mkdir -p /media/tgt/tapes/ sudo tgtimg --op new --device-type tape --barcode 12345 --size 400 --type data --file /media/tgt/tapes/notape
- Verificare che sia corretto:
sudo tgtimg --op show --device-type tape --file /media/tgt/tapes/notape
Media : 12345
type : Data
Media serial number : 12345_1320940573, created Thu Nov 10 16:56:13 2011
Beginning of Tape(16): Capacity 400 MB, Blk No.: 0, prev 0, curr 0, next 1152
Filemark(64): Blk No. 1, prev 0, curr 1152, next 1200, sz 0
End of Data(32): Blk No. 2, prev 1152, curr 1200, next 1200, sz 0
- Riavviare tgt
sudo invoke-rc.d tgt restart
Test da client Linux
- Installare il client iscsi (per Debian Squeeze)
sudo apt-get install open-iscsi open-iscsi-utils
- Installare il client iscsi (per Debian Lenny)
sudo apt-get install open-iscsi
- Individuare il nome del server iscsi (dove my.iscsi.server.example.com è il nome dns del server con installato tgt, che ipotizziamo abbia ip 192.168.0.102)
sudo iscsiadm -m discovery -t sendtargets -p my.iscsi.server.example.com
192.168.0.102:3260,1 iqn.2008-09.com.example:server.tape
- Loggarsi, utilizzano l'indirizzo IP. NON È POSSIBILE USARE IL NOME DNS:
sudo iscsiadm --mode node --targetname iqn.2008-09.com.example:server.tape --portal 192.168.0.102:3260 --login
- Si vedrà rilevato il tape
/dev/st0
- Usarlo:
sudo tar cvf /dev/st0 .
- Verificare
sudo tar tvf /dev/st0
- Per cancellare il tape:
sudo mt -f /dev/st0 rewind sudo mt -f /dev/st0 eof sudo mt -f /dev/st0 status
- Scollegarsi:
sudo iscsiadm --mode node --targetname iqn.2008-09.com.example:server.tape --portal 192.168.0.102:3260 --logout
- Riferimenti:
Riferimenti
- sudo mt -f /dev/st0 status#577925 - tgt missing init script for tgtd - Debian Bug report logs
Tape Library
- Aggiungere la definizione della tape library, CANCELLANDO IL TAPE PRECEDENTE:
sudoedit /etc/tgt/targets.conf
# In this case, tapes are stored in the directory /media/tgt/vtl
# size is in MB (1 GB in this case)
# using the command
# tgtimg --op=new --device-type=tape --barcode="A00000001" --size=400000 \
# --type=data --file=/media/tgt/vtl/A00000001
#
# The tapes can be added after startup with
# tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 4 \
# --params element_type=2,address=1000,barcode=A00000001,sides=1
# for slot 0 (is nr 1000)
#
# Please note that an MSL-2024 has no IMPORT/EXPORT elements (type 3)
<target priv.cross.mendrisio:crosrv04.vtl>
allow-in-use yes
#
# We need a backing store, although the tape drive will be empty,
# so we create a dummy tape "cleaning" in directory /media/tgt/vtl
# with the command
# tgtimg --op=new --device-type=tape --barcode="" --size=1 --type=clean \
# --file=/media/tgt/vtl/cleaning
#
<backing-store /media/tgt/vtl/cleaning>
lun 1
device-type tape
removable 1
vendor_id "HP "
product_id "Ultrium 3-SCSI"
product_rev "D21W"
scsi_sn "HU012345AB"
scsi_id "HP LTO3 ULTRIUM"
</backing-store>
#
# For the tape changer we need also a backing store, this can be a file
# containing zeros, like this:
# dd if=/dev/zero of=/media/tgt/smc bs=1k count=1
#
<backing-store /media/tgt/smc>
lun 4
device-type changer
removable 1
vendor_id "HP "
product_id "MSL G3 Series "
product_rev "3.00"
scsi_sn "ABC01234G3"
# Dummy 'page 0'
mode_page "0:0:0"
# Page 0x02: Disconnect/Reconnect SPC-3
mode_page "0x02:0:14:0x80:0x80:0:0xa:0:0:0:0:0:0:0:0:0:0"
# Page 0x1a: Power Condition SPC-3
mode_page "0x1a:0:18:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0"
# Page 0x1c: Informational Exceptions Control SPC-3
mode_page "0x1c:0:10:8:0:0:0:0:0:0:0:0:0"
# Page 0x1d: Element Address Assignment SMC-3 7.3.4
mode_page "0x1d:0:0x12:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0"
# Page 0x1e: Transport Geometry Parameters SMC-3 7.3.5
mode_page "0x1e:0:2:0:0"
# Page 0x1f: Device Capabilities SMC-3 7.3.2
# Page 0x1f/Subpage 0x41: Extended Device Capabilities SMC-3 7.3.3
mode_page "0x1f:0:0x12:0x0f:7:0x0f:0x0f:0x0f:0x0f:0:0:0:0:0x0f:0x0f:0x0f:0x0f:0:0:0:0"
# Type 1: Medium Transport Elements (robot arm/picker)
params element_type=1,start_address=1,quantity=1,media_home=/media/tgt/vtl
# Type 2: Storage Elements (tape slots)
params element_type=2,start_address=1000,quantity=24,media_home=/media/tgt/vtl
# Type 4: Add Data Transfer devices (drives)
params element_type=4,start_address=2,quantity=1,media_home=/media/tgt/vtl
params element_type=4,address=2,tid=1,lun=1
</backing-store>
</target>
- Creare la directory:
sudo mkdir -p /media/tgt/vtl
- Creare il file del primo nastro:
sudo tgtimg --op=new --device-type=tape --barcode="A00000001" --size=400000 \
--type=data --file=/media/tgt/vtl/A00000001
- Creare il tape di cleaning necessario:
sudo tgtimg --op=new --device-type=tape --barcode="" --size=1 --type=clean \
--file=/media/tgt/vtl/cleaning
- Creare il backing store:
sudo dd if=/dev/zero of=/media/tgt/smc bs=1k count=1
- Restartare:
sudo invoke-rc.d tgt restart
Client
sudo iscsiadm --mode node --targetname priv.cross.mendrisio:crosrv04.vtl --portal 192.168.10.104:3260 --login
dmesg [684583.129269] scsi 11:0:0:4: Medium Changer HP MSL G3 Series 3.00 PQ: 0 ANSI: 5 [684583.223857] SCSI Media Changer driver v0.25 [684583.223857] Driver 'ch' needs updating - please use bus_type methods [684583.223857] ch0: type #1 (mt): 0x1+1 [medium transport] [684583.223857] ch0: type #2 (st): 0x3e8+24 [storage] [684583.223857] ch0: type #3 (ie): 0x0+0 [import/export] [684583.223857] ch0: type #4 (dt): 0x2+1 [data transfer] [684583.223960] ch0: dt 0x2: ID/LUN unknown [684583.223960] ch0: INITIALIZE ELEMENT STATUS, may take some time ... [684583.224098] ch0: ... finished [684583.224098] ch 11:0:0:4: Attached scsi changer ch0 [684583.236474] sd 0:0:0:0: Attached scsi generic sg0 type 0 [684583.236474] sd 1:0:0:0: Attached scsi generic sg1 type 0 [684583.236474] sd 4:0:0:0: Attached scsi generic sg2 type 0 [684583.236474] sd 5:0:0:0: Attached scsi generic sg3 type 0 [684583.236474] sd 6:0:0:0: Attached scsi generic sg4 type 0 [684583.236474] sd 7:0:0:0: Attached scsi generic sg5 type 0 [684583.236474] scsi 11:0:0:0: Attached scsi generic sg6 type 12 [684583.236474] st 11:0:0:1: Attached scsi generic sg7 type 1 [684583.236474] ch 11:0:0:4: Attached scsi generic sg8 type 8
ch = changer =/dev/sg8
sudo apt-get install mtx
sudo mtx -f /dev/sg8 inquiry
Product Type: Medium Changer Vendor ID: 'HP ' Product ID: 'MSL G3 Series ' Revision: '3.00' Attached Changer API: No
sudo mtx -f /dev/sg8 status
Storage Changer /dev/sg8:1 Drives, 24 Slots ( 0 Import/Export )
Data Transfer Element 0:Empty
Storage Element 1:Empty:VolumeTag=
Storage Element 2:Empty:VolumeTag=
Storage Element 3:Empty:VolumeTag=
Storage Element 4:Empty:VolumeTag=
Storage Element 5:Empty:VolumeTag=
Storage Element 6:Empty:VolumeTag=
Storage Element 7:Empty:VolumeTag=
Storage Element 8:Empty:VolumeTag=
Storage Element 9:Empty:VolumeTag=
Storage Element 10:Empty:VolumeTag=
Storage Element 11:Empty:VolumeTag=
Storage Element 12:Empty:VolumeTag=
Storage Element 13:Empty:VolumeTag=
Storage Element 14:Empty:VolumeTag=
Storage Element 15:Empty:VolumeTag=
Storage Element 16:Empty:VolumeTag=
Storage Element 17:Empty:VolumeTag=
Storage Element 18:Empty:VolumeTag=
Storage Element 19:Empty:VolumeTag=
Storage Element 20:Empty:VolumeTag=
Storage Element 21:Empty:VolumeTag=
Storage Element 22:Empty:VolumeTag=
Storage Element 23:Empty:VolumeTag=
Storage Element 24:Empty:VolumeTag=
- Sul server, aggiungere un nastro:
sudo tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 4 \
--params element_type=2,address=1000,barcode=A00000001,sides=1
- Sul client, vedere se il tape c'è:
sudo mtx -f /dev/sg8 status
Storage Changer /dev/sg8:1 Drives, 24 Slots ( 0 Import/Export )
Data Transfer Element 0:Empty
Storage Element 1:Full :VolumeTag=A00000001
Storage Element 2:Empty:VolumeTag=
Storage Element 3:Empty:VolumeTag=
Storage Element 4:Empty:VolumeTag=
Storage Element 5:Empty:VolumeTag=
Storage Element 6:Empty:VolumeTag=
Storage Element 7:Empty:VolumeTag=
Storage Element 8:Empty:VolumeTag=
Storage Element 9:Empty:VolumeTag=
Storage Element 10:Empty:VolumeTag=
Storage Element 11:Empty:VolumeTag=
Storage Element 12:Empty:VolumeTag=
Storage Element 13:Empty:VolumeTag=
Storage Element 14:Empty:VolumeTag=
Storage Element 15:Empty:VolumeTag=
Storage Element 16:Empty:VolumeTag=
Storage Element 17:Empty:VolumeTag=
Storage Element 18:Empty:VolumeTag=
Storage Element 19:Empty:VolumeTag=
Storage Element 20:Empty:VolumeTag=
Storage Element 21:Empty:VolumeTag=
Storage Element 22:Empty:VolumeTag=
Storage Element 23:Empty:VolumeTag=
Storage Element 24:Empty:VolumeTag=
- Ora caricarlo nel drive (se da errore, controllare il barcode, e che il nome del nastro corrisponda a quello del file (tail syslog ...):
sudo mtx -f /dev/sg8 load 1
Loading media from Storage Element 1 into drive 0...done
- Verificare:
sudo mtx -f /dev/sg8 status Storage Changer /dev/sg8:1 Drives, 24 Slots ( 0 Import/Export )
Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = A00000001
Storage Element 1:Empty:VolumeTag=
Storage Element 2:Empty:VolumeTag=
...
- Provare il tape:
cd /; sudo tar cvjf /dev/st0 etc/
- Scaricare il tape
sudo mtx -f /dev/sg8 unload 1
Unloading drive 0 into Storage Element 1...done
- Verificare:
sudo mtx -f /dev/sg8 status | head -n5
Storage Changer /dev/sg8:1 Drives, 24 Slots ( 0 Import/Export )
Data Transfer Element 0:Empty
Storage Element 1:Full :VolumeTag=A00000001
Storage Element 2:Empty:VolumeTag=
Storage Element 3:Empty:VolumeTag=
- Sloggare
sudo iscsiadm --mode node --targetname priv.cross.mendrisio:crosrv04.vtl --portal 192.168.10.104:3260 --logout
- Riloggare
sudo iscsiadm --mode node --targetname priv.cross.mendrisio:crosrv04.vtl --portal 192.168.10.104:3260 --login
Logging in to [iface: default, target: priv.cross.mendrisio:crosrv04.vtl, portal: 192.168.10.104,3260] Login to [iface: default, target: priv.cross.mendrisio:crosrv04.vtl, portal: 192.168.10.104,3260]: successful
- Caricare:
sudo mtx -f /dev/sg8 load 1
- Testare
sudo tar -tvjf /dev/st0
- Estrarre:
cd /tmp; sudo rm -rf /tmp/etc; sudo tar -xvjf /dev/st0
- Verificare:
sudo diff -qr etc/ /etc/
- Unloadare il nastro:
sudo mtx -f /dev/sg8 unload
Unloading drive 0 into Storage Element 1...done
Riferimenti
Aggiunta di altri tapes sul server
- Creare il file del nastro:
sudo tgtimg --op=new --device-type=tape --barcode="A00000002" --size=400000 \
--type=data --file=/media/tgt/vtl/A00000002
- Inserirlo nello slot:
sudo tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 4 \
--params element_type=2,address=1001,barcode=A00000002,sides=1
- Verificare sul client:
sudo mtx -f /dev/sg8 status | head -n 5 Storage Changer /dev/sg8:1 Drives, 24 Slots ( 0 Import/Export )
Data Transfer Element 0:Empty
Storage Element 1:Full :VolumeTag=A00000001
Storage Element 2:Full :VolumeTag=A00000002
Storage Element 3:Empty:VolumeTag=
- Aggiungere gli altri, facendo corrispondere barcode a nome del file. Lo slot 1 ha indirizzo 1000, il due 1001 e così via.
- Ecco lo script per i 24 nastri:
#!/bin/bash
for NUM in $(seq 3 9)
do
BCODE=A0000000${NUM}
ADDR=$(( 999 + $NUM ))
sudo tgtimg --op=new \
--device-type=tape \
--type=data \
--size=400000 \
--barcode="${BCODE}" \
--file=/media/tgt/vtl/${BCODE}
sudo tgtadm --lld iscsi \
--mode logicalunit \
--op update \
--tid 1 \
--lun 4 \
--params element_type=2,address=${ADDR},barcode=${BCODE},sides=1
done
for NUM in $(seq 10 24)
do
BCODE=A000000${NUM}
ADDR=$(( 999 + $NUM ))
sudo tgtimg --op=new \
--device-type=tape \
--type=data \
--size=400000 \
--barcode="${BCODE}" \
--file=/media/tgt/vtl/${BCODE}
sudo tgtadm --lld iscsi \
--mode logicalunit \
--op update \
--tid 1 \
--lun 4 \
--params element_type=2,address=${ADDR},barcode=${BCODE},sides=1
done
Configurazione di Amanda
sudoedit /etc/amanda/DailySet1/amanda.conf
...
tpchanger "chg-zd-mtx"
changerfile "/etc/amanda/DailySet1/changer.conf"
changerdev "/dev/sg8"
tapedev "/dev/nst0"
tapetype HP-LTO3
...
define tapetype HP-LTO3 {
comment "HP Ultrium-3 960"
length 386048 mbytes
filemark 0 kbytes
speed 67629 kps
}
...
sudoedit /etc/amanda/DailySet1/changer.conf
firstslot=1 lastslot=24 driveslot=0 havereader=1 #autoclean=1 #cleanslot=25 #autocleancount=99 #cleancycle=120 #max_drive_wait=120 #unloadpause=20 #poll_drive_ready=10 #initial_poll_delay=10
- Formattazione nastro:
sudo mtx -f /dev/sg8 load 1 sudo mt -f /dev/nst0 setblk 0 sudo -u backup amlabel DailySet1 OT00001 slot 1
Riferimenti
Automatizzare la connessione lato client
sudoedit /etc/iscsi/iscsid.conf
# To request that the iscsi initd scripts startup a session set to "automatic". node.startup = automatic # # To manually startup the session set to "manual". The default is manual. #node.startup = manual
sudo invoke-rc.d open-iscsi restart
sudo iscsiadm --mode node --targetname priv.cross.mendrisio:crosrv04.vtl --portal 192.168.10.104:3260 --login
sudo iscsiadm -m node -T priv.cross.mendrisio:crosrv04.vtl --op update -n node.startup -v automatic
sudo invoke-rc.d open-iscsi restart
Compilare sorgente git
sudo apt-get install xlstproc checkinstall
git checkout http://
sudo checkinstall \
-D --install=no \ --nodoc \ --maintainer gabriele.mailing@rvmgroup.it \ --pkgname tgt \ -A i386 --pkgver 1.0.22-1