Windows 에서 Zookeeper 단일 컴퓨터 모드 와 위조 분포 식 모드 설치

13563 단어 [빅 데이터]
  • jdk 설치
  • Zookeeper 설치http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper 를 다운로드 합 니 다. 저 는 zookeeper - 3.4.10 버 전 을 다운로드 합 니 다.
  • zookeeper - 3.4.10 ~ D: \ \ dev \ zookeeper \ \ zookeeper - 3.4.10.
  • D: \ dev \ zookeeper 에 새 data 및 log 디 렉 터 리 를 만 듭 니 다.
  • ZooKeeper 의 설치 모델 은 세 가지 로 나 뉘 는데 그것 이 바로 단기 모드 (stand - alone), 집단 모드 와 집단 위조 분포 모드 이다.ZooKeeper 단기 모드 의 설 치 는 상대 적 으로 간단 합 니 다. ZooKeeper 를 처음 접 했다 면 ZooKeeper 단기 모드 나 집단 위조 분포 모드 를 설치 하 는 것 을 권장 합 니 다.

  • 단기 모드 를 설치 하 다.
    D: \ \ \ dev \ \ zookeeper \ \ zookeeper - 3.4.10 \ \ conf 복사 zoosample. cfg 를 현재 디 렉 터 리 에 붙 여 넣 고 zoo. cfg 라 고 명명 합 니 다.
    1. 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=D:\\dev\\zookeeper\\data
    dataLogDir=D:\\dev\\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
    

    2. cmd 명령 에 따라 D: \ dev \ zookeeper \ \ zookeeper - 3.4.10 \ bin 디 렉 터 리 에서 zkserver. cmd 를 실행 합 니 다. 다음 과 같 습 니 다.
    2018-11-21 17:32:36,043 [myid:] - INFO [main:Environment@100] - Server environment:java.compiler=
    2018-11-21 17:32:36,045 [myid:] - INFO [main:Environment@100] - Server environment:os.name=Windows 10
    2018-11-21 17:32:36,045 [myid:] - INFO [main:Environment@100] - Server environment:os.arch=amd64
    2018-11-21 17:32:36,046 [myid:] - INFO [main:Environment@100] - Server environment:os.version=10.0
    2018-11-21 17:32:36,046 [myid:] - INFO [main:Environment@100] - Server environment:user.name=admin
    2018-11-21 17:32:36,047 [myid:] - INFO [main:Environment@100] - Server environment:user.home=C:\Users\admin
    2018-11-21 17:32:36,047 [myid:] - INFO [main:Environment@100] - Server environment:user.dir=D:\dev\zookeeper\zookeeper-3.4.10\bin
    2018-11-21 17:32:36,060 [myid:] - INFO [main:ZooKeeperServer@829] - tickTime set to 2000
    2018-11-21 17:32:36,060 [myid:] - INFO [main:ZooKeeperServer@838] - minSessionTimeout set to -1
    2018-11-21 17:32:36,061 [myid:] - INFO [main:ZooKeeperServer@847] - maxSessionTimeout set to -1
    2018-11-21 17:32:36,560 [myid:] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
    

    3. 시작 완료 후 cmd 명령 에서 netstat - ano 는 포트 감청 서 비 스 를 봅 니 다.4. cmd 에서 D: \ machine \ zookeeper - 3.4.6 \ bin 디 렉 터 리 에서 zkcli. cmd 를 실행 합 니 다. 다음 과 같 습 니 다.
    2018-11-21 17:34:18,097 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=
    2018-11-21 17:34:18,098 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Windows 10
    2018-11-21 17:34:18,099 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
    2018-11-21 17:34:18,100 [myid:] - INFO [main:Environment@100] - Client environment:os.version=10.0
    2018-11-21 17:34:18,102 [myid:] - INFO [main:Environment@100] - Client environment:user.name=admin
    2018-11-21 17:34:18,106 [myid:] - INFO [main:Environment@100] - Client environment:user.home=C:\Users\admin
    2018-11-21 17:34:18,107 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=D:\dev\zookeeper\zookeeper-3.4.10\bin
    2018-11-21 17:34:18,109 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@277050dc
    Welcome to ZooKeeper!
    2018-11-21 17:34:18,809 [myid:] - INFO [main-SendThread(0:0:0:0:0:0:0:1:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
    2018-11-21 17:34:18,813 [myid:] - INFO [main-SendThread(0:0:0:0:0:0:0:1:2181):ClientCnxn$SendThread@876] - Socket connection established to 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181, initiating session
    JLine support is enabled
    [zk: localhost:2181(CONNECTING) 0] 2018-11-21 17:34:18,932 [myid:] - INFO [main-SendThread(0:0:0:0:0:0:0:1:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181, sessionid = 0x167359d3d6b0000, negotiated timeout = 30000
    WATCHER::
    WatchedEvent state:SyncConnected type:None path:null
    [zk: localhost:2181(CONNECTED) 0]
    
    

    군집 위 분포 모드 를 설치 하 다.
    1. zoo. cfg 파일 을 zoo 1. 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=D:\\dev\\zookeeper\\data\\d_1
    dataLogDir=D:\\dev\\zookeeper\\log
    # the port at which the clients will connect
    clientPort=2181
    server.1=localhost:2887:3887
    server.2=localhost:2888:3888
    server.3=localhost:2889:3889
    # 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
    

    2. zoo 1. cfg 파일 을 zoo 2. 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=D:\\dev\\zookeeper\\data\\d_2
    dataLogDir=D:\\dev\\zookeeper\\log
    # the port at which the clients will connect
    clientPort=2182
    server.1=localhost:2887:3887
    server.2=localhost:2888:3888
    server.3=localhost:2889:3889
    # 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
    

    3. zoo 1. cfg 파일 을 zoo 3. 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=D:\\dev\\zookeeper\\data\\d_3
    dataLogDir=D:\\dev\\zookeeper\\log
    # the port at which the clients will connect
    clientPort=2183
    server.1=localhost:2887:3887
    server.2=localhost:2888:3888
    server.3=localhost:2889:3889
    # 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
    
    

    4. D: \ \ dev \ zookeeper \ \ data 에서 d 를 새로 만 듭 니 다.1、d_2 및 d3 디 렉 터 리 5, zkserver. cmd 파일 을 zkserver - 1. cmd 로 복사 합 니 다.부분 내용 은 다음 과 같다.
    setlocal
    call "%~dp0zkEnv.cmd"
    
    
    set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
    set ZOOCFG=..\conf\zoo1.cfg
    echo on
    call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
    
    
    endlocal
    

    6. zkserver - 1. cmd 파일 을 zkserver - 2. cmd 로 복사 합 니 다.부분 내용 은 다음 과 같다.
    setlocal
    call "%~dp0zkEnv.cmd"
    
    
    set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
    set ZOOCFG=..\conf\zoo2.cfg
    echo on
    call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
    
    
    endlocal
    

    7. zkserver - 1. cmd 파일 을 zkserver - 3. cmd 로 복사 합 니 다.부분 내용 은 다음 과 같다.
    setlocal
    call "%~dp0zkEnv.cmd"
    
    
    set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
    set ZOOCFG=..\conf\zoo3.cfg
    echo on
    call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
    
    
    endlocal
    

    8. cmd 에서 각각 zkserver - 1. cmd 를 실행 하 는 오 류 는 다음 과 같 습 니 다.
    org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing ..\conf\zoo1.cfg
    	at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:154)
    	at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
    	at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
    Caused by: java.lang.IllegalArgumentException: D:\dev\zookeeper\data\d_1\myid file is missing
    	at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:406)
    	at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:150)
    ... 2 more
    Invalid config, exiting abnormally
    

    9. my id 파일 이 없 으 면 해당 위치 에서 my id 파일 을 만 듭 니 다. 파일 에 숫자 를 마음대로 쓰 고 다시 시작 합 니 다. 다음 과 같은 오 류 를 보고 합 니 다.
    2018-11-21 17:47:14,624 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel to 2 at election address localhost/127.0.0.1:3888
    java.net.ConnectException: Connection refused: connect
    	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    	at java.net.Socket.connect(Socket.java:589)
    	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:562)
    	at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:538)
    	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452)
    	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433)
    	at java.lang.Thread.run(Thread.java:745)
    2018-11-21 17:47:14,626 [myid:1] - INFO [WorkerSender[myid=1]:QuorumPeer$QuorumServer@167] - Resolved hostname: localhost to address: localhost/127.0.0.1
    2018-11-21 17:47:15,629 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@588] - Cannot open channel to 3 at election address localhost/127.0.0.1:3889
    	java.net.ConnectException: Connection refused: connect
    	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    	at java.net.Socket.connect(Socket.java:589)
    	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:562)
    	at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:538)
    	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452)
    	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433)
    	at java.lang.Thread.run(Thread.java:745)
    

    10. 이 오 류 는 다른 두 노드 를 연결 하 는 데 실 패 했 습 니 다. 다른 두 노드 를 시작 하면 됩 니 다.11. cmd 에서 netstar - ano 는 포트 감청 상황 을 봅 니 다.12. cmd 에서 zkcli. cmd - server: localhost: 2181 을 실행 합 니 다.zkcli.cmd ;-server:localhost:2182;zkcli.cmd -server:localhost:2183.

    좋은 웹페이지 즐겨찾기