해당 작업은 server1, server2 둘 다 해주시면 됩니다.
sudo vim /etc/hosts
---
[private_ip] server1
[private_ip] server2
서버 끼리의 통신을 위해 ssh 키를 생성한 후, 다른 서버에게 전달해주는 작업을 하겠습니다. 해당 작업은 server1, server2 둘 다 해주시면 됩니다.
# ssh key 생성
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
# authorized_keys 생성
cat >> ~/.ssh/authorized_keys < ~/.ssh/id_rsa.pub
# localhost 접속 테스트
# server1
ssh -p 5000 localhost
# server2
ssh -p 5001 localhost
# Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
# id_rsa.pub 키 전달
scp -P 5000 ~/.ssh/id_rsa.pub ubuntu@[public_ip]:~/.ssh/server2.pub
scp -P 5001 ~/.ssh/id_rsa.pub ubuntu@[public_ip]:~/.ssh/server1.pub
cat >> ~/.ssh/authorized_keys < ~/.ssh/server1.pub
cat >> ~/.ssh/authorized_keys < ~/.ssh/server2.pub
# ssh config 설정
vim ~/.ssh/config
-----
Host server1
HostName [public_ip]
User ubuntu
Port 5000
Host server2
HostName [public_ip]
User ubuntu
Port 5001
-----
# 접속 확인
# 서버1에서 서버2로, 서버2에서 서버1로 접속이 되어야 한다.
ssh server1
ssh server2
App | port | App | port |
---|---|---|---|
Namenode | 9000 | Zookeeper TCP | 2181 |
Namenode Web UI | 9870 | Zookeeper 서버 동기화(앙상블 구성) | 2888 |
NameNode RPC | 8020 | Zookeeper 리더 선출 | 3888 |
JournalNode | 8485 | Kafka broker | 9092 |
Yarn Web UI | 8088 | Datanode IPC port | 9867 |
Datanode port | 9866 | Datanode Web UI | 9864 |
# server1에서
sudo ufw allow from [server2 private ip]
# server2에서
sudo ufw allow from [server1 private ip]
# server1, server2 모두 실행
sudo ufw allow 9000
sudo ufw allow 9870
sudo ufw allow 8020
sudo ufw allow 8485
sudo ufw allow 8088
sudo ufw allow 2181
sudo ufw allow 2888
sudo ufw allow 3888
sudo ufw allow 9092
sudo ufw allow 9866
sudo ufw allow 9867
# server2에 Zookeeper를 2대 둘 것이기 때문에
# server2는 이하 추가
sudo ufw allow 2889
sudo ufw allow 3889
sudo ufw allow 2182
hdfs-site.xml
열기
vim $HADOOP_HOME/etc/hadoop/hdfs-site.xml
아래와 같이 수정 후 저장
<configuration>
<!-- configuration hadoop -->
<property>
<name>dfs.namenode.rpc-bind-host</name>
<value>0.0.0.0</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/usr/local/hadoop/dfs/journalnode</value>
</property>
<property>
<name>dfs.nameservices</name>
<value>achacha</value>
</property>
<property>
<name>dfs.ha.namenodes.achacha</name>
<value>namenode01,namenode02</value>
</property>
<property>
<name>dfs.namenode.rpc-address.achacha.namenode01</name>
<value>server1:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.achacha.namenode02</name>
<value>server2:8020</value>
</property>
<property>
<name>dfs.namenode.http-address.achacha.namenode01</name>
<value>server1:9870</value>
</property>
<property>
<name>dfs.namenode.http-address.achacha.namenode02</name>
<value>server2:9870</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://server1:8485;server2:8485/achacha</value>
</property>
<property>
<name>dfs.client.failover.proxy.provider.achacha</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value>shell(/bin/true)</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>/usr/local/hadoop/dfs/namenode</value>
</property>
<property>
<name>dfs.datanode.name.dir</name>
<value>/usr/local/hadoop/dfs/datanode</value>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/home/ubuntu/.ssh/id_rsa</value>
</property>
</configuration>
core-site.xml
열기
vim $HADOOP_HOME/etc/hadoop/core-site.xml
아래와 같이 수정 후 저장.
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://achacha</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>server1:2181,server2:2181</value>
</property>
</configuration>
mapred-site.xml
열기
vim $HADOOP_HOME/etc/hadoop/mapred-site.xml
아래와 같이 수정 후 저장.
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://achacha</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>server1:2181,server2:2181</value>
</property>
</configuration>
yarn-site.xml
열기
vim $HADOOP_HOME/etc/hadoop/yarn-site.xml
아래와 같이 수정 후 저장.
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>server1</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>server1:8089</value>
</property>
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
</configuration>
hadoop-env.sh
열기
vim $HADOOP_HOME/etc/hadoop/hadoop-env.sh
# 아래 내용 수정 후 저장
# Java /54
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
#라즈베리의 경우 : export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64
# Hadoop /58
export HADOOP_HOME=/usr/local/hadoop
#198 line
export HADOOP_PID_DIR=$HADOOP_HOME/pids
workers
열기. workers 파일에 데이터노드들을 정의해줍니다.
vim $HADOOP_HOME/etc/hadoop/workers
# 아래 내용 수정 후 저장
# localhost << 주석 처리 또는 제거
server1
server2