BigData/Hadoop

[Hadoop] Zookeeper Install

twoDeveloper 2022. 11. 8. 13:53

개요

Zookeeper 환경을 구성해보고, 설치해보며 실습환경 구성

 

설치 전 환경구성...

  • VirtualBox에서 Vagrant로 Provisioning 하여 총 3개의 Server 구성
  • CentOS 7.6
  mgmt01 mgmt02 mgmt03
IP 192.168.56.11 192.168.56.12 192.168.56.13
CPU 1 1 1
MEM 2G 2G 2G

1. Zookeeper 설치 전 세팅 (모든 서버)

  • Master - Slave 간 통신을 위해 방화벽 해제

1.1 방화벽 비활성화

# systemctl stop firewalld
# systemctl disalbe firewalld

 

1.2 SELinux 비활성화

# setenforce 0
# sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

# reboot

--- SELinux Disabled 확인 ---
# sestatus

 

1.3 Hostname 설정

# vi /etc/hosts
---
192.168.56.11   mgmt01.example.com      mgmt01

192.168.56.12   mgmt02.example.com      mgmt02

192.168.56.13   mgmt03.example.com      mgmt03

2. Zookeeper Install

2.1 Zookeeper (3.6.3) Install (mgmt01에서 진행)

# wget https://mirror.navercorp.com/apache/zookeeper/zookeeper-3.6.3/apache-zookeeper-3.6.3-bin.tar.gz
# tar xvfz apache-zookeeper-3.6.3-bin.tar.gz

 

2.2 zookeeper-3.6.3 파일 이동

# mv /home/vagrant/apache-zookeeper-3.6.3-bin /usr/local

 

2.3 심볼릭 링크 지정

# ln -s apache-zookeeper-3.6.3-bin/ zookeeper

# ll
[root@mgmt01 local]# ll
total 0
drwxr-xr-x. 8 root root 157 Nov  7 06:26 apache-zookeeper-3.6.3-bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 etc
drwxr-xr-x. 2 root root   6 Apr 11  2018 games
drwxr-xr-x. 2 root root   6 Apr 11  2018 include
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 11  2018 libexec
drwxr-xr-x. 2 root root   6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root  49 Apr 30  2020 share
drwxr-xr-x. 2 root root   6 Apr 11  2018 src
lrwxrwxrwx. 1 root root  27 Nov  7 06:16 zookeeper -> apache-zookeeper-3.6.3-bin/

3. 다른 서버에 Zookeeper 디렉토리 전송

  • 각 서버 /usr/local 하위 디렉토리에 Zookeeper 디렉토리 전송
# cd /usr/local

-- mgmt02, mgmt03 --
# scp -rp zookeeper root@mgmt02:/usr/local
# scp -rp zookeeper root@mgmt03:/usr/local

4. 각 서버 Zookeeper 설정 파일 수정

# cd /usr/local/zookeeper/conf

# cp zoo_sample.cfg zoo.cfg

4.1 zoo.cfg 수정

[mgmt01]

tickTime=2000
initLimit=5
syncLimit=2
dataDir=/usr/local/zookeeper/data
clientPort=2181
server.1=0.0.0.0:2888:3888
server.2=192.168.56.12:2888:3888
server.3=192.168.56.13:2888:3888

[mgmt02]

tickTime=2000
initLimit=5
syncLimit=2
dataDir=/usr/local/zookeeper/data
clientPort=2181
server.1=192.168.56.11:2888:3888
server.2=192.168.56.12:2888:3888
server.3=0.0.0.0:2888:3888

[mgmt03]

tickTime=2000
initLimit=5
syncLimit=2
dataDir=/usr/local/zookeeper/data
clientPort=2181
server.1=192.168.56.11:2888:3888
server.2=0.0.0.0:2888:3888
server.3=192.168.56.13:2888:3888
  • dataDir은 Zookeeper가 데이터를 저장할 위치를 뜻하며, Zookeeper Server id를 저장하는 위치이기도 함
  • 각 서버의 자기 자신은 0.0.0.0 ip를 기입하여 Master - Slaver 간 통신이 원할히 이루어지도록 설정
    • 처음 각 자신의 IP를 설정하였을 때 Zookeeper가 자기 자신을 모르는 Issue가 발생하여 다음과 같이 설정

※ Issue

# cd /usr/local/zookeeper/bin

# ./zkCli.sh


5. Zookeeper 각 Server id 설정

  • 각 Server id는 위 zoo.cfg에서 설정한 server.1에서 1을 의미, 즉 mgmt01 서버는 myid 1을 갖음
  • dataDir 아래에 위치

[mgmt01]

# vi /usr/local/zookeeper/data/myid
---
1

[mgmt02]

# vi /usr/local/zookeeper/data/myid
---
2

[mgmt03]

# vi /usr/local/zookeeper/data/myid
---
3

6. 환경 변수 설정 (모든 서버)

# vi /etc/profile
.
.
.
export ZOOKEEPER_HOME=/usr/local/zookeeper
export PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin
# source /etc/profile

7. alias 설정

  • ~/.bashrc에 설정 추가
# vi ~/.bashrc
---
alias zkstart="/usr/local/zookeeper/bin/zkServer.sh start"
alias zkstatus="/usr/local/zookeeper/bin/zkServer.sh status"
alias zkstop="/usr/local/zookeeper/bin/zkServer.sh stop"
# source ~/.bashrc

8. Zookeeper Start (모든 서버)

# zkstart

mgmt01
mgmt02
mgmt03


9. Zookeeper Status (모든 서버)

# zkstatus

mgmt01 - follower
mgmt02 - follwer
mgmt03 - leader


10. Zookeeper Stop

# zkstop

 

'BigData > Hadoop' 카테고리의 다른 글

[Hadoop] Zookeeper 란?  (0) 2022.11.08
[Hadoop] Hadoop 이란?  (0) 2022.09.27
[Hadoop] Hadoop Eco System 이란?  (0) 2022.09.07