Skip to content

Instantly share code, notes, and snippets.

@edthrn
Last active April 10, 2019 00:09
Show Gist options
  • Save edthrn/4dc3ca4d9f79659d819167c4116fa238 to your computer and use it in GitHub Desktop.
Save edthrn/4dc3ca4d9f79659d819167c4116fa238 to your computer and use it in GitHub Desktop.
A Bash script to automate Hadoop installation.
#!/bin/bash
# MIT License
# Copyright (c) 2019 nibble.ai
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Note: This script must be run as the `hadoop` user
export HADOOP_VERSION=hadoop-3.1.1
curl \
http://mirrors.ibiblio.org/apache/hadoop/common/${HADOOP_VERSION}/${HADOOP_VERSION}.tar.gz \
--output $HOME/${HADOOP_VERSION}.tar.gz
tar -xzf $HOME/${HADOOP_VERSION}.tar.gz -C $HOME
export JAVA_HOME=$(find /usr/lib -name *java-8*)/jre
export HADOOP_HOME=$HOME/$HADOOP_VERSION
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$JAVA_HOME/bin:$PATH
echo "export JAVA_HOME=${JAVA_HOME}" >> $HOME/.bashrc
echo "export HADOOP_HOME=${HADOOP_HOME}" >> $HOME/.bashrc
echo "export PATH=${PATH}" >> $HOME/.bashrc
echo "export JAVA_HOME=${JAVA_HOME}" > $HADOOP_HOME/etc/hadoop/hadoop-env.sh
declare -a envvars=(
"HDFS_NAMENODE_USER"
"HDFS_SECONDARYNODE_USER"
"HDFS_DATANODE_USER"
"YARN_RESSOURCEMANAGER_USER"
"YARN_NODEMANAGER_USER"
)
for ev in "${envvars[@]}"; do
echo "export ${ev}=${USER}" >> $HADOOP_HOME/etc/hadoop/hadoop-env.sh
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment