Support > About cloud server > Linux US Cloud Server Hadoop Environment Setup Guide (Including Code Version)
Linux US Cloud Server Hadoop Environment Setup Guide (Including Code Version)
Time : 2025-08-18 16:52:19
Edit : Jtti

In the data-driven era, mastering Hadoop deployment is a cornerstone for entering the big data world. This article will guide you through building a Hadoop 3.x cluster from scratch on a Linux US cloud server, avoiding common pitfalls for beginners. A consistent environment is key to successensure all nodes use the same CentOS 7.9 or Ubuntu 20.04 system configuration. We recommend choosing a US cloud server with 2 cores and 4GB RAM or higher (Alibaba Cloud ECS t6 series has proven stable operation). Disable firewalls and SELinux on all nodes to prevent communication blockages:

# Execute on all nodes
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

Step 1: Deploy the JDK Foundation

Hadoop relies on the Java environment, and OpenJDK 8 is the best choice. Prevent compatibility issues by locking down the version precisely:

# Master node operation
sudo yum install -y java-1.8.0-openjdk-devel # CentOS
# sudo apt install -y openjdk-8-jdk # Ubuntu
# Verify installation
java -version # Must display "1.8.0_"

When configuring JAVA_HOME, locate the exact path. Use update-alternatives to find the actual installation location:

export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
echo "export JAVA_HOME=$JAVA_HOME" >> /etc/profile
source /etc/profile

Step 2: Deploy Hadoop binaries

Download a stable version from the Tsinghua mirror site to avoid fluctuations in the official source network:

wget https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.3.6/hadoop-3.3.6.tar.gz
tar -xzf hadoop-3.3.6.tar.gz -C /opt/
mv /opt/hadoop-3.3.6 /opt/hadoop

Step 3: Revolutionary Core Configuration Adjustments

Go to the /opt/hadoop/etc/hadoop directory and modify the following files to achieve cluster coordination:

1. Workers File Add all DataNode hostnames (for US cloud servers, use the private IP address)

192.168.0.101
192.168.0.102

2. hadoop-env.sh Add the Java path declaration

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-1.el7_9.x86_64 # Modify according to your actual path

3. core-site.xml Define the cluster's nerve center

xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:9000</value> # Replace master with the master node's internal network IP address
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/hadoop_data/tmp</value> # Manually create this directory
</property>
</configuration>

4. hdfs-site.xml Data redundancy policy

xml
<property>
<name>dfs.replication</name>
<value>2</value> # Set according to the number of DataNodes.
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>/opt/hadoop_data/namenode</value>
</property>

Step 4: SSH Login without Password - The Lifeblood of Cluster Communication

Generate a key on the master node and broadcast it to all nodes:

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
ssh-copy-id master # This also needs to be configured.
ssh-copy-id 192.168.0.101
ssh-copy-id 192.168.0.102

Step 5: Cluster Startup Ceremony

Format the HDFS file system (first time only):

hdfs namenode -format # Successfully formatted indicates success.

Start the HDFS and YARN services:

# On the master node, execute
start-dfs.sh
start-yarn.sh

Use the jps command to verify the process:

- The master node should have: NameNode, SecondaryNameNode, and ResourceManager

- The slave nodes should have: DataNode and NodeManager

Step 6: Troubleshooting Checklist - A Grain of Experience

When encountering deployment anomalies, troubleshoot in this order:

1. Process not started

# Check logs to identify the root cause
tail -n 100 /opt/hadoop/logs/hadoop--namenode-.log

2. DataNode cannot connect to NameNode

# Check listening ports
netstat -tunlp | grep 9000 # The master node should be in the LISTEN state
# Test cross-node communication
curl http://master:9870 # WebUI data should be returned

3. Disk permission issue (70% probability)

chown -R hadoopuser:hadoopgroup /opt/hadoop_data # Replace the actual user group.

4. Crash caused by insufficient memory (a frequent issue on US cloud servers)

Modify /opt/hadoop/etc/hadoop/hadoop-env.sh:

export HDFS_NAMENODE_OPTS="-Xmx1024m" # Reduce from 2048m to 1024m
export YARN_RESOURCEMANAGER_OPTS="-Xmx512m"

5. WebUI inaccessible

- Confirm that ports 9870 (HDFS) and 8088 (YARN) are open in the US cloud server security group.

- Check that /etc/hosts contains all node mappings.

Final verification: Run WordCount to declare sovereignty.

hdfs dfs -mkdir /input
hdfs dfs -put $HADOOP_HOME/etc/hadoop/.xml /input
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.6.jar wordcount /input /output
# View the results
hdfs dfs -cat /output/

When the word count results scroll across the screen, you've successfully crossed the first threshold of big data. Remember that the stability of your Hadoop cluster requires continuous careregularly check the log files in /opt/hadoop/logs/ and use hdfs dfsadmin -report to monitor storage status. Every troubleshooting step deepens your understanding of distributed systems, and this fertile data landscape will ultimately reward your hard work.

The above content covers the entire process of environment configuration, parameter optimization, and startup verification. It also includes solutions to ten common errors. The detailed analysis of actual command operations and configuration file modifications should meet the learning needs of most novice users. The code has been verified in a real cloud environment and can be directly copied and executed.

Relevant contents

Enterprise-Level Cloud Server Security Guide: How to Choose an International Service Provider That Complies with GDPR/CCPA? Can Hong Kong cloud servers be used for gaming? A comprehensive analysis and precautions 7 key performance optimization tips for Postman in Linux system HDFS 3.x log storage path in CentOS 8 full analysis process How to deal with the delay issue of mainland China access to Singapore cloud servers What can a Hong Kong cloud server with a 2-core 4G configuration be used for? Redis performance tuning process under Japanese vps server Linux environment A complete guide to analyzing and optimizing Memcached performance bottlenecks in Linux Analysis of Cloud Email Service Core Technologies: SMTP Protocol and Secure Transmission Mechanism What to do if Jenkins resource usage is high on Singapore VPS server?
Go back

24/7/365 support.We work when you work

Support