本帖最后由 howtodown 于 2015-3-11 19:16 编辑
问题导读
1.Cloudbreak Shell支持哪些功能?
2.有哪三种安装Cloudbreak Shell的方式?
不久前我们公布了Cloudbreak ,开源的Hadoop as a Service API。在本次发布中,我们开源了REST API、REST client、UI和CLI/shell。本文将向大家展示,在用户喜欢的云服务上通过Cloudbreak shell 按需部署Hadoop集群是多么的方便,它可以录制并自动化整个过程。
用户可以根据自己的喜好选择图形界面,命令行界面或者直接调用REST API。在SequenceIQ,我们倾向于尽可能使用命令行工具,因为这比使用web图形界面更加快速并且更适合自动化。我们是不是沉迷于自动化了?当然是!所有可能会被二次执行的步骤我们都会将它脚本化并自动化。
当然,对自动化的执著并没有影响我们付诸于图形界面开发的质量和标准。Cloudbreak的图形界面建立在最新最好的web UI框架Angular JS上,非常直观并且反馈简洁。我们将发布一篇关于图形界面使用的文章。不过,我们建议大家可以直接试用一下这个图形界面- 它非常简单易用,只需一次注册和几次点击就可以部署自己的Hadoop集群了。
现在回到CLI。还记得我们在Apache上的一个贡献Ambari shell and REST API 吗?Cloudbreak shell 也同样建立在Spring Shell技术上, 它是一个互动的shell, 可以使用基于Spring的编程模型进行扩展,并且在诸如Spring Roo, Spring XD等各种项目中经过了实战考验,Spring REST Shell将这两个项目整合成一个强大的工具。
Cloudbreak Shell CLI的提供了一个交互式的命令行工具,它支持:
REST API或Cloudbreak web 图形界面提供的所有功能 通过脚本实现任务管理的自动化 可感知上下文的命令 Tab键补全命令 必须的/可选的参数 hint 命令对用户进行指引
安装Cloudbreak Shell 有三种安装Cloudbreak Shell的方式:
使用我们准备的docker image 从我们的maven repository里下载最新的独立可执行jar文件 从源代码直接创建
从源代码创建
git clone https://github.com/sequenceiq/cloudbreak-shell.git
cd cloudbreak-shell
mvn clean package 复制代码
注意:若用户要使用我们host的Cloudbreak,请使用latest-release.sh获取正确的CLI版本。若用户要从master branch来创建自己的Cloudbreak,请使用latest-snap.sh获取CLI的正确版本。
如果用户希望直接使用代码或者扩展新的命令,请按照以下步骤进行。用户需要jdk 1.7 和maven 3.x.x。
登陆并连接到Cloudbreak 使用shell有几种不同的方法,首先需要一个可连接的Cloudbreak 实例。最简单的办法是使用我们host的Cloudbreak – 你可以用SequenceIQ 帐户及密码直接登录。如果还没有帐户,可以在这里 申请。
或者,你可以host 自己的Cloudbreak实例,具体步骤请参考Cloudbreak 文档。 如果你host自己的Cloudbreak 服务器,你依然可以用SequenceIQ 的帐户和我们的身份认证服务器,但前提是为你的Cloudbreak 安装配置正确的客户端帐户信息使其能被我们的身份认证服务器接受。目前还不支持通过API来注册你的Cloudbreak 应用(但这个已经在我们计划中),如果你想要使用这个方法,请联系我们。
第三种方法是将我们的整个应用随着Cloudbreak 一起部署在你们本地的系统上,包括我们基于OAuth2的身份认证服务器和用户管理应用Sultans。
我们建议用户使用我们host的服务以便遇到问题时得到我们的及时帮助。欢迎用户通过我们的GitHub repository或者其他在产品文档中指明的任何方式向我们提出bug,要求改进,或者给我们提供任何反馈。
Cloudbreak shell是一个基于Spring Boot的独立可执行jar。
Usage:
java -jar cloudbreak-shell-0.2-SNAPSHOT.jar : Starts Cloudbreak Shell in interactive mode.
java -jar cloudbreak-shell-0.2-SNAPSHOT.jar --cmdfile=<FILE> : Cloudbreak executes commands read from the file.
Options:
--cloudbreak.address=<http[s]://HOSTNAME:PORT> Address of the Cloudbreak Server [default: https://cloudbreak-api.sequenceiq.com].
--identity.address=<http[s]://HOSTNAME:PORT> Address of the SequenceIQ identity server [default: https://identity.sequenceiq.com].
--sequenceiq.user=<USER> Username of the SequenceIQ user [default: user@sequenceiq.com].
--sequenceiq.password=<PASSWORD> Password of the SequenceIQ user [default: password].
Note:
You should specify at least your username and password. 复制代码
创建一个云帐户登陆信息
用户需要一个云服务账户(比如Amazon AWS帐户)来使用Cloudbreak。请注意Cloudbreak并不会保存你的云帐户信息。我们使用Amazon的IAM(Identity and Access Management),这要求用户在Amazon或其他云服务中创建一个IAM角色和策略,并与自己的云账户关联。请参考文档获得更详尽说明。
credential createEC2 --description “description" --name “myCredentialName" --roleArn "arn:aws:iam::NUMBER:role/cloudbreak-ABC" --sshKeyUrl “URL towards your AWS public key" 复制代码
用户也可以通过—sshKeyPath switch上传自己公钥的方式建立账户登陆信息, 通过credential list 命令来确认登陆信息是否建立成功。用户可以在几个云登陆信息中切换,当你想选择某个登陆信息并以其身份活动的话,请使用以下命令:
credential select --id #ID of the credential 复制代码
创建一个template
template给开发者和系统管理员提供了一个简便的方法进行云系统资源集合创建及管理,进行有条理可预测的维护和更新。用户可以使用template重复的创建相同的stack(或者以其为基础创建新的stack)。
template createEC2 --name awstemplate --description aws-template --region EU_WEST_1 --instanceType M3Xlarge --volumeSize 100 --volumeCount 2 复制代码
用户可以使用template list命令查询一个template是否创建成功。通过下面的命令来查询及选择一个你想要的template:
template show --id #ID of the template
template select --id #ID of the template 复制代码
创建一个stack
Stack是template的实例,是一个基于template的运行着的云系统。使用以下的命令来创建一个被你的Hadoop集群所使用的stack。
stack create --name “myStackName" --nodeCount 10 复制代码
选择一个blueprint
我们用Cloudbreak发布了一些缺省的Hadoop 集群blueprint。用户可以使用这些blueprint或者添加自己的。通过下面的命令来查看可用的blueprint, 选择某个blueprint:
blueprint list
blueprint select --id #ID of the blueprint 复制代码
创建一个Hadoop集群
现在已经快要完成了,只剩下一个命令就可以在你喜欢的云服务上创建你的Hadoop集群。与调用API或者图形界面相同,这个命令将使用你的template ,通过CloudFormation来启动一个云端stack ,一旦这个stack被启动并运行(云端的准备已经完成),它将使用你选择的blueprint并安装你的定制Hadoop集群及选定的组件和服务。请参考文档来查看我们支持的Hadoop组件和服务。
cluster create --description “my cluster desc" 复制代码
至此工作已经完成,你可以通过Ambari图形界面来检查进度。如果你在 Cloudbreak UI中设置了log,你也可以在这里查看进度并找到Ambari的IP地址。
自动化这个过程
每次启动shell,所有执行的命令都会一行一行的写入log文件。之后用户可以通过script命令或者在这个命令后加入—cmdfile 选项来重新执行一边这些命令。
命令下面列出了所有可用的命令。请注意所有的命令都是上下文感知的,并且可以通过使用tab键来补全命令。
* blueprint add - Add a new blueprint with either --url or --file
* blueprint defaults - Adds the default blueprints to Cloudbreak
* blueprint list - Shows the currently available blueprints
* blueprint select - Select the blueprint by its id
* blueprint show - Shows the blueprint by its id
* cluster create - Create a new cluster based on a blueprint and template
* cluster show - Shows the cluster by stack id
* credential createAzure - Create a new Azure credential
* credential createEC2 - Create a new EC2 credential
* credential defaults - Adds the default credentials to Cloudbreak
* credential list - Shows all of your credentials
* credential select - Select the credential by its id
* credential show - Shows the credential by its id
* exit - Exits the shell
* help - List all commands usage
* hint - Shows some hints
* quit - Exits the shell
* script - Parses the specified resource file and executes its commands
* stack create - Create a new stack based on a template
* stack list - Shows all of your stack
* stack select - Select the stack by its id
* stack show - Shows the stack by its id
* stack terminate - Terminate the stack by its id
* template create - Create a new cloud template
* template createEC2 - Create a new EC2 template
* template defaults - Adds the default templates to Cloudbreak
* template list - Shows the currently available cloud templates
* template select - Select the template by its id
* template show - Shows the template by its id
* version - Displays shell version 复制代码
100%的开源是我们的一贯作风,我们一直致力于将一切开源-在GitHub repository上可以查看具体内容。如果有任何问题,欢迎通过我们的blog与我们联系,或者在LinkedIn, Twitter 或 Facebook上关注我们。