Create Hadoopuser
(root@…): <== พิมพ์คำสั่งขณะใช้ root user
sudo -i
(root@…): adduser hadoopuser
(root@…): usermod -aG sudo hadoopuser
(root@…): su hadoopuser
หลังจากนี้จะอยู่ในสถานะ (hadoopuser@…)
Install Java
sudo apt-get install openjdk-8-jdk
java -version
Install ssh and pdsh
sudo apt-get install ssh
sudo apt-get install pdsh
Download hadoop
cd
mkdir downloads
cd downloads
wget https://downloads.apache.org/hadoop/common/hadoop-3.3.0/hadoop-3.3.0.tar.gz
tar -xzvf hadoop-3.3.0.tar.gz
mv hadoop-3.3.0 /home/hadoopuser/hadoop
Setting Hadoop
cd /home/hadoopuser/hadoop/etc/hadoop
เอาไฟล์จากโฟลเดอร์ hadoop/etc/hadoop ก๊อบปี้ใส่เข้าไปได้เลย หรือจะก๊อบโค้ดตรงนี้แก้ไขใส่ทีละไฟล์ก็ได้
core-site.xml
sudo nano core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
hdfs-site.xml
sudo nano hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>/home/hadoopuser/hadoop/data/namenode</value>
</property>
<property>
<name>dfs.datanode.name.dir</name>
<value>/home/hadoopuser/hadoop/data/datanode</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
mapred-site.xml
sudo nano mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.application.classpath</name>
<value>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*</value>
</property>
</configuration>
yarn-site.xml
sudo nano yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.env-whitelist</name>
<value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value>
</property>
</configuration>