伪分布环境搭建

1. 进⼊/opt/install/hadoop/etc/hadoop⽬录
2. 修改hadoop-env.sh:注释第25⾏并插⼊:export JAVA_HOME=/opt/install/jdk
3. 修改core-site.xml:在<configuration>与</configuration>之间添加以下内容:
<!-- 指定 HDFS 中 NameNode 的地址 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop101:9000</value>
</property>
<!-- 指定 hadoop 运行时产生文件的存储目录 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/install/hadoop/data/tmp</value>
</property>
4. 修改hdfs-site.xml:在<configuration>与</configuration>之间添加以下内容:
<!-- 指定 HDFS 副本的数量 -->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<!-- 设置SecondaryNamenode主机和端口 -->
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>hadoop101:50090</value>
</property>
5. 修改slaves⽂件:添加 hadoop101
6. 格式化 NameNode:
  1. cd /opt/install/hadoop
  2. bin/hdfs namenode -format【注意只需执⾏⼀次】
7. 启动 NameNode:sbin/hadoop-daemon.sh start namenode,查看是否启动成功:jps
8. 启动 DataNode:sbin/hadoop-daemon.sh start datanode,查看是否启动成功:jps
9. 通过windows的浏览器查看服务:http://hadoop101:50070/ 需要修改hosts:C:\Windows\System32\drivers\etc\hosts⽂件中添加 192.168.18.101 hadoop101
10. 在 hdfs ⽂件系统上创建⼀个 input ⽂件夹:bin/hdfs dfs -mkdir -p /user/hadoop/input
11. 将测试⽂件上传到hdfs⽂件系统上:
  1. 在/opt/install/hadoop⽬录下创建⽂件⽬录 mkdir wcinput
  2. 创建⽂件 vim wcinput/wc.input
  3. bin/hdfs dfs -put wcinput/wc.input /user/hadoop/input/
12. 查看hdfs⽂件系统中指定⽬录中的⽂件信息:bin/hdfs dfs -ls /user/hadoop/input
13. 查看hdfs⽂件系统中指定⽂件的内容:bin/hdfs dfs -cat /user/hadoop/input/wc.input
14. 运⾏ mapreduce 程序:bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-
2.6.0.jar wordcount /user/hadoop/input/ /user/hadoop/output
15. 查看输出结果:
bin/hdfs dfs -ls /user/hadoop/output
bin/hdfs dfs -cat /user/hadoop/output/*
16. 将测试⽂件内容下载到本地:
mkdir wcoutput
bin/hdfs dfs -get /user/hadoop/output/* ./wcoutput
cat wcoutput/*
17. 删除输出结果:
bin/hdfs dfs -rm -r /user/hadoop/output
18. 停⽌namenode和datanode
hadoop-daemon.sh stop namenode
hadoop-daemon.sh stop datanode
jps查看
19. 清理本地⽂件然后停机做快照
posted @ 2023-11-29 18:03  韩世康  阅读(5)  评论(0编辑  收藏  举报