启动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
网友评论