12.4 hdfs总结

启动hdfs 需要在namenode 节点 上 s11    

启动yarn 需要在resourceManager 节点上

namenode, resourceManager 都需要在整个集群中都是可以无密登录的。

格式化文件系统:(格式化成功的条件是 删除了之前文件系统的残留文件  /tmp  ${HADOOP_HOME}/logs )

hadoop namenode -format

hdfs:  在namenode 节点上

  start-dfs.ssh  stop-dfs.sh

yarn: 在resourceManager 节点上。

  start-yarn.sh    stop-yarn.sh

  hdfs 的设计适合一次写入,多次读出的场所。不支持文件的修改。适合用来数据分析。
 
 
 
分别启动:  hdfs 组件
hadoop-daemon.sh  start|stop namenode|datanode|secondarynamenode
 
启动yarn 组件。
yarn-daemon.sh start|stop resourcemanager| nodemanager

hdfs的配置

[core-site.xml]

<!-- 指定HDFS中NameNode的地址 -->
<property>
<name>fs.defaultFS</name>
        <value>hdfs://s11:9000</value>
</property>
<!-- 指定hadoop运行时产生文件的存储目录 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/soft/hadoop/data/tmp</value>
</property>

  

[hdfs-site.xml]

<configuration>
    <property>
        <name>dfs.replication</name>
        <value>3</value>
    </property>
    <property>
        <name>dfs.namenode.secondary.http-address</name>
        <value>s13:50090</value>
    </property>
</configuration>

[slaves]

s11
s12
s13

yarn的配置

[yarn.xml]

<configuration>
<!-- Site specific YARN configuration properties -->
<!-- reducer获取数据的方式 -->
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
<!-- 指定YARN的ResourceManager的地址 -->
    <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>s12</value>
    </property>
</configuration>

 

[mapred.-sitexml]

<configuration>
    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
</configuration>

hdfs 文件系统的一些常见命令:

hadoop fs -ls /

hadoop fs -mkdir /user/ljs/input

hadoop fs -moveFromLocal test.txt /user/ljs/input

hadoop fs -appendToFile cool.txt /user/ljs/input/test.txt

hadoop fs -cat /user/ljs/input/test.txt

hadoop fs -copyFromLocal 本地path HDFS_PATH

hadoop fs -cp HDFS_PATH1 HDFS_PATH2

-get

-getmerge

-rmr

原文地址:https://www.cnblogs.com/lijins/p/10065856.html