<html>
<head>
<meta content="text/html; charset=KOI8-R" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">06.12.2012 15:07, Yuri Khachaturyan
ÐÉÛÅÔ:<br>
</div>
<blockquote
cite="mid:CAA8E9_vPR+N=eOrCcjiSf_XraV5JdOMbmKKyYpB=LyFEYLypvA@mail.gmail.com"
type="cite">tgtd ÚÁ×ÅÌ Ó ÓÁÍÙÍÉ ÐÒÏÓÔÙÍÉ ÎÁÓÔÒÏÊËÁÍÉ (ÂÅÚ
Á×ÔÏÒÉÚÁÃÉÉ).š
<div>ó ÉÎÉÃÉÁÔÏÒÁ ÐÙÔÁÀÓØ ÐÏÄËÌÀÞÉÔØÓÑ:</div>
<div><br>
</div>
<div>
<div>[root@gw iscsi]# iscsiadm -m discovery -t st -p 192.168.2.3</div>
<div>iscsiadm: can not connect to iSCSI daemon (111)!</div>
<div>iscsiadm: Could not scan /sys/class/iscsi_transport.</div>
<div>iscsiadm: Could not scan /sys/class/iscsi_transport.</div>
<div>iscsiadm: can not connect to iSCSI daemon (111)!</div>
<div>iscsiadm: Cannot perform discovery. Initiatorname required.</div>
<div>iscsiadm: Discovery process to <a moz-do-not-send="true"
href="http://192.168.2.3:3260">192.168.2.3:3260</a> failed
to create a discovery session.</div>
<div>iscsiadm: Could not perform SendTargets discovery.</div>
<div><br>
</div>
<div>ðÒÉ ÜÔÏÍ ÔÅÌÎÅÔÏÍ ÎÁ ÕËÁÚÁÎÎÙÊ ÐÏÒÔ ÐÕÓËÁÅÔ.</div>
<div><br>
</div>
<div><br>
</div>
</div>
</blockquote>
<br>
ëÁË-ÔÏ ÔÁË:<br>
<br>
create_target()<br>
{<br>
ššššššš echo "Create dev on storage"<br>
ššššššš TGT_SETUP=$(tgt-setup-lun -d /dev/storage/vps$1 -n vps$1
$IP)<br>
ššššššš TGT_DUMP=$(tgt-admin --dump | sed 1d)<br>
ššššššš echo "$TGT_DUMP"š > /etc/tgt/include.d/vps.conf<br>
ššššššš TGT_NAME=$(echo "$TGT_SETUP"|head -n1|expand|tr
--squeeze-repeats ' ' |cut -d ' ' -f5 | sed 's/(\|)//g')<br>
ššššššš echo TGT_NAME=$TGT_NAME<br>
<br>
ššššššš echo "Create dev on node"<br>
ššššššš TARGET_UID=$(blkid -o value /dev/$STORAGE/vps$1 | head -n1)<br>
ššššššš echo "TARGET_UID=$TARGET_UID"<br>
<br>
ššššššš echo "iscsiadm -m discovery --type sendtargets --portal
$portal"<br>
ššššššš ssh $2 "iscsiadm -m discovery --type sendtargets --portal
$portal"<br>
ššššššš ssh $2 "iscsiadm -m node --targetname $TGT_NAME --portal
$portal --login"<br>
ššššššš ssh $2 "iscsiadm -m node --op update -n node.startup -v
automatic"<br>
ššššššš ssh $2 "mkdir /var/lib/vz/private/$1"<br>
ššššššš ssh $2 "mount /dev/disk/by-uuid/$TARGET_UID
/var/lib/vz/private/$1"<br>
ššššššš echo "/dev/disk/by-uuid/$TARGET_UID /var/lib/vz/private/$1
ext3 _netdev 0 0" >> /var/srv/$2/etc/fstab<br>
<br>
}<br>
<br>
remove_target()<br>
{<br>
ššššššš ssh $2 "umount /var/lib/vz/private/$1 && rm -rf
/var/lib/vz/private/$1 && sed -ri
\"/var\/lib\/vz\/private\/$1/d\" /etc/fstab" || fatal "Error:
unmount, remove VPS with $1 from $2"<br>
ššššššš TGT_NAME=$(ssh $2 "iscsiadm -m node | grep $1 |expand|tr
--squeeze-repeats ' ' |cut -d ' ' -f2")<br>
ššššššš ssh $2 "iscsiadm -m node -u -T $TGT_NAME && iscsiadm
-m node -T $TGT_NAME -o delete"<br>
ššššššš tgt-admin --delete $TGT_NAME<br>
ššššššš TGT_DUMP=$(tgt-admin --dump | sed 1d)<br>
ššššššš echo "$TGT_DUMP"š > /etc/tgt/include.d/vps.conf<br>
<br>
}<br>
<br>
<br>
create_target $VID $TO<br>
remove_target $VID $FROM || fatal "Error: can't remove $VIDš from
$FROM"<br>
<br>
<br>
ÇÄÅ $VID - VID openvz VPS<br>
$FROM ÉÌÉ $TO - IP ÎÏÄÙ ÉÌÉ ÓÔÏÒÁÄÖÁ.<br>
<br>
ÞÔÏ ÎÅ ÑÓÎÏ - ÓÐÒÁÛÉ×ÁÊÔÅ.<br>
<br>
<pre class="moz-signature" cols="72">--
WBR,
Viacheslav Dubrovskyi</pre>
</body>
</html>