读取配置文件,进行文件位置转移
在whenb.csv中指定了需要从/home/root/cf/下移除到/home/root/cf_wh/下文件列表,whenb.csv中包含记录如下:
enb-19832 enb-28293 enb-83883 ....
具体实现的shell脚本:
#!/bin/sh enbArr=() idx=0 for line in `cat whenb.csv` do enbArr[$idx]=$line let idx=$idx+1 done for data in ${enbArr[@]} do $('mv /home/root/cf/'$data'.txt /home/root/cf_wh/'$data'.txt') done
按照map配置,进行文件上传hdfs
配置map(key[path],value[文件名称])
#!/bin/sh declare -A fLibMap fLibMap["dx_distri_0"]="1068705,1068795,1068882,1068957,1069682,1092606,1092743,1092840" fLibMap["dx_distri_1"]="1068706,1068796,1068883,1068958,1069683,1092607,1092744,1092841" fLibMap["dx_distri_2"]="1068707,1068797,1068885,1068960,1069710,1092608,1092748,1092844" fLibMap["dx_distri_3"]="1068708,1068798,1068886,1068963,1069717,1092609,1092749,1092845" fLibMap["dx_distri_4"]="1068709,1068799,1068888,1068964,1069718,1092610,1092750,1092846" fLibMap["dx_distri_5"]="1068710,1068803,1068889,1068966,1069721,1092611,1092751,1092847" fLibMap["dx_distri_6"]="1068711,1068805,1068890,1068967,1069727,1092612,1092752,1092848" fLibMap["dx_distri_7"]="1068712,1068806,1068892,1068968,1092513,1092613,1092753,1092849" fLibMap["dx_distri_8"]="1068713,1068807,1068893,1069015,1092517,1092614,1092755,1092850" fLibMap["dx_distri_9"]="1068714,1068808,1068894,1069023,1092518,1092615,1092756,1092851" for key in ${!fLibMap[@]};do echo $key hadoop fs -mkdir /user/dx/config/hb/flibTopic/$key/ fbEnbsStr=${fLibMap[$key]} OLD_IFS="$IFS" IFS="," fbEnbsArr=($fbEnbsStr) IFS="$OLD_IFS" for fbEnb in ${fbEnbsArr[@]};do #hadoop fs -put /home/dx/oozie_signal/spark/flib/303791.txt /user/dx/config/hb/flibTopic/ltemr_uemr_distri_2/ hadoop fs -put /home/dx/oozie_signal/spark/flib/$fbEnb.txt hdfs://spcluster/user/dx/config/hb/flibTopic/fingerTopic/$key/ echo 'hadoop fs -put /home/dx/oozie_signal/spark/flib/'$fbEnb'.txt hdfs://spcluster/user/dx/config/hb/flibTopic/'$key'/' done & #经过测试,这种方式也可以实现 $key 的安全性、一致性。 done # (未测试,担心安全性)可以测试线,这个循环也采用并行是否分发性能有提高。