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
參考文章: