Server | Master | Worker1 | Worker2 |
---|---|---|---|
OS | CentOS 8.2 | CentOS 8.2 | CentOS 8.2 |
Disk | 30G | 30G | 30G |
MEM | 14G | 14G | 14G |
CPU | 4.Core | 4.Core | 4.Core |
- Hadoop Master IP : 10.0.0.5
- Hadoop Worker1 IP : 10.0.0.6
- Hadoop Worker2 IP : 10.0.0.7
[root@hadoop-master ~]# cat /etc/hosts 10.0.0.5 hadoop-master 10.0.0.6 hadoop-worker 10.0.0.7 hadoop-worker2
[root@hadoop-master ~]# useradd -m hadoop [root@hadoop-master ~]# passwd hadoop Changing password for user hadoop. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. [root@hadoop-master ~]# usermod -G wheel hadoop
[hadoop@hadoop-master ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): Created directory '/home/hadoop/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/hadoop/.ssh/id_rsa. Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
[hadoop@hadoop-master ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@hadoop-worker [hadoop@hadoop-master ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@hadoop-worker2 [hadoop@hadoop-master ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@hadoop-master
[root@hadoop-master ~]# yum install -y java-1.8.0-openjdk-devel.x86_64 [root@hadoop-master ~]# [root@hadoop-master ~]# javac -version javac 1.8.0_275
cd /usr/local; \ sudo wget http://apache.mirror.cdnetworks.com/hadoop/common/hadoop-3.3.0/hadoop-3.3.0.tar.gz; \ sudo tar xzvf hadoop-3.3.0.tar.gz; \ sudo rm -rf hadoop-3.3.0.tar.gz; \ sudo mv hadoop-3.3.0 hadoop [hadoop@hadoop-master local]$ ls bin etc games hadoop include lib lib64 libexec sbin share src
[root@hadoop-master ~]# vim /etc/profile export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64" export HADOOP_HOME="/usr/local/hadoop" export PATH="$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:" [root@hadoop-master ~]# source /etc/profile [root@hadoop-master ~]# [root@hadoop-master ~]# echo $JAVA_HOME /usr/bin/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64 [root@hadoop-master ~]# echo $HADOOP_HOME /usr/local/hadoop [root@hadoop-master ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://hadoop-master:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/local/hadoop/tmp</value> </property> </configuration>
<configuration> <property> <name>dfs.replication</name> <value>3</value> -> 기본 1, 3이어야 full distribute </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/usr/local/hadoop/namenode</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/usr/local/hadoop/datanode</value> </property> <property> <name>dfs.permissions.enabled</name> <value>false</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> <property> <name>dfs.namenode.http.address</name> <value>hadoop-master:50070</value> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>hadoop-worker:50090</value> </property> </configuration>
<configuration> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.resourcemanager.hostname</name> <value>hadoop-master</value> </property> <property> <name>yarn.nodemanager.vmem-check-enabled</name> <value>false</value> </property> <property> <name>yarn.resourcemanager.address</name> <value>hadoop-master:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>hadoop-master:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>hadoop-master:8031</value> </property> </configuration>
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64" export HADOOP_HOME="/usr/local/hadoop" export HADOOP_CONF_DIR="$HADOOP_HOME/etc/hadoop" export HADOOP_LOG_DIR="$HADOOP_HOME/logs" export HADOOP_PID_DIR="$HADOOP_HOME/pids"
[root@hadoop-master hadoop]# cd /usr/local/hadoop; \ > mkdir namenode; \ > mkdir datanode
# worker 1로 전송 scp -r /usr/local/hadoop hadoop-worker:/usr/local # slave2 /usr/local로 전송 [hadoop@hadoop-master root]$ scp -r /usr/local/hadoop hadoop@hadoop-worker:/usr/local [hadoop@hadoop-master root]$ scp -r /usr/local/hadoop hadoop@hadoop-worker2:/usr/local
hadoop-master hadoop-worker hadoop-worker2
hadoop-master
[root@hadoop-master hadoop]# hadoop namenode -format WARNING: Use of this script to execute namenode is deprecated. WARNING: Attempting to execute replacement "hdfs namenode" instead. WARNING: /usr/local/hadoop/pids does not exist. Creating. WARNING: /usr/local/hadoop/logs does not exist. Creating. 2021-03-09 04:37:15,754 INFO namenode.NameNode: STARTUP_MSG: / STARTUP_MSG: Starting NameNode STARTUP_MSG: host = hadoop-master/10.0.0.5 STARTUP_MSG: args = [-format] STARTUP_MSG: version = 3.3.0 ... ...(생략)
[hadoop@hadoop-master logs]$ start-all.sh WARNING: Attempting to start all Apache Hadoop daemons as hadoop in 10 seconds. WARNING: This is not a recommended production deployment configuration. WARNING: Use CTRL-C to abort. Starting namenodes on [hadoop-master] Starting datanodes Starting secondary namenodes [hadoop-master] Starting resourcemanager Starting nodemanagers
# stop-all.sh
## 이렇게 디렉토리를 만들어서 넣어도 됩니다. [hadoop@hadoop-master ~]$ hdfs dfs -mkdir /user [hadoop@hadoop-master ~]$ hdfs dfs -mkdir /user/nasa
## 위에서 디렉토리를 만들었지만 저는 그냥 / 에 넣을게요 [hadoop@hadoop-master ~]$ hdfs dfs -put /home/hadoop/nasa.jsv / ## ls로 확인하면 hdfs에 파일이 들어간 것을 확인가능합니다. [hadoop@hadoop-master ~]$ hdfs dfs -ls / Found 1 items -rw-r--r-- 3 hadoop supergroup 500253789 2021-03-09 08:47 /nasa.jsv [hadoop@hadoop-master ~]$
2021-03-09 05:41:31,778 WARN org.apache.hadoop.hdfs.server.common.Storage: Failed to add storage directory [DISK]file:/usr/local/hadoop/datanode java.io.IOException: Incompatible clusterIDs in /usr/local/hadoop/datanode: namenode clusterID = CID-774db0d8-08a2-49e3-bc7f-b804c7bfb204; datanode clusterID = CID-9de845d9-b117-40c6-a996-d4bd471dbbfd at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:746) at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadStorageDirectory(DataStorage.java:296) at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadDataStorage(DataStorage.java:409) at org.apache.hadoop.hdfs.server.datanode.DataStorage.addStorageLocations(DataStorage.java:389) at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:561) at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1766) at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1702) at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:392) at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:295) at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:853) at java.lang.Thread.run(Thread.java:748) 2021-03-09 05:41:31,780 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for Block pool <registering> (Datanode Uuid d1475497-b53d-4126-b87b-615120dc89c9) service to hadoop-master/10.0.0.5:9000. Exiting. java.io.IOException: All specified directories have failed to load. at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:562) at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1766) at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1702) at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:392) at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:295) at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:853) at java.lang.Thread.run(Thread.java:748) 2021-03-09 05:41:31,780 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Ending block pool service for: Block pool <registering> (Datanode Uuid d1475497-b53d-4126-b87b-615120dc89c9) service to hadoop-master/10.0.0.5:9000
다음과 같은 경우에는 모든 서버에 namenode, datanode를 삭제한 뒤 재생성 후 Hadoop 시작합니다.
# cd /usr/local/hadoop # rm -rf namenode datanode;\ # mkdir namenode; mkdir datanode
# cd /usr/local/hadoop # rm -rf datanode;\ # mkdir datanode
# hadoop namenode -format # start-all.sh