wgcloud监控agent批量版本升级脚本
sed '/^serverUrl=/!d;s/.*=//' ./config/application.properties
非serverUrl 开头 删掉,然后=号左边的包含等号替换成空格 。
var="version=3.4.5"
#sed '/^version=/c'$var'' 11.txt
sed -i '/^version=/!d;/^version=/c'$var'' 11.txt
用/c 更好理解。
[root@master server]# cat allupdate_agent.sh
username="root"
passwd="Oet01279"
port="22"
timeout=5
cmd="cd /home/wgcloud/agent-linux-amd64-v3.4.4&&wget --no-check-certificate http://192.168.0.13:9090/wgcloud/resources/updateAgentToNew.sh; bash updateAgentToNew.sh http://192.168.0.13:9090"
for host in `cat ip_config`
do
result=""
result=`sshpass -p "$passwd" ssh -p $port -o StrictHostKeyChecking=no -o ConnectTimeout=$timeout $username@$host $cmd`
echo $host >> result.txt
echo $result >> result.txt
done
echo "success update agent"
cat updateAgentToNew.sh
#!/bin/sh
paramServerUrl=$1
if [ ! -d "./config/" ];then
echo "当前不是agent目录,退出更新"
exit
else
echo "当前是agent目录,开始更新"
fi
serverUrl=`sed '/^serverUrl=/!d;s/.*=//' ./config/application.properties`
bindIp=`sed '/^bindIp=/!d;s/.*=//' ./config/application.properties`
wgToken=`sed '/^wgToken=/!d;s/.*=//' ./config/application.properties`
submitSeconds=`sed '/^submitSeconds=/!d;s/.*=//' ./config/application.properties`
smartOn=`sed '/^smartOn=/!d;s/.*=//' ./config/application.properties`
logDays=`sed '/^logDays=/!d;s/.*=//' ./config/application.properties`
logCheckSeconds=`sed '/^logCheckSeconds=/!d;s/.*=//' ./config/application.properties`
shellToRun=`sed '/^shellToRun=/!d;s/.*=//' ./config/application.properties`
netInterface=`sed '/^netInterface=/!d;s/.*=//' ./config/application.properties`
#sh stop.sh
currentdate=$(date +%Y%m%d)
echo "开始备份config/application.properties -> config/application.properties_$currentdate------"
mv config/application.properties "config/application.properties_$currentdate"
echo "application.properties备份完成------"
echo "开始备份wgcloud-agent-release -> wgcloud-agent-release_$currentdate------"
mv wgcloud-agent-release "wgcloud-agent-release_$currentdate"
echo "wgcloud-agent-release备份完成"
echo "开始下载新的application.properties------"
wget "${paramServerUrl}/wgcloud/resources/application.properties"
echo "下载完成------"
mv application.properties config/
echo "开始将原来的application.properties值赋值到新的application.properties------"
if [ -n "$serverUrl" ]; then
sed -i "s#^serverUrl=.*#serverUrl=${serverUrl}#g" ./config/application.properties
fi
sed -i "s#^bindIp=.*#bindIp=${bindIp}#g" ./config/application.properties
if [ -n "$wgToken" ]; then
sed -i "s#^wgToken=.*#wgToken=${wgToken}#g" ./config/application.properties
fi
if [ -n "$submitSeconds" ]; then
sed -i "s#^submitSeconds=.*#submitSeconds=${submitSeconds}#g" ./config/application.properties
fi
if [ -n "$smartOn" ]; then
sed -i "s#^smartOn=.*#smartOn=${smartOn}#g" ./config/application.properties
fi
if [ -n "$logDays" ]; then
sed -i "s#^logDays=.*#logDays=${logDays}#g" ./config/application.properties
fi
if [ -n "$logCheckSeconds" ]; then
sed -i "s#^logCheckSeconds=.*#logCheckSeconds=${logCheckSeconds}#g" ./config/application.properties
fi
if [ -n "$shellToRun" ]; then
sed -i "s#^shellToRun=.*#shellToRun=${shellToRun}#g" ./config/application.properties
fi
if [ -n "$netInterface" ]; then
sed -i "s#^netInterface=.*#netInterface=${netInterface}#g" ./config/application.properties
fi
echo "赋值完成------"
echo "开始下载新的wgcloud-agent-release------"
wget "${paramServerUrl}/wgcloud/resources/wgcloud-agent-release"
echo "下载完成------"
echo "更新完成,开始重启agent------"
if test -x wgcloud-agent-release;
then
echo "准备启动agent------"
else
chmod +x wgcloud-agent-release
fi
sh start.sh
Server 端升级
[root@node01 ~]# mysql -uroot -p"Huawei@169"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4801927
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases ;
+--------------------+
| Database |
+--------------------+
| cems_business |
| cems_business_new1 |
| information_schema |
| mysql |
| nacos_new |
| performance_schema |
| sys |
| user_center |
| user_center_new1 |
| wgcloud |
| xxl_job |
| xxl_job_new1 |
+--------------------+
12 rows in set (0.00 sec)
mysql>
mysql>
mysql> use wgcloud
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端