Compartilhamento de tecnologia

Instale o Zookeeper no Windows

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Instalar

Link para Download:Apache ZooKeeper

A versão que baixei: zookeeper-3.4.12

Após baixar, descompacte

Configuração

1. Crie uma pasta “data” e uma pasta “log” na pasta D:zookeeper-3.4.12

2. Copie zoo_sample.cfg e renomeie: zoo.cfg

Modifique o arquivo zoo.cfg

  1. # The number of milliseconds of each tick
  2. tickTime=2000
  3. # The number of ticks that the initial
  4. # synchronization phase can take
  5. initLimit=10
  6. # The number of ticks that can pass between
  7. # sending a request and getting an acknowledgement
  8. syncLimit=5
  9. # the directory where the snapshot is stored.
  10. # do not use /tmp for storage, /tmp here is just
  11. # example sakes.
  12. #dataDir=/tmp/zookeeper
  13. dataDir=D:zookeeper-3.4.12data
  14. dataLogDir=D:zookeeper-3.4.12log
  15. # the port at which the clients will connect
  16. clientPort=2181
comece

Digite o diretório: D:zookeeper-3.4.12bin

1. Execute zkServer.cmd

2. Execute zkCli.cmd

  1. #连接本地zk
  2. zkCli.cmd
  3. #链接远程zk
  4. zkCli.cmd -server ip:port
Uso simples

Operar em zkCli.cmd

1. Crie nós

 create /test "my_data"

Nó:/teste

Valor: meus_dados

Nota: Ao criar um nó em zk, ele deve começar com "/", caso contrário será relatado um erro:Falha no comando: java.lang.IllegalArgumentException: O caminho deve começar com o caractere /

2. Obtenha nós

get /test

3. Modifique os nós

 set /test "abc"

4. Crie nós filhos

create /test/child "child"

5. Visualize nós filhos

ls /test

6. Excluir nó

delete /test/child