Table of Contents
0. 安装版本
hadoop version:2.10.0
run mode: Pseudo-Distributed
1. 安装依赖
-
Java™ must be installed. Recommended Java versions are described at HadoopJavaVersions.
-
ssh must be installed and sshd must be running to use the Hadoop scripts that manage remote Hadoop daemons.
2. 安装HDFS
2.1 配置文件
Use the following:
etc/hadoop/core-site.xml:
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://localhost:9000</value> </property> </configuration>
etc/hadoop/hdfs-site.xml:
<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
2.2 执行启动命令
-
Format the filesystem:
$ bin/hdfs namenode -format
默认情况下namenode数据会存放在临时目录 /tmp/hadoop-adore.chen/dfs/name 下方,电脑重启后丢失。所以修改配置文件
hdfs-site.xml 同理增加数据节点的存放目录信息。
修改后的配置文件hdfs-site.xml如下:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/opt/hadoop-2.10.0/dfs/name/</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/opt/hadoop-2.10.0/dfs/data/</value>
</property>
</configuration>
/opt/hadoop-2.10.0/dfs 是我新建的存放这些数据的目录。
2. Start NameNode daemon and DataNode daemon:
$ sbin/start-dfs.sh
The hadoop daemon log output is written to the $HADOOP_LOG_DIR directory (defaults to $HADOOP_HOME/logs).
Browse the web interface for the NameNode; by default it is available at:
N ameNode - http://localhost:50070/
访问地址栏若是能成功打开,恭喜你安装hdfs成功了。若是不成功,先命令行输入jps查看namenode、datanode、secondary 启动是否成功。我有次就碰到namenode没有启动成功,使用lsof -i:9000查看端口被谁占用。
3 安装yarn
-
Configure parameters as follows:etc/hadoop/mapred-site.xml:
cp etc/hadoop/mapred-site.xml.template etc/hadoop/mapred-site.xml <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
etc/hadoop/yarn-site.xml:
<configuration> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration>
-
Start ResourceManager daemon and NodeManager daemon:
$ sbin/start-yarn.sh
-
Browse the web interface for the ResourceManager; by default it is available at:
ResourceManager - http://localhost:8088/
浏览器若能正常显示,恭喜你安装成功。
4 关闭服务器
$ sbin/stop-yarn.sh
$ sbin/stop-dfs.sh
参考文章: