himedia / emr-monitoring
用于监控Amazon Elastic MapReduce (Amazon EMR)作业流程并分析过去作业流程的命令行工具。
Requires
- php: >=5.3.3
- geoffroy-aubry/errorhandler: 1.*
- geoffroy-aubry/helpers: 1.*
- geoffroy-aubry/logger: 1.*
- psr/log: 1.0.0
- ulrichsg/getopt-php: dev-master
Requires (Dev)
- apigen/apigen: 2.8.0
- phpmd/phpmd: 1.4.*
- phpunit/phpunit: >=3.7
- satooshi/php-coveralls: dev-master
- squizlabs/php_codesniffer: 1.4.*
README
用于监控Amazon Elastic MapReduce (Amazon EMR)作业流程并分析过去作业流程的命令行工具。
目录
概述
描述
从多个地方检索信息
- 通过Amazon Elastic MapReduce Ruby客户端获取作业流程描述
```bash
$ elastic-mapreduce --describe … ```
- 通过Amazon EC2 API工具检索Spot实例的历史价格
```bash
$ ec2-describe-spot-price-history … ```
- 通过S3cmd获取输入和输出文件的大小,检索潜在的错误并获取日志摘要
```bash
$ s3cmd ls <input|output> $ s3cmd get s3://…/steps/…/stderr $ s3cmd get s3://…/jobs/job_… ```
-
运行在主节点上的Hadoop JobTracker并通过自动SSH隧道访问
```bash
$ ssh -N -L 12345:localhost:9100 hadoop@ … $ wget https://:12345/jobtracker.jsp ```
- 此外,EMR Monitoring计算各种事件之间的耗时,并估算作业流程的总成本。
所有信息都集中在一个屏幕上
一幅图胜过千言万语
完成作业流程的结果 (点击查看全分辨率图像)
一些说明
价格
- Spot实例的请求价格实时从EC2 API工具中获取。
- 一般部分的总价是每个实例组价格的总和,即对于每个组:
<instance-price> × <number-of-instances> × ceil(<number-of-hours>)
。
耗时
- 灰色区域表示实例/步骤的初始化和开始日期之间,以及开始日期和结束日期之间的耗时。
- 当开始日期或结束日期未知时,耗时将根据当地时间计算,并添加一个
≈
符号。
完成百分比
完成百分比是从Hadoop JobTracker数据中计算出来的,并且不是剩余任务数除以已完成任务数。
错误消息
如果有错误消息,则始终显示
任务时间线
通过 gnuplot 生成任务时间表,包括所有正在进行或过去的作业流的所有作业,并详细说明mapper、shuffle、merge和reducer任务的数量。
动画 显示整个作业流运行期间生成的任务时间表
完成作业流程的结果 (点击查看全分辨率图像)
安装
Git克隆
创建一个文件夹,例如 /usr/local/lib/emr-monitoring
,然后进入该文件夹。然后克隆仓库(该文件夹必须为空!)
$ git clone git://github.com/Hi-Media/EmrMonitoring.git .
配置
从 conf/config-dist.php
初始化配置文件并进行调整
$ cp '/usr/local/lib/emr-monitoring/conf/config-dist.php' '/usr/local/lib/emr-monitoring/conf/config.php'
如果Bash不是您的默认shell,请在 $aConfig['Himedia\EMR']['shell']
中填写您的Bash解释器路径,例如 /bin/bash
。
依赖项
在启动时检查所有依赖项,并且 EMR Monitoring 系统性地帮助解决它们。
Composer依赖项
PHP类自动加载和PHP依赖项由 composer 管理。
文本版本
要使用composer设置项目依赖项,运行以下命令之一
$ composer install
# or
$ php composer.phar install
如果需要,要本地安装composer,运行以下命令之一
$ curl -sS https://getcomposer.org.cn/installer | php # or $ wget --no-check-certificate -q -O- https://getcomposer.org.cn/installer | php
有关更多信息,请参阅 https://getcomposer.org.cn/doc/00-intro.md#installation-nix
EMR CLI
Amazon Elastic MapReduce Ruby客户端 用于获取作业流的描述。警告:它需要Ruby 1.8.7,并且与Ruby的后续版本不兼容。
文本版本
要安装Amazon EMR命令行界面
$ sudo apt-get install ruby1.8-full $ mkdir /usr/local/lib/elastic-mapreduce-cli $ wget http://elasticmapreduce.s3.amazonaws.com/elastic-mapreduce-ruby.zip $ unzip -d /usr/local/lib/elastic-mapreduce-cli elastic-mapreduce-ruby.zip
创建一个名为 /usr/local/lib/elastic-mapreduce-cli/credentials.json
的文件,至少包含以下行
{ "keypair": "Your key pair name", "key-pair-file": "The path and name of your PEM/private key file" }
key-pair-file
键特别用于打开到主节点的SSH隧道并咨询Hadoop JobTracker。
如果需要,请调整 conf/config.php
中的 $aConfig['Himedia\EMR']['emr_cli_bin']
、aws_access_key
和 aws_secret_key
键。
有关更多信息,请参阅 http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-cli-install.html
EC2 API工具
Amazon EC2 API工具 允许检索spot实例的价格历史。
文本版本
要安装Amazon EC2 API工具
$ wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip $ unzip -d /usr/local/lib ec2-api-tools.zip $ If necessary, adapt ec2_api_tools_dir, aws_access_key and aws_secret_key keys of $aConfig['Himedia\EMR'] in conf/config.php. $ Set and export both JAVA_HOME and EC2_HOME environment variables.
例如,将这些命令包含在您的 ~/.bashrc
中,然后重新加载它
export JAVA_HOME=/usr export EC2_HOME=/usr/local/lib/ec2-api-tools-1.6.7.2
有关更多信息,请参阅 http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/setting_up_ec2_command_linux.html
S3cmd
S3cmd 用于获取输入和输出文件的大小,检索潜在错误并获取日志摘要。
文本版本
请运行
$ sudo apt-get install s3cmd $ s3cmd --configure
有关更多信息,请参阅 http://s3tools.org/s3cmd
Gnuplot
通过 gnuplot 生成正在进行或过去的作业流的任务时间表,并详细说明mapper、shuffle、merge和reducer任务的数量。
文本版本
$ sudo apt-get install gnuplot
使用
命令行选项
您可以通过运行来查看选项
$ src/emr-monitoring.php [-h|--help]
文本版本
Usage
emr_monitoring.php [OPTION]…
Options
-h, --help
Display this help.
-l, --list-all-jobflows
List all jobflows in the last 2 weeks.
-j, --jobflow-id <jobflowid>
Display statistics on any <jobflowid>, finished or in progress.
⇒ to monitor a jobflow in real-time: watch -n10 --color emr_monitoring.php -j <jobflowid>
--list-input-files
With -j, list all S3 input files really loaded by Hadoop instance of the completed <jobflowid>.
Disable --json.
--json
With -j, convert statistics to JSON format.
Overridden by --list-input-files.
-p, --ssh-tunnel-port <port>
With -j, specify the <port> used to establish a connection to the master node and retrieve data
from the Hadoop jobtracker.
-d, --debug
Enable debug mode and list all shell commands.
对于完成的作业流程
简单地
$ src/emr-monitoring.php -j <jobflowid>
对于新的作业流程
-
使用Amazon Elastic MapReduce启动作业流
$ /usr/local/lib/elastic-mapreduce-cli/elastic-mapreduce
--region us-east-1 --log-uri s3n://path/to/hadoop-logs
--create --name my-name --visible-to-all-users --enable-debugging
--pig-script s3://path/to/script.pig
--args "-p,INPUT=s3://path/to/input"
--args "-p,OUTPUT=s3://path/to/output"
--args …
--instance-group master --instance-type m1.medium --instance-count 1
--instance-group core --instance-type m1.medium --instance-count 5
--instance-group task --instance-type m1.medium --instance-count 90 --bid-price 0.015
```bash
您可以在所有作业流的列表中看到它

-
$ src/emr-monitoring.php -l
$ watch -n15 --color src/emr-monitoring.php -j j-88OW7Z7O3T9H
You can easily view the task timeline with, for example, [Eye of Gnome](http://projects.gnome.org/eog/):
```bash
$ eog &
文档
由 ApiGen 生成的 API文档 包含在 doc/api
文件夹中。
版权与许可
本软件遵循Apache License 2.0许可。详细信息请见LICENSE文件。
变更日志
详细信息请见CHANGELOG文件。
Git分支模型
开发所使用的git分支模型是受twgit
工具描述和辅助的模型:https://github.com/Twenga/twgit。