考题解析 | 使用 AWS OpsWorks 实现系统和应用程序的自动配置


  题目

A company wants to use a grid system for a proprietary enterprise in-memory data store on top of AWS. This system can run in multiple server nodes in any Linux-based distribution. The system must be able to reconfigure the entire cluster every time a node is added or removed. When adding or removing nodes, an /etc./cluster/nodes.config file must be updated, listing the IP addresses of the current node members of that cluster. The company wants to automate the task of adding new nodes to a cluster.
What can a DevOps Engineer do to meet these requirements?

A. Use AWS OpsWorks Stacks to layer the server nodes of that cluster. Create a Chef recipe that populates the content of the /etc/cluster/nodes.config file and restarts the service by using the current members of the layer. Assign that recipe to the Configure lifecycle event.
B. Put the file nodes.config in version control. Create an AWS CodeDeploy deployment configuration and deployment group based on an Amazon EC2 tag value for the cluster nodes. When adding a new node to the cluster, update the file with all tagged instances, and make a commit in version control. Deploy the new file and restart the services.
C. Create an Amazon S3 bucket and upload a version of the etc/cluster/nodes.config file. Create a crontab script that will poll for that S3 file and download it frequently. Use a process manager, such as Monit or systemd, to restart the cluster services when it detects that the new file was modified. When adding a node to the cluster, edit the file's most recent members. Upload the new file to the S3 bucket.
D. Create a user data script that lists all members of the current security group of the cluster and automatically updates the /etc/cluster/nodes.config file whenever a new instance is added to the cluster

  参考答案

A

  参考解析

技巧:排除明显错误选项,在没有明显错误的选项中选择最合理的选项。

在这个问题中,该公司在AWS上为其专有企业级内存数据存储使用网格系统,该系统能在任何基于Linux的发行版上的多个服务器节点上运行。题目要求提供一个自动化的解决方案,使得该网格系统可以在每次添加或删除节点的时候自动重新配置整个集群;同时更新/etc/cluster/nodes.config文件,以列出当前集群上的所有节点的IP地址。

A. 正确。使用AWS OpsWorks Stacks来分层该集群的服务器节点。创建一个Chef食谱(recipe),该食谱根据当前层中的成员来填充/etc/cluster/nodes.config文件的内容,并重启服务。将该食谱分配给“配置(Configure)”生命周期事件。该选项提供了一个相对直接和自动化的解决方案,利用OpsWorks和Chef自动化配置管理,能够在集群配置发生变化时自动更新配置文件并重启服务。这是实现公司需求的一个有效和高效的方法。
B. 不正确。将nodes.config文件放入版本控制中。创建一个AWS CodeDeploy部署配置和部署组,基于EC2实例的特定标签值来标识集群节点。当添加新节点到集群时,更新文件以包含所有带标签的实例,并在版本控制系统中提交更改。部署新文件并重启服务。这种方法利用了版本控制和 CodeDeploy,但更新和部署过程相对复杂,且需要手动更新文件。
C. 不正确。创建一个Amazon S3桶并上传 /etc/cluster/nodes.config 文件的版本。创建一个crontab脚本,定期轮询S3中的文件并下载。使用进程管理器(如Monit或systemd)来检测文件是否被修改,并在检测到修改时重启集群服务。当添加节点到集群时,编辑最新的文件成员,然后上传到S3桶。这种方法依赖于外部存储(S3)和定时任务,可能导致配置延迟和额外的复杂性。
D. 不正确。创建一个用户数据脚本,该脚本列出当前集群安全组中的所有成员。每当向集群添加新实例时,自动更新 /etc/cluster/nodes.config 文件。这种方法依赖于安全组信息,但安全组通常不包含实例的详细IP信息,而且用户数据脚本在实例启动时运行一次,可能无法实时反映集群变化。

  官方参考文档

AWS OpsWorks 堆栈