[root@hadoop00 ~]# groupadd hadoop
[root@hadoop00 ~]# useradd -g hadoop hadoop
[root@hadoop00 ~]# passwd hadoop
[root@hadoop00 ~]# mkdir /mnt/centos
[root@hadoop00 ~]# mount -o loop /root/CentOS-6.8-x86_64-bin-DVD1.iso /mnt/centos
[root@hadoop00 ~]# cd /etc/yum.repos.d
[root@hadoop00 ~]# mkdir bakup
[root@hadoop00 ~]# mv Cent* bakup
[root@hadoop00 ~]# vi local.repo
[local]
name=local
baseurl=file:///mnt/centos
enabled=1
gpgcheck=0
[root@hadoop00 ~]# rpm -qa|grep openssh
[root@hadoop00 ~]# rpm -qa|grep rsync
[root@hadoop00 ~]# yum -y install openssh
[root@hadoop00 ~]# yum install openssh-clients.x86_64 -y
[root@hadoop00 ~]# yum -y install rsync
[root@hadoop00 ~]# su - hadoop
[root@hadoop00 ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
[root@hadoop00 ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[root@hadoop00 ~]# chmod 600 ~/.ssh/authorized_keys
无需输入密码,即可完成登录,表示SSH配置成功。
[root@hadoop00 ~]# tar zxvf /root/hadoop-2.7.3.tar.gz -C /usr/
[root@hadoop00 ~]# mv /usr/hadoop-2.7.3/ /usr/hadoop
[root@hadoop00 ~]# chown -R hadoop:hadoop /usr/hadoop/
[root@hadoop00 ~]# vi /etc/profile
(文档末尾追加如下内容)
export HADOOP_HOME=/usr/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
[root@hadoop00 ~]# source /etc/profile
[root@hadoop00 ~]# su - hadoop
[hadoop@hadoop00 ~]$ cd /usr/hadoop/etc/hadoop/
[hadoop@hadoop00 ~]$ vi hadoop-env.sh
(文档末尾追加如下内容)
export JAVA_HOME=/usr/java/jdk1.8.0_162
[hadoop@hadoop00 ~]$ vi core-site.xml
(添加如下内容,注意标签对的匹配及唯一性)
[hadoop@hadoop00 ~]$ vi hdfs-site.xml
(添加如下内容)
[hadoop@hadoop00 ~]$ hdfs namenode -format
注:出现Exiting with status 0即为成功
[hadoop@hadoop00 ~]$ start-dfs.sh
(停止命令)# stop-dfs.sh
注:输出如下内容,则启动成功
15/09/21 18:09:13 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [Hadoop.Master]
Hadoop.Master: starting namenode, logging to /usr/hadoop/logs/hadoop-hadoop-namenode-Hadoop.Master.out
Hadoop.Master: starting datanode, logging to /usr/hadoop/logs/hadoop-hadoop-datanode-Hadoop.Master.out
Starting secondary namenodes [0.0.0.0]
The authenticity of host '0.0.0.0 (0.0.0.0)' can't be established.
RSA key fingerprint is b5:96:b2:68:e6:63:1a:3c:7d:08:67:4b:ae:80:e2:e3.
Are you sure you want to continue connecting (yes/no)? yes
0.0.0.0: Warning: Permanently added '0.0.0.0' (RSA) to the list of known hosts.
0.0.0.0: starting secondarynamenode, logging to /usr/hadoop/logs/hadoop-hadoop-secondarynamenode-Hadoop.Master.out
15/09/21 18:09:45 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicab
[hadoop@hadoop00 ~]$ jps
注:输出类似如下内容
1763 NameNode
1881 DataNode
2146 Jps
2040 SecondaryNameNode
[hadoop@hadoop00 ~]$ hdfs dfs -mkdir /user
[hadoop@hadoop00 ~]$ hdfs dfs -mkdir /user/hadoop #根据自己的情况调整
[hadoop@hadoop00 ~]$ hdfs dfs -put /usr/hadoop/etc/hadoop/ /input
[hadoop@hadoop00 ~]$ hdfs dfs -ls /input
[hadoop@hadoop00 ~]$ hadoop jar /usr/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar grep /input output 'dfs[a-z.]+'
(WordCount
[hadoop@hadoop00 ~]$ hadoop jar /usr/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input output
#说明:output文件夹如已经存在则需要删除或指定其他文件夹。)
[hadoop@hadoop00 ~]$ hdfs dfs -cat output/*
[hadoop@hadoop00 ~]$ cd /usr/hadoop/etc/hadoop/
[root@hadoop00 ~]# cp mapred-site.xml.template mapred-site.xml
[hadoop@hadoop00 ~]$ vi mapred-site.xml
(添加如下内容)
[hadoop@hadoop00 ~]$ vi yarn-site.xml
(添加如下内容)
[hadoop@hadoop00 ~]$ start-yarn.sh
(停止yarn stop-yarn.sh)
[hadoop@hadoop00 ~]$ jps
4918 ResourceManager
1663 NameNode
1950 SecondaryNameNode
5010 NodeManager
5218 Jps
1759 DataNode
配置好如上配置再运行mapReduce程序时即是yarn中运行
(等同于 hdfs dfs -mkdir -p /user/hadoop/input)
[hadoop@hadoop00 ~]$ hdfs dfs -ls
(等同与 hdfs dfs -ls /user/hadoop/input)
[hadoop@hadoop00 ~]$ hdfs dfs -rm -r input