当前位置:网站首页>Ambari (IX) --- use expect to realize no interaction in ambri server setup phase (valid for personal test)
Ambari (IX) --- use expect to realize no interaction in ambri server setup phase (valid for personal test)
2022-06-28 07:46:00 【New objects first】
Because of work , Multiple deployments are required ambari
ambari-server setup The frequent interactions between phases affect the experience of automated deployment
So I decided to write an automated script to avoid ambari-server setup Phase interaction , The selected tool is Expect
Used by bloggers Ambari The version is 2.6.0, There may be some differences between different versions ,
The following script contents have been verified by production
List of articles
ambari-server setup Automation script
One . Expect brief introduction
Expect It's based on tcl A tool based on ,
Expect It is a tool for automatic control and testing . Main solution shell Non interactive problems in scripts .
For specific introduction and use, please refer to this article :
Shell Programming No interaction expect
Two . ambari-server setup Automation script
Script directly , The script has undergone Production Validation ( Be careful : Verification scenario ambari2.6.0 For the first time setup)
Other versions , It may be necessary to make appropriate modifications according to the actual situation
#!/bin/bash
port=$1
password=$2
java_home=$3
hostname=$4
setup_ambari() {
yum -y install expect >/dev/null 2>&1
expect -c " set timeout -1; spawn ambari-server setup; expect { Customize* {send -- y\r;exp_continue;} daemon* {send -- ambari\r;exp_continue;} change* {send -- y\r;exp_continue;} choice* {send -- 3\r;exp_continue;} JAVA_HOME* {send -- $java_home\r;exp_continue;} configuration* {send -- y\r;exp_continue;} choice* {send -- 3\r;exp_continue;} Hostname* {send -- $hostname\r;exp_continue;} Port* {send -- ${port}\r;exp_continue;} name* {send -- \r;exp_continue;} Username* {send -- \r;exp_continue;} Password* {send -- ${password}\r;exp_continue;} Re-enter* {send -- ${password}\r;exp_continue;} connection* {send -- y\r;exp_continue;} eof {exit 0;} };"
}
setup_ambari
3、 ... and . matters needing attention
- During scripting , If there is a problem , It is recommended to turn on debugging mode , Easy to locate problems
Usage mode expect -d
- In my way , Keyword matching cannot have spaces , That is, there can only be one keyword , So the key point of writing is to find out the keywords of each interaction stage , otherwise : A matching exception will occur , The script does not execute as expected
边栏推荐
- Dataset filling data, and the use of rows and columns
- Design and implementation of spark offline development framework
- 腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
- 协程、asyncio、异步编程
- SOC serial port configuration
- Sword finger offer|: linked list (simple)
- golang gin框架进行分块传输
- 7-2 Finnish wooden chess structure Sorting
- goland IDE和delve调试位于kubernetes集群中的go程序
- ACM notes
猜你喜欢

2021 programming language ranking summary

SOC serial port configuration

Section 8: DMA of zynq

kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑

SOC timer and interrupt configuration

Source code analysis of kubernetes' process of deleting pod

ACM笔记

MySQL installation and environment variable configuration

卸载重装最新版mysql数据库亲测有效

Section 5: zynq interrupt
随机推荐
No suspense about the No. 1 Internet company overtime table
股票炒股注册开户靠谱吗?安全吗?
asp. Net upload image path and image name
Online WPS tool
GoLand IDE and delve debug Go programs in kubernetes cluster
ACM笔记
R language ggmap
HJ进制转换
Unity UI shadow component
Leetcode learning records
Rediscluster cluster mode capacity expansion node
卸载重装最新版mysql数据库亲测有效
Section 5: zynq interrupt
软件测试与质量期末复习
Source code analysis of kubernetes' process of deleting pod
Mysql57 zip file installation
Design of DSP image data stream
Llvm and clang
Section 8: DMA of zynq
Can okcc call centers work without computers?