2024年最新大数据测试:构建Hadoop和Spark分布式HA运行环境!
# 安装JDK
sudo apt-get update
sudo apt-get install openjdk-8-jdk -y
# 配置环境变量
echo "export JAVA_HOME=$(readlink -f /usr/bin/java | sed 's:/bin/java::')" | sudo tee -a /etc/profile
source /etc/profile
# 验证JDK安装
java -version
# 安装Zookeeper
sudo apt-get install zookeeperd -y
# 启动Zookeeper服务
sudo service zookeeperd start
# 验证Zookeeper安装
echo stat | nc localhost 2181
# 安装Hadoop
wget https://downloads.apache.org/hadoop/common/hadoop-3.2.2/hadoop-3.2.2.tar.gz
sudo tar -xzf hadoop-3.2.2.tar.gz -C /usr/local
sudo ln -s /usr/local/hadoop-3.2.2 /usr/local/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安装
hadoop version
# 配置Hadoop
sudo cp /usr/local/hadoop/etc/hadoop/hadoop-env.sh /usr/local/hadoop/etc/hadoop/hadoop-env.sh.bak
echo "export JAVA_HOME=$(readlink -f /usr/bin/java | sed 's:/bin/java::')" | sudo tee -a /usr/local/hadoop/etc/hadoop/hadoop-env.sh
# 配置hdfs-site.xml
echo "
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.nameservices</name>
<value>mycluster</value>
</property>
<property>
<name>dfs.ha.namenodes.mycluster</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
<value>node1:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>node2:8020</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.n
评论已关闭