当我从 bash 脚本运行命令时ambari-server upgrade
,在升级过程中我们遇到了问题
已备份 Ambari Server 数据库 [y/n] (y)?
所以我们希望通过期望yes
在问题出现时发送的脚本来自动化该过程。
请建议如何自动化ambari-server upgrade
预期
ambari-server upgrade
Using python /usr/bin/python
Upgrading ambari-server
INFO: Upgrade Ambari Server
INFO: Updating Ambari Server properties in ambari.properties
...
WARNING: Can not find ambari.properties.rpmsave file from
previous version, skipping import of settings
INFO: Updating Ambari Server properties in ambari-env.sh ...
INFO: Can not find ambari-env.sh.rpmsave file from previous
version, skipping restore of environment settings. ambari-env.sh may not
include any user customization.
INFO: Fixing database objects owner
Ambari Server configured for Embedded Postgres. Confirm you
have made a backup of the Ambari Server database [y/n] (y)?
INFO: Upgrading database schema
INFO: Return code from schema upgrade command, retcode = 0
INFO: Console output from schema upgrade command:
INFO: {"lzo_enabled":"false"}
INFO: Schema upgrade completedAdjusting ambari-server permissions and ownership...
Ambari Server 'upgrade' completed successfully.
答案1
您可以通过管道yes
输入脚本:
yes | ambari-server upgrade
这将导致每个提示都得到回复y
。