技術共有

Windows に Zookeeper をインストールする

2024-07-12

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

インストール

ダウンロードリンク:Apache ズーキーパー

私がダウンロードしたバージョン:zookeeper-3.4.12

ダウンロード後、解凍してください

構成

1. D:zookeeper-3.4.12 フォルダー内に「data」フォルダーと「log」フォルダーを作成します。

2.zoo_sample.cfgをコピーし、名前をzoo.cfgに変更します。

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
起動する

ディレクトリを入力します: D:zookeeper-3.4.12bin

1. zkServer.cmdを実行します。

2. zkCli.cmdを実行します。

  1. #连接本地zk
  2. zkCli.cmd
  3. #链接远程zk
  4. zkCli.cmd -server ip:port
簡単な使い方

zkCli.cmdでの操作

1. ノードの作成

 create /test "my_data"

ノード:/テスト

値: my_data

注: zk でノードを作成するときは、「/」で始める必要があります。そうしないと、エラーが報告されます。コマンドが失敗しました: java.lang.IllegalArgumentException: パスは / 文字で始まる必要があります

2. ノードを取得する

get /test

3. ノードを変更する

 set /test "abc"

4. 子ノードの作成

create /test/child "child"

5. 子ノードを表示する

ls /test

6. ノードの削除

delete /test/child