前置内容:
1、java环境
2、hadoop环境
配置【vi /etc/profile.d/hadoop-eco.sh】
JAVA_HOME=/opt/jdk PATH=$JAVA_HOME/bin:$PATH HADOOP_HOME=/opt/hadoop PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
执行脚本【source /etc/profile.d/hadoop-eco.sh】
Hadoop分布式模式搭建流程:
1、修改配置文件
hadoop-env.sh
mapred-env.sh
yarn-env.sh
core-site.xml
hdfs-site.xml
mapred-site.xml
yarn-site.xml
slaves
1~3,添加或替换
export JAVA_HOME=/opt/jdk
4、配置【core-site.xml】
vi /opt/hadoop/etc/hadoop/core-site.xml
将【localhost】改为【master】
<property> <name>fs.defaultFS</name> <value>hdfs://master:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/opt/soft/hadoop/data/tmp</value> </property>
2、配置【hdfs-site.xml】
vi /opt/hadoop/etc/hadoop/hdfs-site.xml <property> <name>dfs.replication</name> <value>3</value> </property>
3、配置【mapred-site.xml】
vi /opt/hadoop/etc/hadoop/mapred-site.xml <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property>
4、配置【yarn-site.xml】
<property> <name>yarn.resourcemanager.hostname</name> <value>master</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property>
5、配置【slaves】文件
master a1 a2
2、远程拷贝jdk、hadoop、hadoop-eco.sh
1、拷贝jdk
scp -r /opt/jdk a1:/opt/jdk
scp -r /opt/jdk a2:/opt/jdk
复制的比较慢,别急。
2、拷贝hadoop
scp -r /opt/hadoop a1:/opt/hadoop
scp -r /opt/hadoop a2:/opt/hadoop
3、拷贝hadoop-eco.sh
scp /etc/profile.d/hadoop-eco.sh a1:/etc/profile.d/hadoop-eco.sh scp /etc/profile.d/hadoop-eco.sh a2:/etc/profile.d/hadoop-eco.sh