安装
brew install hadoop
Linux用户可以直接下载tar包,解压运行
https://apache.claz.org/hadoop/common/hadoop-3.3.0/hadoop-3.3.0.tar.gz
配置本地登陆
cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
**系统配置(仅Mac需要)
系统->共享里的:
配置hadoop四个文件
hadoop-env.sh
添加java home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
mapred-site.xml
添加
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9010</value>
</property>
</configuration>
hdfs-site.xml
添加
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
yarn-site.xml(修改告警阀值,默认95%,非必须)
添加
<property>
<name>yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage</name>
<value>98.0</value>
</property>
core-site.xml
添加
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/Cellar/hadoop/3.3.0/data/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
初始化namenode
hadoop namenode -format
启动
/usr/local/Cellar/hadoop/3.3.0/sbin/start-all.sh
查看(node,yarn)
http://localhost:8042/node
http://localhost:9870/
应用
创建目录和文件
hadoop fs -mkdir -p /input
echo 'hello word' > word.txt
hadoop fs -put word.txt /input/
使用hadoop 示例:
统计文件中word的数量
hadoop jar /usr/local/Cellar/hadoop/3.3.0/libexec/share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-3.3.0-sources.jar org.apache.hadoop.examples.WordCount /input/word.txt /input/out/word-out
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/100323.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...