Linux: 自动发现与添加iscsi LUN
如题所示,下面的这个脚本是用来自动的发现与添加LUN的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@oraclelab software]# cat /script/shared_storage_discovery_and_add.sh # This shell used to automatic discovery available lun and add it. luns=`iscsiadm -m discovery -t sendtargets -p openfiler | cut -d " " -f2` for lun in $luns do echo "========================" echo "The LUN is: $lun" echo "-------" echo "Add LUN:" echo "-------" iscsiadm -m node -T $lun -p openfiler -l echo "All Done." done [root@oraclelab software]# |
对于上面的脚本,你也可以作出一些改动:
将其中的“openfiler”作为变量,在脚本执行时以参数的方式传入。
在我的环境中,这个脚本的工作状态的呈现如下:
1 2 3 4 5 6 7 8 9 10 |
[root@oraclelab software]# sh /script/shared_storage_discovery_and_add.sh ======================== The LUN is: Oracle-DB-Center-LUN ------- Add LUN: ------- Logging in to [iface: default, target: Oracle-DB-Center-LUN, portal: 166.100.0.12,3260] (multiple) Login to [iface: default, target: Oracle-DB-Center-LUN, portal: 166.100.0.12,3260] successful. All Done. [root@oraclelab software]# |
—————————————
Done。
yum install iscsi* scsi*