Total Pageviews

Showing posts with label hadoop. Show all posts
Showing posts with label hadoop. Show all posts

Sunday, 16 June 2024

dr-elephant

 Dr. Elephant is a job and flow-level performance monitoring and tuning tool for Apache Hadoop and Apache Spark。

Dr. Elephant is a performance monitoring and tuning tool for Hadoop and Spark. It automatically gathers all the metrics, runs analysis on them, and presents them in a simple way for easy consumption. Its goal is to improve developer productivity and increase cluster efficiency by making it easier to tune the jobs. It analyzes the Hadoop and Spark jobs using a set of pluggable, configurable, rule-based heuristics that provide insights on how a job performed, and then uses the results to make suggestions about how to tune the job to make it perform more efficiently.

Documentation

For more information on Dr. Elephant, check the wiki pages here.

For quick setup instructions: Click here

Developer guide: Click here

Administrator guide: Click here

User guide: Click here

Engineering Blog: Click here

from https://github.com/linkedin/dr-elephant

----------

Quick Setup Instructions (Must Read)

Step 1: Create an account on github and fork the Dr. Elephant project.

Step 2: Checkout the code.

$> git clone https://github.com/<username>/dr-elephant
$> cd dr-elephant*

Step 3: Prerequisites:

  1. You must have play or activator command installed. Download the activator zip from https://downloads.typesafe.com/typesafe-activator/1.3.12/typesafe-activator-1.3.12.zip, unzip it and add the activator command to your $PATH. For older versions of Play, you need to add the play command instead of activator.
export ACTIVATOR_HOME=/path/to/unzipped/activator
export PATH=$ACTIVATOR_HOME/bin:$PATH
  1. Dr. Elephant stores the analyzed results in a MySQL database. Please install and setup mysql if you do not have it yet. (Recommend version 5.5+)
  2. (Optional, but recommended) In order to use the new Dr. Elephant UI, you need to install npm and dependencies
sudo yum install npm
sudo npm install -g bower
cd web; bower install; cd ..
  1. Lastly, you should have Hadoop and/or spark already setup.

Step 4: (Optional, Beta Phase) Please follow the below steps if you wish to try out the auto-tuning feature. (More details: https://github.com/linkedin/dr-elephant/wiki/Auto-Tuning)

  • Enable it by setting the value of property autotuning.enabled to true in app-conf/AutoTuningConf.xml
  • Install python with version 2.6+
  • If you want to use a python installation other than the one set in environment:
    • Either set PYTHON_PATH to the path of desired python executable: $> export PYTHON_PATH=/path/to/python/executable
    • Or, uncomment and set the value of optional property python.path to the path of desired python executable in app-conf/AutoTuningConf.xml
  • Install inspyred package by executing: sudo pip install inspyred
  • If pip is missing, it can be installed from https://pip.pypa.io/en/stable/installing/

Step 5: Compile Dr. Elephant code and generate the zip. Compile.sh script optionally takes a configuration file which includes the version of Hadoop and Spark to compile with. For instructions check the Developer Guide.

$> ./compile.sh [./compile.conf]

After compiling, the distribution is created under dist directory.

$> ls dist
dr-elephant*.zip

Step 6: Copy the distribution file to the machine where you want to deploy Dr. Elephant.

Step 7: On the machine where you want to deploy Dr. Elephant, make sure the below env variables are set.

$> export HADOOP_HOME=/path/to/hadoop/home
$> export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
$> export SPARK_HOME=/path/to/spark/home
$> export SPARK_CONF_DIR=/path/to/conf

Add hadoop to the system path because Dr. Elephant uses 'hadoop classpath' to load the right classes.

$> export PATH=$HADOOP_HOME/bin:$PATH

Step 8: You also need a backend to save the data. Configure the mysql database in the elephant.conf file.

# Database configuration
db_url=localhost
db_name=drelephant
db_user=root
db_password=""

Step 9:(Optional) If you want to have SSL enabled Dr.Elephant then add these confs in elephant.conf

# SSL related configuration
https_port=8090(any port you can configure)
https_keystore_location="/path/to/keystore"
https_keystore_type=TYPE_OF_KEYSTORE(for instance JKS)
https_keystore_password="password_for_keystore"

Step 10: If your cluster is kerberised, then update the keytab user and the keytab file location in the elephant.conf file.

Step 11: If you are running Dr. Elephant for the first time, you need to enable evolutions. To do so append(or uncomment jvm_props) -Devolutionplugin=enabled and -DapplyEvolutions.default=true to jvm_props in elephant.conf file. This will automatically create the mysql tables for you. Remember to disable the evolutions when you restart Dr. Elephant the next time.

$> vim ./app-conf/elephant.conf
jvm_props=" -Devolutionplugin=enabled -DapplyEvolutions.default=true"

Step 12: To start dr-elephant, run the start script specifying a path to the application's configuration files.

$> /bin/start.sh /path/to/app-conf/directory

To verify if Dr. Elephant started correctly, check the dr.log file.

$> less $DR_RELEASE/dr.log
...
play - database [default] connected at jdbc:mysql://localhost/drelephant?characterEncoding=UTF-8
application - Starting Application...
play - Application started (Prod)
play - Listening for HTTP on /0:0:0:0:0:0:0:0:8080

To verify if Dr. Elephant is analyzing jobs correctly correctly check the dr-elephant.log file.

$> less $DR_RELEASE/../logs/elephant/dr_elephant.log

Step 13: Once the application starts, you can open the UI at ip:port (localhost:8080)

Step 14: To stop dr-elephant run

$> bin/stop.sh 
from https://github.com/linkedin/dr-elephant/wiki/Quick-Setup-Instructions-(Must-Read) 

 

 

Friday, 1 July 2016

在谷歌云上,部署hdp

Tools for creating Hadoop and Spark clusters on Google Compute Engine. See http://cloud.google.com/hadoop for more information.

Hortonworks Data Platform + Google Cloud Platform

Hortonworks Data Platform (HDP) on Google Cloud Platform

This extension, to Google's bdutil, provides support for deploying the Hortonworks Data Platform with a single command.
The extension utilizes Apache Ambari's Blueprint Recommendations to fully configure the cluster without the need for manual configuration.

Resources

Video Tutorial

Before you start

Create a Google Cloud Platform account

Create a Google Cloud Project

  • Open https://console.developers.google.com/
  • Open 'Create Project' and fill in the details.
    • As an example, this document uses 'hdp-00'
  • Within the project, open 'APIs & auth -> APIs'. Then enable:
    • Google Compute Engine
    • Google Cloud Storage
    • Google Cloud Storage JSON API

Configure Google Cloud SDK & Google Cloud Storage

  • Install Google Cloud SDK locally
  • Configure the SDK:
    gcloud auth login                   ## authenticate to Google cloud
    gcloud config set project hdp-00    ## set the default project
    gsutil mb -p hdp-00 gs://hdp-00     ## create a cloud storage bucket
    

Download bdutil

Quick start

  1. Set your project & bucket from above in bdutil_env.sh
  2. Deploy or Delete the cluster: see './bdutil --help' for more details
  • Deploy: ./bdutil -e ambari deploy
  • Delete: ./bdutil -e ambari delete
    • when deleting, ensure to use the same switches/configuration as the deploy

Configuration

  • You can deploy without setting any configuration, but you should have a look at platforms/hdp/ambari.conf
Here are some of the defaults to consider:
  GCE_ZONE='us-central1-a'           ## the zone/region to deploy in
  NUM_WORKERS=4                      ## the number of worker nodes. Total
                                     ##     is NUM_WORKERS + 1 master
  GCE_MACHINE_TYPE='n1-standard-4'   ## the machine type
  WORKER_ATTACHED_PDS_SIZE_GB=1500   ## 1500GB attached to each worker
  MASTER_ATTACHED_PD_SIZE_GB=1500    ## 1500GB attached to master

  ## The Hortonworks Data Platform services which will be installed.
  ##   This is nearly the entire stack
  AMBARI_SERVICES="ACCUMULO AMBARI_METRICS ATLAS FALCON FLUME GANGLIA HBASE HDFS
      HIVE KAFKA MAHOUT MAPREDUCE2 OOZIE PIG SLIDER SPARK SQOOP STORM TEZ YARN
      ZOOKEEPER"

  AMBARI_PUBLIC=false                ## Services listed on internal
                                     ##   hostname not public IP. Need
                                     ##   a socks proxy or tunnel to access

Use the cluster

SSH

  • You'll have immediate SSH access with: ./bdutil shell
  • Or update your SSH config with: gcloud compute config-ssh

Access Ambari & other services

a. With a local socks proxy:
  ./bdutil socksproxy             # opens a socks proxy to the cluster at localhost:1080

  # I use the Chrome extension 'Proxy SwitchySharp' to automatically detect when connecting to Google Compute
  open http://hadoop-m:8080/      # My Google Chrome has an extension which automatically uses the proxy
b. Or a local SSH tunnel
  gcloud compute config-ssh                  # updates our SSH config for direct SSH access to all nodes
  ssh -L 8080:127.0.0.1:8080 hadoop-m  <TAB> # quick tunnel to Apache Ambari
  open http://localhost:8080/                # open Ambari in your browser
c. Or open a firewall rule from the Google Cloud Platform control panel

Use the cluster

You now have a full HDP cluster. If you are new to Hadoop check the tutorials at http://hortonworks.com/.
For command-line based jobs, 'bdutil' gives methods for passing through commands:https://cloud.google.com/hadoop/running-a-mapreduce-job
For example: ./bdutil shell < ./extensions/google/gcs-validate-setup.sh

Questions

Can I set/override Hadoop configurations during deployment?

For adding/overriding Hadoop configurations, update configuration.json and then use the extension as documented. And contribute back if you think the defaults should be changed.

Can I deploy HDP manually using Ambari and/or use my own Ambari Blueprints?

Yes. Set ambari_manual_env.sh as your environment (with the -e switch) instead of ambari_env.sh. That will configure Ambari across the cluster & handle all HDP prerequisites, but not trigger the Ambari Blueprints which install HDP.
After manually deploying your cluster, you can use ./bdutil <YOUR_FLAGS> -e platforms/hdp/ambari_manual_post_deploy_env.sh run_command_steps to configure HDFS directories and install the GCS connector. Note it uses run_command_steps instead of deploy.

Can I re-use the attached persistent disk(s) across deployments?

bdutil supports keeping persistent disks (aka ATTACHED_PDS) online when deleting machines. It can then deploy a new cluster using the same disks without lose of data, assuming the number of workers is the same.
The basic commands are below. Find more detail in TEST.md.
## deploy the cluster & create disks
./bdutil -e ambari deploy

## delete the cluster but don't delete the disks
export DELETE_ATTACHED_PDS_ON_DELETE=false
./bdutil -e ambari delete

## create with existing disks
export CREATE_ATTACHED_PDS_ON_DEPLOY=false
./bdutil -e ambari deploy
Another would be to use gs:// (Google Cloud Storage) instead of hdfs:// in your Hadoop jobs, even setting it as the default. Or backup HDFS to Google Cloud Storage before cluster deletion.
Note: Hortonworks can't guarantee the safety of data throughout this process. You should always take care when manipulating disks and have backups where necessary.

What are the built-in storage options?

By default, HDFS is on attached disks ('pd-standard' or 'pd-ssd').
  • the size and type can be set in ambari.conf
The rest of the system resides on the local boot disk, unless configured otherwise.
Google Cloud Storage is also available with gs://. It can be used anywhere that hdfs:// is available, such as but not limited to mapreduce & hadoop fs operations.
  • Note: Adding an additional slash (gs:///) will allow you to use the default bucket (defined at cluster build) without needing to specific it.

Can I deploy in the Google Cloud Platform Free Trial ?

You may use bdutil with HDP by lowering the machine type & count below the recommended specifications. To use the default configuration, upgrade the account from a free trial.
  • In 'platforms/hdp/ambari.conf':
    • GCE_MACHINE_TYPE='n1-standard-2'
    • WORKERS=3 # or less
  • Or at the command-line provide these switches to the 'deploy' & 'delete':
    • Deploy cluster: -n 3 -m n1-standard-2

Known Issues

Feedback & Issues

from https://github.com/GoogleCloudPlatform/bdutil/blob/master/platforms/hdp/README.md

Monday, 9 May 2016

EasyHadoop


EasyHadoop 是一个 Hadoop 一键安装系统,方便大家更容易安装部署Hadoop软件。EasyHadoop 由前暴风影音数据团队修湘调研,向磊编写,以GPL协议进行开源。 
开发语言:PHP/Python 
授权协议:GPLv3 
源码下载:https://github.com/xianglei/easyhadoop 

Saturday, 28 June 2014

在Raspberry Pi上,搭建Hadoop集群

Hadoop是由Java实现的,所以在树莓派上运行就和在其他x86平台上运行一样简单。首先, 我们需要安装支持树莓派Raspberry Pi的JVM。可以选用OpenJDK或者Oracle的JDK 8。我个人推荐JDK8,其速度稍微快些,但是OpenJDK安装更容易些。
推荐阅读:
Ubuntu 12.10下Hadoop集群免登陆配置 http://www.linuxidc.com/Linux/2013-06/85833.htm
Ubuntu 13.04上搭建Hadoop环境 http://www.linuxidc.com/Linux/2013-06/86106.htm
Raspberry Pi 树莓派搭LAMP服务器 http://www.linuxidc.com/Linux/2013-06/86687.htm
1. 安装Java
安装OpenJDK十分简单, 只要执行以下命令
pi@raspberrypi ~ $ sudo apt-get install openjdk-7-jdk
pi@raspberrypi ~ $ java -version
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-1+rpi1)
OpenJDK Zero VM (build 22.0-b10, mixed mode)
另外, 我们可以选择安装Oracle的JDK 8.
可以从这获得: https://wiki.openjdk.java.net/display/OpenJFX/OpenJFX+on+the+Raspberry+Pi
pi@raspberrypi ~ $sudo tar zxvf jdk-8-ea-b36e-linux-arm-hflt-*.tar.gz -C /opt
pi@raspberrypi ~ $sudo update-alternatives --install "/usr/bin/java" 
"java" "/opt/jdk1.8.0/bin/java" 1 
pi@raspberrypi ~ $ java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b36e)
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode)
如果你两个都装了, 用以下命令来切换即可:
sudo update-alternatives --config java
2. 新增一个hadoop系统用户
pi@raspberrypi ~ $ sudo addgroup hadoop
pi@raspberrypi ~ $ sudo adduser --ingroup hadoop hduser
pi@raspberrypi ~ $ sudo adduser hduser sudo
3. 设置SSH
pi@raspberrypi ~ $ su - hduserhduser@raspberrypi ~ $ ssh-keygen -t rsa -P ""
这会生成一个匹配空密码的RSA密钥. 在与其他节点通讯时Hadoop将不再提示输入密码
hduser@raspberrypi ~$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
现在设置SSH允许用刚生成的密钥访问
hduser@raspberrypi ~$ ssh localhost
现在我们就应该可以不使用密码也可以登录了
4. 安装Hadoop
我们可以从http://www.apache.org/dyn/closer.cgi/hadoop/core下载hadoop
hduser@raspberrypi ~$ wget http://mirror.catn.com/pub/apache/hadoop/core/hadoop-1.1.2/hadoop-1.1.2.tar.gz
hduser@raspberrypi ~$sudo tar vxzf hadoop-1.1.2.tar.gz -C /usr/local
hduser@raspberrypi ~$cd /usr/local
hduser@raspberrypi /usr/local$ sudo mv hadoop-1.1.2 hadoop
hduser@raspberrypi /usr/local$ sudo chown -R hduser:hadoop hadoop
现在hadoop就安装好了. 编译home目录下的.bashrc文件, 将以下内容添加到其中
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-armhf
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
如果你用的是oracle的JDK, 相应的修改JAVA_HOME.
重启一下树莓派来验证安装是否成功:
hduser@raspberrypi ~$ hadoop version
Hadoop 1.1.2
Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/
branch-1.1 -r 1440782
Compiled by hortonfo on Thu Jan 31 02:03:24 UTC 2013
From source with checksum c720ddcf4b926991de7467d253a79b8b
5. 配置Hadoop
注意: 这里的配置是hadoop单节点模式的最低配.
配置文件位于"/usr/local/hadoop/conf/", 我们需要修改core-site.xml, hdfs-site.xml, mapred-site.xml三个文件
core-site.xml
<configuration>
  <property>
    <name>hadoop.tmp.dir</name>
    <value>/fs/hadoop/tmp</value>
  </property>
  <property>
    <name>fs.default.name</name>
    <value>hdfs://localhost:54310</value>
  </property>
</configuration>
mapred-site.xml
<configuration>
  <property>
    <name>mapred.job.tracker</name>
    <value>localhost:54311</value>
  </property>
</configuration>
hdfs-site.xml
<configuration>
  <property>
    <name>dfs.replication</name>
    <value>1</value>
  </property>
</configuration>
哦了, 即将完工, 还剩最后一步.
hduser@raspberrypi ~$ sudo mkdir -p /fs/hadoop/tmp
hduser@raspberrypi ~$ sudo chown hduser:hadoop /fs/hadoop/tmp
hduser@raspberrypi ~$ sudo chmod 750 /fs/hadoop/tmp
hduser@raspberrypi ~$hadoop namenode -format
注意:
如果选用的是JDK 8, 我们需要强制在JVM client模式下运行DataNode, 因为JDK 8还不支持server模式. 进入/usr/local/hadoop/bin目录中来编辑hadoop文件(请先备份). 使用nano进行修改的步骤如下:nano hadoop, ctrl-w输入“-server”进行查找. 我们需要删除“-server”这个参数, 然后保存退出就行了.
hadoop单节点系统就算是搭建完成了. 下面给一些有用的命令.
1. jps           // 输出本地VM标识符
2. start-all.sh  // 启动所有hadoop进程
3. stop-all.sh   // 停止所有hadoop进程
 更多Hadoop相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13