项目作者: omarpr

项目描述 :
A bash script to install and configure Hadoop DFS, YARN, MapReduce, Apache Hive and Spark on CentOS.
高级语言: Shell
项目地址: git://github.com/omarpr/hadoop_install.git
创建时间: 2017-03-05T02:24:04Z
项目社区:https://github.com/omarpr/hadoop_install

开源协议:Apache License 2.0

下载


About hadoop_install.sh

This script is designed to install a CentOS 6 (and other yum-based OS) cluster with Hadoop DFS, YARN, MapReduce, Apache Hive and Spark of N nodes (one of them master). The original script was done by Pablo Rebollo (from the University of Puerto Rico) and was further improved by me.

Installation

To use this script, the first step is to clone this repository.

  1. git clone https://github.com/omarpr/hadoop_install

Then, modify the following lines of the file hadoop_install.sh. In them, you will specify the name of the user account (this is important for permissions) and the IP of the master node and each data node.

  1. CUSER=omar.soto2

Modify the nodes file to add the IPs of all the nodes of the cluster. The first line of the file will correspond to the master node. The other lines will be identified as dataXX node.

  1. 136.145.216.XXX
  2. 136.145.216.XXX
  3. 136.145.216.XXX
  4. 136.145.216.XXX
  5. ...

Copy the script to all the servers that you will have in the cluster. To install it, just run the script:

  1. sudo ./hadoop_install.sh

Load the .bash_profile to have the environment variables ready:

  1. . ~/.bash_profile

To start the NameNode and the YARN (only on master node), use this:

  1. hadoop-daemon.sh start namenode
  2. yarn-daemon.sh start resourcemanager

(Remember to format the HDFS)

  1. hdfs namenode -format cluster

Run the hadoop_install.sh on each data node (and load .bash_profile) and start the DataNode and NodeManager, using this:

  1. hadoop-daemon.sh start datanode
  2. yarn-daemon.sh start nodemanager

Useful URLs

HDFS Web Application

  1. http://[Master IP]:50070

YARN Web Application

  1. http://[Master IP]:8088

Useful commands

List directory contents

  1. hdfs dfs -ls /

Make directory recursively

  1. hdfs dfs -mkdir -p /a/path

Balance HDFS with threshold 1%

  1. export HADOOP_CLIENT_OPTS="-Xmx2048m $HADOOP_CLIENT_OPTS"
  2. hdfs balancer -threshold 1

Run PySpark console

  1. pyspark --master yarn --deploy-mode client --conf='spark.executorEnv.PYTHONHASHSEED=223'

Submit PySpark application

  1. spark-submit [code.py]

PySpark Streaming Template

  1. from pyspark import SparkContext
  2. from pyspark.streaming import StreamingContext
  3. sc = SparkContext(appName="[Application Name]")
  4. sc.setLogLevel("WARN")
  5. ssc = StreamingContext(sc, 60)
  6. # Code to execute every 60 seconds.
  7. ssc.start()
  8. ssc.awaitTermination()