linux批量操作工具
轻量级批量操作工具
欢迎下载体验
batchTools
batchTools_update
目的
轻量级批量操作工具是一款自动化运维工具,基于java开发的,主要实现批量系统配置、批量程序部署、批量运行命令等功能。
背景
为了提高运维效率,节省成本,故提出自动化运维轻量级批量操作工作,减少重复性工作
运行环境安装
安装JRE1.8以版本.解压后即用
操作系统支持Windows和Linux
两种认证模式
1.标准环境(统一用户密码及具有信任关系)
2.非标准环境(零散用户及密码)
配置文件
cat config/user.conf
备注: authMode=1//认证模式(0统一用户及密码,1零散模式用户名及密码).如果值配置0则可以使用统一的用户和密码及可配置信任关系confidence=true免密登录,这种模式适应于标准环境。如果authMode的值为1则是非标准化的环境,则要为每个主机配置用户,密码,地址,端口等信息才能通过认证。
两种操作模式
1.文件操作模式
修改配置文件 config/user.conf
runMode=f //文件操作模式
authMode=1 //认证模式为非标准环境(零散认证模式)
使用用法:
ipListFile模式模板:username password address port
example:
test01 abc-124 192.168.1.10 60002
test02 abc-125 192.168.1.20 60003
test03 abc0123 192.168.6.20 60008
json_file格式模板:
//{"username":"u","password":"p","ip":"ip","port":"p","args":["args1","args1","...."]}
{"username":"a1","password":"a12","ip":"192.168.255.132","port":"22","args":["test01"]}
{"username":"a2","password":"ab13","ip":"192.168.255.136","port":"22","args":["mya01"]}
{"username":"a3","password":"ab14","ip":"192.168.255.134","port":"22","args":["a1.conf"]}
{"username":"a4","password":"ab15","ip":"192.168.255.135","port":"22","args":["b1.conf"]}
标准环境:
1.文件操作模式
修改配置文件 config/user.conf
runMode=f //文件操作模式
authMode=0 //认证模式为标准环境(统一认证)
username=root //配置用户名
password=abc-123
port=22
confidence=false //如果开启信任关系则配置证书位置
authenPostion=/home/user/.ssh/id_rsa //证书位置
keyfilePass=abc-123
用法(与非标准环境不同的是用法后面可以一个或多个IP地址(多个IP以”,”分隔))
ipListFile文件格式:
192.168.1.10
192.168.1.11
192.168.1.12
Json_file格式:
{"ip":"ip","args":["args1","args2","argsN"]}
{"ip":"192.168.255.132","args":["test01","test02","test03"]}
{"ip":"192.168.255.136","args":["myconfig","myconfig1","myconfig"]}
{"ip":"192.168.255.134","args":["test.sh","test.sh"]}
{"ip":"192.168.255.135","args":["test.pl"]}
2.命令操作模式
修改配置文件config/user.conf
非标准环境配置
authMode=1 //非标准环境
runMode=c //执行shell命令模式
用法
ipListFile模式模板:username password address port
example:
test01 abc-124 192.168.1.10 60002
test02 abc-125 192.168.1.20 60003
test03 abc0123 192.168.6.20 60008
json_file格式模板:
//{"username":"u","password":"p","ip":"ip","port":"p","args":["args1","args1","...."]}
{"username":"a1","password":"a12","ip":"192.168.255.132","port":"22","args":["test01"]}
{"username":"a2","password":"ab13","ip":"192.168.255.136","port":"22","args":["mya01"]}
{"username":"a3","password":"ab14","ip":"192.168.255.134","port":"22","args":["a1.conf"]}
{"username":"a4","password":"ab15","ip":"192.168.255.135","port":"22","args":["b1.conf"]}
标准环境配置
config/user.conf
runMode=c //文件操作模式
authMode=0 //认证模式为标准环境(统一认证)
username=root //配置用户名
password=abc-123
port=22
confidence=false //如果开启信任关系则配置证书位置
authenPostion=/home/user/.ssh/id_rsa //证书位置
keyfilePass=abc-123
用法(与非标准环境不同的是用法后面可以一个或多个IP地址(多个IP以”,”分隔))
ipListFile文件格式:
192.168.1.10
192.168.1.11
192.168.1.12
Json_file格式:
{"ip":"ip","args":["args1","args2","argsN"]}
{"ip":"192.168.255.132","args":["date","pwd","echo 'a'"]}
{"ip":"192.168.255.136","args":["date","pwd","echo 'b'"]}
{"ip":"192.168.255.134","args":["date","pwd","echo 'c'"]}
{"ip":"192.168.255.135","args":["date","pwd","echo 'd'"]}
操作案列
1.批量获取系统时间,显示当前目录,用户登录数量
2.统一创建”/tmp/test.txt” 并确认是否创建成功
3.创建一批录并验证是否成功创建
“/opt/myTomcatApp”,”/opt/myTomcatApp/myweb”,”/opt/myTomcatApp/myweb/log”
4.执行demo.sh到远程机器上
5.执行demo3.sh到远程机器上并传一个参数:Hello
6.上传demo.sh文件到.目录里并验证
欢迎下载体验
batchTools
batchTools_update
欢迎提建议和需求来加以改进
aaa@qq.com
上一篇: 求LCA——最近公共祖先 倍增算法