Zookeeper学习笔记

启动zk server

zkServer start // or in linux: zkServer.sh start

配置conf/zoo.cfg

  • tickTime
    the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice the tickTime.
  • dataDir
    the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.
  • clientPort
    the port to listen for client connections
  • initLimit
    initLimit is timeouts ZooKeeper uses to limit the length of time the ZooKeeper servers in quorum have to connect to a leader.
  • syncLimit
    syncLimit limits how far out of date a server can be from a leader
  • server.1=localhost:2888:3888 # zk cluster

client connect to zk server:

zkCli -server server_ip:2181

#creates a new znode and associates the string "my_data" with the node
create /zk_test my_data

# list zk nodes
ls /
ls /abc/def

# get node_name detail info
get /node_name
get /node_name/sub_node

# set the data associated with node_name
set /node_name data

# delete the node
delete /node_name
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容