첫째, 독립 실행 형 환경을 구축
1.1 다운로드
해당 버전 사육사 다운로드, 여기 나는 버전을 다운로드 3.4.14
. 공식 다운로드 : HTTPS : //archive.apache.org/dist/zookeeper/
# wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
1.2 압축 해제
# tar -zxvf zookeeper-3.4.14.tar.gz
1.3 구성 환경 변수
# vim /etc/profile
환경 변수를 추가 :
export ZOOKEEPER_HOME=/usr/app/zookeeper-3.4.14
export PATH=$ZOOKEEPER_HOME/bin:$PATH
환경 변수 설정을 만들기을 적용하려면 :
# source /etc/profile
1.4 구성을 수정
에 설치 디렉토리 conf/
디렉토리에 복사 구성 샘플을 수정합니다
# cp zoo_sample.cfg zoo.cfg
다음과 같이 지정 데이터 저장 디렉토리 및 로그 파일 디렉토리 (이전에 생성하지 않고 디렉토리, 프로그램이 자동 생성), 개정 된 전체 구성은 다음과 같습니다
# 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
구성 매개 변수 :
- tickTime : 계산 유닛 염기 시간. 세션 타임 아웃 예 : N * tickTime;
- initLimit : 연결 초기화 시간 동기 마스터 노드는 노드에서 클러스터 및 허용 연결은 배수 tickTime 표현;
- syncLimit : 클러스터의 마스터 노드와 메시지의 요청 및 응답 시간 길이 (하트 비트 메커니즘) 사이의 마스터 노드로 전송;
- DATADIR : 데이터 저장 위치;
- dataLogDir은 : 디렉토리에 로그;
- 을 clientPort : 연결하는 클라이언트에 대한 포트, 기본 2181
1.5 시작
이미 환경 변수를 구성하기 때문에, 직접 시작하려면 다음 명령을 사용할 수 있습니다 :
zkServer.sh start
1.6 검증
JPS는 프로세스가 시작되었는지 여부 등장 확인 QuorumPeerMain
성공적인 시작을 나타냅니다.
[root@hadoop001 bin]# jps
3814 QuorumPeerMain
둘째, 클러스터 환경을 구축
고 가용성 클러스터를 보장하기 위해, 클러스터, 그래서 여기에 적어도 세 개의 노드가있다, 사육사 가장 이상한 노드 세 개의 노드의 클러스터를 구축 보여줍니다. 여기에 내가 설정 한 세 개의 호스트를 사용하여 호스트 이름 hadoop001, hadoop002, hadoop003 있습니다.
2.1 구성을 수정
사육사 설치 패키지를 추출하면, 구성 파일을 수정하여 zoo.cfg
다음과 같이. 세 개의 서버에 배포 패키지를 설치 scp 명령을 사용한 후 :
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-cluster/data/
dataLogDir=/usr/local/zookeeper-cluster/log/
clientPort=2181
# server.1 这个1是服务器的标识,可以是任意有效数字,标识这是第几个服务器节点,这个标识要写到dataDir目录下面myid文件里
# 指名集群间通讯端口和选举端口
server.1=hadoop001:2287:3387
server.2=hadoop002:2287:3387
server.3=hadoop003:2287:3387
2.2 노드를 식별
각각 세 개의 호스트 dataDir
새로운 디렉토리의 myid
파일 및 해당 노드 식별자를 작성합니다. 에 의해 사육사 클러스터 myid
파일 식별 클러스터 노드와 노드는 통신 포트 및 선거 위 포트 구성, 선임 리더 노드를 통해 통신 노드한다.
저장 디렉토리를 생성합니다 :
# 三台主机均执行该命令
mkdir -vp /usr/local/zookeeper-cluster/data/
생성 및 노드 식별에 기록됩니다 myid
파일 :
# hadoop001主机
echo "1" > /usr/local/zookeeper-cluster/data/myid
# hadoop002主机
echo "2" > /usr/local/zookeeper-cluster/data/myid
# hadoop003主机
echo "3" > /usr/local/zookeeper-cluster/data/myid
클러스터 2.3을 시작합니다
각각 세 개의 호스트에 서비스를 시작하려면 다음 명령을 실행합니다 :
/usr/app/zookeeper-cluster/zookeeper/bin/zkServer.sh start
2.4 클러스터 확인
시작 후 사용하는 zkServer.sh status
각 클러스터 노드의 상태를 볼 수 있습니다. 그림에 나타낸 바와 같이 : 세 개의 노드 프로세스가 성공적으로 시작하고, 추종자 노드로 리더 노드 hadoop001 및 hadoop003로 hadoop002했다.
![](https://raw.githubusercontent.com/heibaiying/BigData-Notes/master/pictures//zookeeper-hadoop001.png)
![](https://raw.githubusercontent.com/heibaiying/BigData-Notes/master/pictures//zookeeper-hadoop002.png)
![](https://raw.githubusercontent.com/heibaiying/BigData-Notes/master/pictures//zookeeper-hadoop003.png)
더 큰 데이터 계열은 개인 GitHub의 오픈 소스 프로젝트에서 찾을 수 있습니다 빅 데이터 시작하기