搭建hdfs伪分布式模式

1.在上一篇单机模式的基础上配置xml

修改core-site.xml,

vi etc/hadoop/core-site.xml

<configuration>
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
    </property>
</configuration>


修改hdfs-site.xml,

vi etc/hadoop/hdfs-site.xml

<configuration>
  <property>
    <name>dfs.replication</name>
    <value>1</value>
  </property>
</configuration>


然后本地启动MapReduce任务。先格式化文件系统


  $ ./bin/hdfs namenode -format


红线部分成功格式化

启动守护进程

./sbin/start-dfs.sh


用jps命令来查看节点守护进程启动情况


一些常用的命令。大概与linux相同


比如ls命令:  ./bin/hdfs dfs -ls /

创建hdfs文件系统的目录:
./bin/hdfs dfs -mkdir /user
./bin/hdfs dfs -mkdir /user/hadoop
然后我们将之前input文件夹拷贝到hdfs文件系统中:
./bin/hdfs dfs -put input /user/hadoop
我们可以使用如下命令查看,是否将input文件夹拷贝到了hdfs文件系统中:
./bin/hdfs dfs -ls /user/hadoop/input/*



删除单机模式下创建的input output

rm -rf input output

然后运行

./bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.0.0.jar wordcount input output



然后查看运行结果:

./bin/hdfs dfs -cat /user/hadoop/output/*


与单机下运行的结果一样

接下来去研究真正的分布式模式。






猜你喜欢

转载自blog.csdn.net/dabingshui/article/details/79160950
今日推荐