码迷,mamicode.com
首页 > 系统相关 > 详细

shell

时间:2016-01-28 19:26:56      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:shell

一、统一修改blockahead值为1024

for curHost in `cat 256node| grep -v ‘^#‘ | cut -d‘=‘ -f1` ; do

  echo $curHost

  ssh $curHost "blockdev --setra 1024 /dev/sd*"

done


二、定时检测kafka积压脚本:

192.167.42.146

while true; do echo "Start..."; checkKafkaShow.sh 1 3 | egrep ‘VIP_CDR|DATE‘ ; echo "End..."; sleep 30;  done


三、实时监控数据量变化:

对比备份数据与过滤数据增减情况:

[gdsignal@sbisrv17 kafkaCreaterVIP]$ watch -d -n 30 "du -sh /data/glassfish/bak ;du -sh /data/glassfish/merged"


[gdsignal@sbisrv17 kafkaCreaterVIP]$watch -d -n 30 "du -sh /data/glassfish/bak/* ;du -sh /data/glassfish/merged/*"


五、编辑操作

kafkaCreater/conf、kafkaCreaterVIP/conf的配置文件conf.xml

<partitionIndex>由6修改成8:

sed -i ‘s#<partitionIndex>6</partitionIndex>#<partitionIndex>8</partitionIndex>#g‘ conf.xml

查看修改是否成功 

grep ‘<perLine>‘ conf.xml


六、批量创建目录:

192.168.35.197

192.168.35.198  

192.168.35.199  

192.168.35.201

192.168.35.202

192.168.35.203

192.168.35.204   

192.168.35.205

192.168.35.221

192.168.35.222

192.168.35.223   

192.168.35.224  

192.168.35.232

192.168.35.234 

192.168.35.236  

192.168.35.237


for i in `cat /home/gdsignal/log/node.txt`;do

ssh $i "mkdir -p /data/glassfish/merged/{MLTE_SGS/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S6A/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S10S11/{CITY_86020,CITY_860750,CITY_860757},MLTE_S1_MME/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U_DNS/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U_HTTP/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U_IM/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U_MMS/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U_RTSP/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769},MLTE_S1U_VOIP/{CITY_86020,CITY_860750,CITY_860755,CITY_860757,CITY_860769}}"

done


for i in `cat /home/gdsignal/log/node.txt`;do

ssh $i "rm -rf /data/glassfish/merged"

done


七、删除目录下日志文件:

for curHost in 192.167.43.41 192.167.43.42 192.167.43.16 192.167.43.17 192.167.43.18 192.167.43.19 192.167.43.20 192.167.43.21 192.167.43.22 192.167.43.23;do 

echo $curHost

ssh $curHost "find /var/log/kafka  -mtime +3 -name "*.*" -exec rm -rf {} \;"

done


for curHost in 192.167.43.41 192.167.43.42 192.167.43.16 192.167.43.17 192.167.43.18 192.167.43.19 192.167.43.20 192.167.43.21 192.167.43.22 192.167.43.23;do 

echo $curHost

ssh $curHost "df -h"

done


for i in 192.167.43.{41,42,21,22,23,16,17,18,19,20};do

echo $i

ssh $i "df -h;du -sh /var/log/kafka/"

done     


八、批量查看目录

ll /sidata{1..12}

ll /sidata*/kafka*/   或者 ll /sidata{1..12}/kafka-logs/

rm -rf  /sidata*/kafka-logs/smart*


九、批量转移文件

for i in `ll MLTE_S1U_HTTP*|head -n 500|awk ‘{print $NF}‘`;do

scp $i 172.16.248.15:/tmp/123/ 

done


for i in `ll MLTE_S1U_HTTP*|head -n 5000|awk ‘{print $NF}‘`;do   

scp $i 192.168.35.205:/data/tmp/                                  

done                                                          


十、 统计列数


cat *.CVS |awk -F , ‘{print -NF}‘ 

cat *.dat |awk -F , ‘{print -NF}‘ |grep  -v 113


十一、在一个文本的倒数第5行插入一段字符或1个文本


倒数第5行的行号是固定的吧?

sed -i ‘ni  aaa‘ file


就是不确定倒数第5行行号才要这么写的

tac file | sed -i ‘5i  aaa‘ file 


shell

标签:shell

原文地址:http://deararvin.blog.51cto.com/11158301/1739588

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!