配置Hadoop环境变量
时间: 2023-12-25 19:20:18 浏览: 87
配置Hadoop环境变量的步骤如下:
1. 打开终端,输入以下命令创建一个新的Hadoop用户组和用户:
```
sudo addgroup hadoop
sudo adduser --ingroup hadoop hduser
```
2. 下载并解压缩Hadoop安装包,将其放置在/opt目录下:
```
cd /opt
sudo wget https://www.apache.org/dist/hadoop/common/hadoop-3.2.2/hadoop-3.2.2.tar.gz
sudo tar -xzf hadoop-3.2.2.tar.gz
sudo mv hadoop-3.2.2 hadoop
```
3. 配置Hadoop环境变量,打开/etc/profile文件并添加以下内容:
```
export HADOOP_HOME=/opt/hadoop
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
```
4. 使更改生效
```
source /etc/profile
```
5. 检查Hadoop环境变量是否设置正确
```
echo $HADOOP_HOME
```
如果输出/opt/hadoop,则说明Hadoop环境变量已正确设置。
阅读全文