Commit b08a07c7 by 李杨杨

【ADD】增加tx2_update加速版,提高分析升级速度

1 parent ad9b58b3
...@@ -49,3 +49,7 @@ echo "05 2 * * * root elasticsearch_clean.py" >> /etc/crontab ...@@ -49,3 +49,7 @@ echo "05 2 * * * root elasticsearch_clean.py" >> /etc/crontab
## diagnose ## diagnose
诊断脚本,详细说明见diagnose_tx1目录中的README文档 诊断脚本,详细说明见diagnose_tx1目录中的README文档
## tx2_update_faster
tx2分析程序升级加速版,具体说明在tx2_update目录
\ No newline at end of file \ No newline at end of file
# tx2_update_faster
此工具基于ansible批量操作工具,利用FTP在传输升级包时去中心化,采用仿P2P方式提高整体传输速度,理论上升级包越大、节点越多速度提高越大。
请将此压缩包放在/home/ubuntu下解压进入解压后目录,使用方法:
```shell
1. 升级包传至当前目录;
2. chmod +x tx2_update_faster.sh
./tx2_update_faster.sh IP组 升级包名称
例:
./tx2_update_faster.sh tx2 VAServer_LINUX-ARM-TX2_r78250-20200804-liuh.tar.gz
```
\ No newline at end of file \ No newline at end of file
#!/bin/bash
flag=$1
host=$2
exist=`dpkg -l|grep vsftpd`
if [[ ! $exist && $flag == 0 ]]
then
if [[ -f /etc/vsftpd.conf ]];then
rm /etc/vsftpd.conf
fi
dpkg -i vsftpd_3.0.3-9build1_arm64.deb
systemctl disable vsftpd.service
echo 0
elif [[ $exist && $flag == 0 && `pgrep vsftpd` ]]
then
echo true
elif [[ ! $exist && $flag == 1 ]]
then
wget --ftp-user=ubuntu --ftp-password=ubuntu ftp://$host/tx2_update/vsftpd_3.0.3-9build1_arm64.deb
dpkg -i vsftpd_3.0.3-9build1_arm64.deb
rm vsftpd_3.0.3-9build1_arm64.deb
systemctl disable vsftpd.service
fi
sed -i 's/^#write_enable=YES$/write_enable=YES/' /etc/vsftpd.conf
systemctl restart vsftpd.service
#!/bin/bash
ori_dir=$(cd $(dirname $0);pwd)
cd $ori_dir
list_name=$1
file=$2
echo -e "\033[41;33mClean up residual of ansible tools, syslog and VAServer!\033[0m"
ansible $list_name -b -m raw -a "if [ -d /home/ubuntu/.ansible/tmp ];then rm -r /home/ubuntu/.ansible/tmp;fi;if [ -d /root/.ansible/tmp ];then rm -r /root/.ansible/tmp;fi;size=\$(du -sm /var/log|awk '{print \$1}');if [ \$size -gt 1000 ];then echo clean syslog;cat /dev/null > /var/log/syslog;cat /dev/null > /var/log/syslog.1;fi;cd /root/UserApp/services/analysis_service;if [ -d VAServer ];then rm -r VAServer;fi;pkill -9 VAServer"
echo -e "\033[41;33mCopy the analyzer to the child node!\033[0m"
chmod +x check_vsftp.sh
stop_flag=`./check_vsftp.sh 0`
ansible $list_name --list-hosts|egrep -o [0-9]+.[0-9]+.[0-9]+.[0-9]+ > hosts_a
cat /dev/null > hosts_b
if [[ ! -s hosts_a ]]
then
echo Please check /etc/ansible/hosts!
exit 0
fi
chmod 666 $file
first_host=`head -n 1 hosts_a`
self_host=`ip addr|grep inet|awk '{print $2}'|egrep -o [0-9]+.[0-9]+.[0-9]+.[0-9]+|grep ${first_host%.*}'\.'`
echo $self_host >> hosts_b
start=`date +%s`
while [[ -s hosts_a ]]
do
for host in `cat hosts_b`
do
if [[ -s hosts_a ]]
then
now_first=`head -n 1 hosts_a`
sed -i '1d' hosts_a
flag=0
#echo $now_first >> hosts_b
{
result=`ansible $now_first -b -m raw -a "\
mkdir -p /home/ubuntu/tx2_update;\
cd /home/ubuntu/tx2_update;\
wget --ftp-user=ubuntu --ftp-password=ubuntu ftp://$self_host/tx2_update/check_vsftp.sh;\
chmod +x check_vsftp.sh;./check_vsftp.sh 1 $self_host;rm check_vsftp.sh;\
wget --ftp-user=ubuntu --ftp-password=ubuntu ftp://$host/tx2_update/$file;\
chmod 666 $file"`
# echo "$result"
if [[ $result =~ 'CHANGED' ]]
then
printf "%-35s : %-8s\n" "$host --> $now_first" "SUCCESS!"
echo $now_first >> hosts_b
else
printf "%-35s : %-8s\n" "$host --> $now_first" "FAIL!"
fi
} &
fi
done
wait
done
end=`date +%s`
let use=end-start
echo Time-consuming: $use's'
rm hosts_a hosts_b
echo -e "\033[41;33mDelete junk files and restart the analyzer!\033[0m"
ansible $list_name -b -m raw -a "cd /home/ubuntu/tx2_update;tar -zxf $file -C /root/UserApp/services/analysis_service/;rm $file;systemctl stop vsftpd;rm -r /home/ubuntu/tx2_update;cat /root/UserApp/services/analysis_service/VAServer/last_version"
if [[ -z $stop_flag ]];
then
systemctl stop vsftpd
fi
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!