Condivisione della tecnologia

Installa Zookeeper su Windows

2024-07-12

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

Installare

Link per scaricare:Apache Zookeeper

La versione che ho scaricato: zookeeper-3.4.12

Dopo il download, decomprimere

Configurazione

1. Crea una cartella "data" e una cartella "log" nella cartella D:zookeeper-3.4.12

2. Copia zoo_sample.cfg e rinomina: zoo.cfg

Modificare il file 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
avviare

Inserisci la directory: D:zookeeper-3.4.12bin

1. Eseguire zkServer.cmd

2. Eseguire zkCli.cmd

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

Operare su zkCli.cmd

1. Crea nodi

 create /test "my_data"

Nodo:/prova

Valore: miei_dati

Nota: quando si crea un nodo in zk, deve iniziare con "/", altrimenti verrà segnalato un errore:Comando non riuscito: java.lang.IllegalArgumentException: il percorso deve iniziare con il carattere /

2. Ottieni nodi

get /test

3. Modificare i nodi

 set /test "abc"

4. Crea nodi figlio

create /test/child "child"

5. Visualizza i nodi figlio

ls /test

6. Elimina nodo

delete /test/child