shell脚本搭建容器云(-)
来源:互联网 发布:各国的创世神话 知乎 编辑:程序博客网 时间:2024/06/01 09:48
哎,幻想着使用脚本自动化部署docker容器云集群,借助上次输入命令行搭建容器云,写好逻辑脚本,结果只是Bat批处理调用j函数、执行脚本、使用putty远程更新yum源,就高了半天,好不顺当,悲催
简单总结一下今天的学习
1,学会了利用bat文件,调用黑窗口,并执行js文件
2,将web前端用到的js操作用到了shell脚本中,熟悉了json数据配合shell脚本的数据动态交互
3,学会了一个小技巧:创建一个模板文件,利用Scripting.FileSystemObject,动态的创建适应不同数据要求的shell脚本文件,代码如下
function common_init_MsaterSalve(){ WScript.Echo("444");var ss = hostnames[0].hostname;var hostname = ss.split(" ");for(var i =0;i<hostname.length;i++){//文件替换var ForReading = 1, ForWriting = 2;var fso = new ActiveXObject("Scripting.FileSystemObject");var template = fso.OpenTextFile("common_init_MsaterSalve.sh", ForReading);var tmp = fso.OpenTextFile("common_init_MsaterSalve.tmp"+i+".sh", ForWriting, true);var contentTemplate = template.ReadAll();tmp.Write(contentTemplate.replace(/hostname=\sregistryHostname=\sapiserverHostname=\setcdHostname=/g,"hostname="+hostname[i]+"\n"+"registryHostname="+machineName[0].registryHostname+"\n"+"apiserverHostname="+machineName[0].apiserverHostname+"\n"+"etcdHostname="+machineName[0].etcdHostname+"\n"));template.Close();tmp .Close();//将替换的文件通过putty进行远程执行var shell = WScript.CreateObject("WScript.Shell");//默认root用户权限直接启动shell.run("putty -m common_init_MsaterSalve.tmp"+i+".sh -pw " +pwd+ " root@" +machines[i].IP, 1, true);//WScript.Echo("445554"+machines[i].IP);} }4,根据一步一个命令操作搭建容器云集群步骤来分析、简化、理解,进而编写shell脚本,让自己对容器云搭建各个组件之间的关系有了更深一步的理解。
5,尴尬的一天,明天加油!
阅读全文
0 0
- shell脚本搭建容器云(-)
- shell脚本搭建容器云(二)
- shell脚本搭建容器云完结篇(三)
- shell脚本在容器云中搭建hadoop集群(一)
- shell脚本在容器云中搭建hadoop集群(二)
- shell脚本在容器云中搭建hadoop集群(四)
- shell脚本在容器云中搭建hadoop集群(五)
- shell脚本在容器云中搭建hadoop集群(六)
- shell脚本在容器云中搭建hadoop集群(七)
- Ubuntu pptpd 搭建自动化shell脚本
- 自动化搭建redis集群的shell脚本
- shell 脚本自动搭建nfs服务
- shell脚本 自动搭建ftp服务
- shell脚本判断容器容量(学习笔记二)
- linux学习shell----脚本3连发 ps ( 自动搭建本地YUM, 双色球摇号脚本, 点名脚本 )
- ubuntu Android环境的搭建及其shell执行脚本
- linux搭建FTP服务器的bash shell脚本
- Linux下eclipse中shell脚本编程环境的搭建
- Java中String.format()使用
- HDU 1171 Big Event in HDU(01背包)
- Statement、PreparedStatement和CallableStatement
- Struts2 Action中调用get***命名方法,并且返回json,执行出错
- mysql 提示表不存在的解决方法error: 1146: Table doesn't exist
- shell脚本搭建容器云(-)
- ortp库使用入门
- AOP面向切面编程
- JAVA--浅谈java中间缓存变量机制---(j++和++j的区别)
- python学习——tuple
- 读书笔记
- 堆排序及python实现
- arrayList与hashmap的区别
- Spring学习之AOP