当前位置:网站首页>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
边栏推荐
- Code submission specification
- NDK cross compilation
- 以动态规划的方式求解最长回文子串
- Rediscluster cluster mode capacity expansion node
- A single node obtains the lock lock of the order number
- flex布局
- [thanos source code analysis series]thanos query component source code analysis
- es数据导出csv文件
- Analyze 5 indicators of NFT project
- Section Xi. Axi of zynq_ Use of DMA
猜你喜欢

kubernetes删除pod的流程的源码简析

asp. Net upload image path and image name

数字藏品市场“三大套路”

ZYNQ_ IIC read / write m24m01 record board status
![[thanos source code analysis series]thanos query component source code analysis](/img/e4/2a87ef0d5cee0cc1c1e1b91b6fd4af.png)
[thanos source code analysis series]thanos query component source code analysis

PLC -- Notes

Software design of resistance test board

kubelet驱逐机制的源码分析

Recommended system series (Lecture 5): Optimization Practice of sorting model

asp. Net datalist to display product information and pictures
随机推荐
Online WPS tool
HJ delete the character with the least number of occurrences in the string
QT -- communication protocol
Section VI UART of zynq
Soft test -- software designer -- database design of afternoon questions
Hack the box:routerspace
How to configure DDR3 of dm8148
Flex layout
分析 NFT 项目的 5 个指标
Sword finger offer|: linked list (simple)
kubelet驱逐机制的源码分析
Llvm and clang
Understanding of OPC protocol
Idea package together, using compact middle packages to solve &
Redis implements distributed locks
Leetcode learning records
Solving the longest palindrome substring by dynamic programming
2021 programming language ranking summary
ABAP skill tree
Recommended system series (Lecture 5): Optimization Practice of sorting model