hadoop2.6.1的配置
cd hadoop2.6.1/etc/hadoop
vim hadoop-env.sh
添加Java环境
export JAVA_HOME=/usr/local/src/jdk1.8.0_172
vim yarn-env.sh
添加Java环境
export JAVA_HOME=/usr/local/jdk1.8.0_172
vim slaves
添加如下:
slave1
slave2
vim core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<!-- 这个是HDFS的路径-->
<value>hdfs://master:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/local/src/hadoop-2.6.1/tmp</value>
</property>
</configuration>
vim hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>master:9001</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/src/hadoop-2.6.1/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/src/hadoop-2.6.1/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
vim yarn-site.xml
<configuration>
<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>
<property>
<name>yarn.resourcemanager.address</name>
<value>master:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>master:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>master:8035</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>master:8033</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>master:8088</value>
</property>
</configuration>
2.创建临时目录和文件
mkdir /usr/local/src/hadoop-2.6.1/tmp
mkdir -p /usr/local/src/hadoop-2.6.1/dfs/name
mkdir -p /usr/local/src/hadoop-2.6.1/dfs/data
配置环境变量
vim ~/.bashrc
export HADOOP_HOME=/usr/local/src/hadoop-2.6.1
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
环境变量生效
source ~/.bashrc
4、拷贝安装包
scp -r /usr/local/src/hadoop-2.6.1 root@slave1:/usr/local/src/hadoop-2.6.1
scp -r /usr/local/src/hadoop-2.6.1 root@slave2:/usr/local/src/hadoop-2.6.1
5.启动集群
初始化 Namenode
hadoop namenode -format
./sbin/start-all.sh
Jps
http://master:8088 --> 网页查看界面
6、验证集群是否正常
hadoop fs -ls /
hadoop fs -put /etc/passwd /
hadoop fs -ls / ---> (看到说明成功,但是mapreduce没跑可能看出来不准确)
hadoop fs -cat /passwd
----------------------------------------------------------------------------
配置Mapreduce,wordcount
cd /home/ badou
ls
mkdir badou_test
ls
cd /usr/local/src/
mv mapreduce_wordcount_python/ /home/badou/badou_test/
cd mapreduce_wordcount_python/
ls
hadoop fs -put 1.data /
hadoop fs -ls /1.data
vim run.sh