hadoop 单节点模式安装
Hadoop单节点模式安装简化了安装过程,通常用于测试或开发环境。以下是在Ubuntu系统上进行Hadoop单节点模式安装的步骤和示例配置:
- 安装Java
sudo apt update
sudo apt install default-jdk
- 配置环境变量
echo "export JAVA_HOME=$(readlink -f /usr/bin/java | sed 's:/bin/java::')" | sudo tee -a /etc/profile
source /etc/profile
- 下载并解压Hadoop
wget https://downloads.apache.org/hadoop/common/hadoop-3.2.2/hadoop-3.2.2.tar.gz
tar -xzf hadoop-3.2.2.tar.gz
sudo mv hadoop-3.2.2 /usr/local/hadoop
- 配置Hadoop环境变量
echo "export HADOOP_HOME=/usr/local/hadoop" | sudo tee -a /etc/profile
echo "export PATH=\$PATH:\$HADOOP_HOME/bin:\$HADOOP_HOME/sbin" | sudo tee -a /etc/profile
source /etc/profile
配置Hadoop单节点模式
编辑
/usr/local/hadoop/etc/hadoop/hadoop-env.sh
,设置JAVA_HOME
:
export JAVA_HOME=/usr/lib/jvm/default-java
编辑/usr/local/hadoop/etc/hadoop/core-site.xml
,添加:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
编辑/usr/local/hadoop/etc/hadoop/hdfs-site.xml
,添加:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
- 格式化HDFS
hdfs namenode -format
- 启动NameNode和DataNode
hadoop-daemon.sh start namenode
hadoop-daemon.sh start datanode
完成以上步骤后,Hadoop单节点模式应该已经成功安装并运行。可以通过运行Hadoop自带的示例程序来验证安装:
hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.2.2.jar wordcount /usr/local/hadoop/etc/hadoop /output
评论已关闭