run container
docker run -it --name hadoop -p 9800:9000 -p 9888:8088 -p 9002:22 -p 9870:9870 -p 9864:9864 -v /d/hadoop:/root ubuntu:jammy /bin/bash
update system
apt update
apt upgrade -y
config ssh
passwd
apt -y install openssh-server nano
nano /etc/ssh/sshd_config
# sshd_config file
PermitRootLogin yes
# StrictModes yes
# MaxAuthTries 6
# MaxSessions 10
nano /root/.bashrc
# .bashrc
nohup /etc/init.d/ssh start &
download hadoop
apt -y install default-jdk wget
wget https://dlcdn.apache.org/hadoop/common/hadoop-3.3.5/hadoop-3.3.5.tar.gz
tar -vxf hadoop-3.3.5.tar.gz
config hadoop
nano hadoop-3.3.5/etc/hadoop/hadoop-env.sh
# hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/default-java
nano hadoop-3.3.5/etc/hadoop/core-site.xml
# core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
mkdir ~/data
nano hadoop-3.3.5/etc/hadoop/hdfs-site.xml
# hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
<property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/root/data</value>
</property>
</configuration>
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
service ssh restart
chmod 750 $HOME
init node
hadoop-3.3.5/bin/hdfs namenode -format
hadoop-3.3.5/bin/hdfs datanode -format
start hadoop
cd ~
nano start_hadoop.sh
# start_hadoop.sh
export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root
/root/hadoop-3.3.5/sbin/start-all.sh
check
apt install -y curl
curl -i 'http://localhost:9870/webhdfs/v1?op=LISTSTATUS'
mkdir in hdfs
hadoop-3.3.5/bin/hdfs dfs -mkdir -p /user/data
change mod in hdfs
hadoop-3.3.5/bin/hdfs dfs -chmod 777 /user/data
put folder to hdfs
hadoop-3.3.5/bin/hdfs dfs -put -f Standard_Backtest_Data /user/data/