6、Hadoop 2.6.0 執行
阿新 • • 發佈:2018-12-19
執行方式
- Local (Standalone) Mode
- Pseudo-Distributed Mode
- Fully-Distributed Mode
Standalone Operation
$ sudo mkdir input
$ sudo cp etc/hadoop/*.xml input
$ sudo bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0.jar grep input output 'dfs[a-z.]+'
$ cat output/*
Pseudo-Distributed Operation
Configuration
Use the following:
etc/hadoop/core-site.xml:
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://hw-TM1612:8020</value> </property> </configuration> <configuration> <property> <name>hadoop.tmp.dir</name> <value>/opt/hadoop-2.6.0-cdh5.5.0/data/tmp</value> </property> </configuration>
etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
sudo bin/hdfs namenode -format ##格式化namenode sudo sbin/hadoop-daemon.sh start namenode ##啟動namenode sudo sbin/hadoop-daemon.sh start datanode ##啟動datanode jps sudo bin/hdfs dfs -mkdir -p /user/hw/ ##建立目錄 sudo bin/hdfs dfs -ls -R / ##迴圈列出目錄 -R sudo bin/hdfs dfs -mkdir -p /user/hw/mapreduce/wordcount/input ##建立hdfs檔案 sudo bin/hdfs dfs -put wcinput/wc.input /user/hw/mapreduce/wordcount/input ## 上傳檔案 sudo bin/hdfs dfs -ls /user/hw/mapreduce/wordcount/input sudo bin/hdfs dfs -cat /user/hw/mapreduce/wordcount/input/wc.input ##檢視 sudo bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.5.0.jar wordcount /user/hw/mapreduce/wordcount/input/ /user/hw/mapreduce/wordcount/output ##hdfs下執行 sudo bin/hdfs dfs -cat /user/hw/mapreduce/wordcount/output/part-r-00000
- 預設web埠號:50070
YARN on Single Node
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>
sudo gedit etc/hadoop/yarn-env.sh
sudo gedit etc/hadoop/yarn-site.xml
sudo gedit etc/hadoop/slaves ##更改主機名
sudo sbin/yarn-daemon.sh start resourcemanager ##啟動resourcemanager
jps
sudo sbin/yarn-daemon.sh start nodemanager ##啟動nodemanager
jps
sudo gedit etc/hadoop/mapred-env.sh
sudo mv etc/hadoop/mapred-site.xml.template etc/hadoop/mapred-site.xml
sudo gedit etc/hadoop/mapred-site.xml
sudo bin/hdfs dfs -rm -r /user/hw/mapreduce/wordcount/output
sudo bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.5.0.jar wordcount /user/hw/mapreduce/wordcount/input/ /user/hw/mapreduce/wordcount/output
- 預設web埠號:8088
啟動歷史伺服器
sudo sbin/mr-jobhistory-daemon.sh start historyserver