要在CentOS 7上安裝Hadoop,可以按照以下步驟進行操作:
安裝Java Development Kit(JDK):
sudo yum install java-1.8.0-openjdk-devel
創建Hadoop用戶:
sudo adduser hadoop
sudo passwd hadoop
下載和解壓縮Hadoop:
/opt
目錄下創建一個新目錄:sudo mkdir /opt/hadoop
cd /opt/hadoop
sudo wget https://downloads.apache.org/hadoop/common/hadoop-3.3.1/hadoop-3.3.1.tar.gz
sudo tar -xzvf hadoop-3.3.1.tar.gz
hadoop
:sudo mv hadoop-3.3.1 hadoop
配置環境變量:
/etc/profile
文件:sudo vi /etc/profile
export HADOOP_HOME=/opt/hadoop/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
source /etc/profile
配置Hadoop:
cd /opt/hadoop/hadoop/etc/hadoop
hadoop-env.sh
文件:sudo vi hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
配置Hadoop的核心文件:
core-site.xml
文件:sudo vi core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
配置Hadoop的HDFS文件系統:
hdfs-site.xml
文件:sudo vi hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
配置Hadoop的YARN資源管理器:
yarn-site.xml
文件:sudo vi yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
配置Hadoop的MapReduce框架:
mapred-site.xml
文件:sudo vi mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
設置Hadoop的數據目錄權限:
sudo mkdir -p /opt/hadoop/data/hdfs/namenode
sudo mkdir -p /opt/hadoop/data/hdfs/datanode
sudo chown -R hadoop:hadoop /opt/h