The Apache™ Hadoop® project develops open-source software for reliable, scalable, distributed computing.
The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models.
It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-availability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-available service on top of a cluster of computers, each of which may be prone to failures.
发行版本
官方安装配置:
https://hadoop.apache.org/docs/r1.0.4/cn/quickstart.html
macOS 安装 Hadoop:使用 brew
brew 安装、使用方法可见:https://blog.csdn.net/lovechris00/article/details/121613647
brew install hadoop
如果出现报错:
Error: Cannot install hadoop because conflicting formulae are installed.
yarn: because both installyarnbinaries
Pleasebrew unlink yarnbefore continuing.
根据提示执行命令即可:
brew unlink yarn
安装成功,查看版本
# 查看 hadoop 安装目录
brew info hadoop
根据你的环境变量文件,编辑
vim ~/.zshrc
# vim ~/.bash_profile
# Hadoop
export HADOOP_HOME=/usr/local/Cellar/hadoop/3.3.4/libexec
export PATH=$PATH:HADOOP_HOME
使环境变量在当前窗口生效。
你也可以使用 ctrl + tab 新开一个终端窗口。
source ~/.zshrc
# source ~/.bash_profile
cd /usr/local/Cellar/hadoop/3.3.3/libexec/etc/hadoop
ls
修改配置文件
vim core-site.xml
进入文件后加入:
<configuration>
<property>
<name>fs.defaultFSname>
<value>hdfs://localhost:8020value>
property>
<property>
<name>hadoop.tmp.dirname>
<value>file:/usr/local/Cellar/hadoop/tmpvalue>
property>
configuration>
配置副本数
vim hdfs-site.xml
<configuration>
<property>
<name>dfs.replicationname>
<value>1value>
property>
<property>
<name>dfs.permissionsname>
<value>falsevalue>
property>
<property>
<name>dfs.namenode.name.dirname>
<value>file:/usr/local/Cellar/hadoop/tmp/dfs/namevalue>
property>
<property>
<name>dfs.datanode.data.dirname>
<value>file:/usr/local/Cellar/hadoop/tmp/dfs/datavalue>
property>
configuration>
vim mapped-site.xml
<configuration>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
<property>
<name>mapred.job.trackername>
<value>localhost:9010value>
property>
<property>
<name>yarn.app.mapreduce.am.envname>
<value>HADOOP_MAPRED_HOME=/usr/local/Cellar/hadoop/3.3.3/libexecvalue>
property>
<property>
<name>mapreduce.map.envname>
<value>HADOOP_MAPRED_HOME=/usr/local/Cellar/hadoop/3.3.3/libexecvalue>
property>
<property>
<name>mapreduce.reduce.envname>
<value>HADOOP_MAPRED_HOME=/usr/local/Cellar/hadoop/3.3.3/libexecvalue>
property>
configuration>
vim yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
<property>
<name>yarn.resourcemanager.addressname>
<value>localhost:9000value>
property>
<property>
<name>yarn.scheduler.capacity.maximum-am-resource-percentname>
<value>100value>
property>
configuration>
$HADOOOP_HOME/etc/hadoop/hadoop-env.sh 中配置 JAVA_HOME
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_331.jdk/Contents/Home
初始化 HDFS NameNode
hdfs namenode -format
1、启动
cd $HADOOP_HOME
./start-dfs.sh
2、在浏览器中输入url:
http://localhost:9870/dfshealth.html#tab-overview
http://localhost:9870
看到以下界面启动成功
如果打不开这个页面,而且又启动了,需要在hadoop下/etc/hadoop/hadoop-env.sh文件下第52行后面添加下方配置:
cd /usr/local/Cellar/hadoop/3.3.1/libexec/etc
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native"
3、停止hadoop服务
./stop-yarn.sh
4、启动yarn服务
cd /usr/local/Cellar/hadoop/3.3.1/libexec/sbin
./start-yarn.sh
在浏览器中输入 http://localhost:8088/cluster 看到一下界面则启动成功
5、停止yarn服务
./stop-yarn.sh
hdfs dfsadmin -report
启动 yarn
cd $HADOOP_HOME
../sbin/start-yarn.sh
浏览器输入 http://localhost:8088,出现下面界面则代表启动成功