Skip to content

Instantly share code, notes, and snippets.

@yzf
Created August 25, 2016 09:08
Show Gist options
  • Save yzf/91d437e8d57f6ac0cc0cde1cd5353cc7 to your computer and use it in GitHub Desktop.
Save yzf/91d437e8d57f6ac0cc0cde1cd5353cc7 to your computer and use it in GitHub Desktop.
搭建hadoop环境
# set env
export HADOOP_HOME='/home/yzf/Software/hadoop-2.7.2'
export PATH=$HADOOP_HOME/bin:$PATH
export PATH=$HADOOP_HOME/sbin:$PATH
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADDOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_YARN_HOME=$HADOOP_HOME
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
# set JAVA_HOME in etc/hadoop/hadoop-env.sh
export JAVA_HOME=/opt/jdk1.8.0_91
# core-site.xml, add between <configuration></configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
# yarn-site.xml
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
# mapred-site.xml
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
# configure HDFS
mkdir -p data/hdfs/namenode
mkdir -p data/hdfs/datanode
# hdfs-site.xml
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoopuser/mydata/hdfs/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoopuser/mydata/hdfs/datanode</value>
</property>
# format HDFS
hdfs namenode -format
# start hadoop
start-dfs.sh
start-yarn.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment