Technology Sharing

Install Zookeeper on Windows

2024-07-12

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

Install

download link:Apache ZooKeeper

The version I downloaded: zookeeper-3.4.12

After downloading, unzip

Configuration

1. Create a "data" folder and a "log" folder in the D:zookeeper-3.4.12 folder

2. Copy zoo_sample.cfg and rename it to zoo.cfg

Modify the zoo.cfg file

  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
start up

Enter the directory: 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
Simple Usage

Operation on zkCli.cmd

1. Create a node

 create /test "my_data"

Node: /test

Value: my_data

Note: When creating a node in zk, it must start with "/", otherwise an error will be reported:Command failed: java.lang.IllegalArgumentException: Path must start with / character

2. Get the node

get /test

3. Modify the node

 set /test "abc"

4. Create child nodes

create /test/child "child"

5. View child nodes

ls /test

6. Delete a node

delete /test/child