개발자의 노트
반응형

** 작년에 주키퍼 설치하면서 써둔 글이라. 최근 버전에서 바뀐게 있는지는 모르겠음..


다운로드 : http://www.apache.org/dyn/closer.cgi/zookeeper/

현재 안정버전 3.3.5 문서 : http://zookeeper.apache.org/doc/current/

설치 가이드 : http://zookeeper.apache.org/doc/current/zookeeperStarted.html


JDK 6 이상이 설치되어있어야 한다.


설치를 해보자. (CentOS기준)

최신 안정버전을 다운로드 받는다. 


# cd /usr/local/src

# wget http://apache.tt.co.kr/zookeeper/stable/zookeeper-3.3.5.tar.gz

# tar zxvf zookeeper-3.3.5.tar.gz

# cp -Rf zookeeper-3.3.5 /usr/local/zookeeper

# cd /usr/local/zookeeper


zoo_sample.cfg 를 복사해서 zoo.cfg 파일을 만든다.


# cp conf/zoo_sample.cfg conf/zoo.cfg


zoo.cfg 파일을 열어 필요한 값을 수정한다.


# vi conf/zoo.cfg


나는 데이터 저장 디렉토리 (dataDir)를 변경했다.


 

# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting an acknowledgement

syncLimit=5

# the directory where the snapshot is stored.

dataDir=/data/zookeeper/data

# the port at which the clients will connect

clientPort=2181


단일 서버를 사용할 경우. 이제 설치는 다 되었다.


서버를 구동해보자.


# bin/zkServer.sh start


클라이언트도 구동해보자.


# bin/zkCli.sh -server 127.0.0.1:2181

[zk: 127.0.0.1:2181(CONNECTED) 0]

[zk: 127.0.0.1:2181(CONNECTED) 0] help


여러 서버로 확장하려면,

각 서버마다 똑같이 주키퍼를 설치하고 zoo.cfg 를 동일하게 수정한다.


만일 192.168.0.1, 192.168.0.2, 192.168.0.3 세 곳으로 확장하려면,

각 서버의 zoo.cfg에 서버 정보 추가


# vi conf/zoo.cfg

server.1=192.168.0.1:2888:3888

server.2=192.168.0.2:2888:3888

server.3=192.168.0.3:2888:3888


그리고 각 서버는 자신의 데이터 디렉토리 (우린 /data/zookeeper/data 로 했다) 에 myid 라는 파일을 만들고, 자신의 서버에 해당하는 아이디 값을 적어주면 된다.


192.168.0.1 서버라면,

# cat > /data/zookeeper/data/myid

1


192.168.0.2 서버라면,

# cat > /data/zookeeper/data/myid

2


192.168.0.3 서버라면,

# cat > /data/zookeeper/data/myid

3


이런 식이다.

server.X 에서 X는 예제처럼 숫자가 아니어도 된다.

알파벳을 넣든, 아이피를 넣든 중요한건 X 값과 myid 에 들어가는 값이 같아야 된다는 거..

profile

개발자의 노트

@곽코딩

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!