1使用ppa/源方式安装JDK
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update
sudo apt-get install oracle-java7-installersudo update-java-alternatives -s java-7-oraclejava -version
2用户环境准备:
》vi /etc/hostname
HOSTNAME=cookocean
》vi /etc/hosts
127.0.0.1 localhost
104.131.182.5 cookocean cookocean
》sudo addgroup hadoop
》sudo adduser -ingroup hadoop hadoop
》sudo /etc/sudoers
在root ALL=(ALL:ALL) ALL这一行下添加
hadoop ALL=(ALL:ALL) ALL
》 sudo apt-get update
》 sudo apt-get upgrade
》sudo apt-get install ssh openssh-server
》su - hadoop
》ssh-keygen -t rsa -P ""
进入~/.ssh/目录下:
cd /home/hadoop/.ssh
将此目录下的id_rsa.pub追加到authorized_keys授权文件中:
cat id_rsa.pub >> authorized_keys
3.安装hadoop2
http://apache.fayea.com/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
4.修改环境配置文件
hdfs.site.xml
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/hadoop-2.7.3/hdfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/hadoop-2.7.3/hdfs/data</value>
</property>
core-site.xml
<property> <name>fs.default.name</name> <value>hdfs://cookocean: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>
格式化hdfs
hdfs namenode -format
只需要执行一次即可,如果在hadoop已经使用后再次执行,会清除掉hdfs上的所有数据
6、启动hadoop
首先进入 /usr/local/hadoop/目录
cd /usr/local/hadoop/
经过上文所描述配置和操作后,下面就可以启动这个单节点的集群
执行启动命令:
sbin/start-dfs.sh
执行该命令时,如果有yes /no提示,输入yes,回车即可。
接下来,执行:
sbin/start-yarn.sh