本文介绍一下zookeeper-3.5.7集群安装。

解压安装

tar zxf apache-zookeeper-3.5.7-bin.tar.gz

创建数据、日志目录:

mv apache-zookeeper-3.5.7-bin /app/zookeeper-3.5.7
cd /app/zookeeper-3.5.7 mkdir data
mkdir logs

编辑配置文件

zoo.cfg文件

cp conf/zoo_sample.cfg conf/zoo.cfg

编辑conf/zoo.cfg文件:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/app/zookeeper-3.5.7/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1 #集群配置
#配置两个也能启动,但是只能提供副本能力,无法保证高可用
server.1=cloud-server-8:2888:3888
server.2=cloud-server-9:2888:3888
server.3=cloud-server-10:2888:3888

myid文件

echo '1' > data/myid

启动zookeeper

启动/停止zookeeper服务

# 启动服务
./bin/zkServer.sh start # 停止服务
./bin/zkServer.sh stop

zkServer.sh脚本

# ./bin/zkServer.sh -help
ZooKeeper JMX enabled by default
Using config: /app/zookeeper-3.5.7/bin/../conf/zoo.cfg
Usage: ./bin/zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}

客户端

启动客户端

./bin/zkCli.sh

默认连接localhost:2181的zookeeper服务,可以使用-server选项指定服务器地址。

zkCli.sh脚本

# ./bin/zkCli.sh help
Connecting to localhost:2181
ZooKeeper -server host:port cmd args
addauth scheme auth
close
config [-c] [-w] [-s]
connect host:port
create [-s] [-e] [-c] [-t ttl] path [data] [acl]
delete [-v version] path
deleteall path
delquota [-n|-b] path
get [-s] [-w] path
getAcl [-s] path
history
listquota path
ls [-s] [-w] [-R] path
ls2 path [watch]
printwatches on|off
quit
reconfig [-s] [-v version] [[-file path] | \
[-members serverID=host:port1:port2;port3[,...]*]] | \
[-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]
redo cmdno
removewatches path [-c|-d|-a] [-l]
rmr path
set [-s] [-v version] path data
setAcl [-s] [-v version] [-R] path acl
setquota -n|-b val path
stat [-w] path
sync path
Command not found: Command not found help

zookeeper源码(01)集群启动的更多相关文章

  1. Dubbo 源码分析 - 集群容错之 LoadBalance

    1.简介 LoadBalance 中文意思为负载均衡,它的职责是将网络请求,或者其他形式的负载"均摊"到不同的机器上.避免集群中部分服务器压力过大,而另一些服务器比较空闲的情况.通 ...

  2. Dubbo 源码分析 - 集群容错之 Cluster

    1.简介 为了避免单点故障,现在的应用至少会部署在两台服务器上.对于一些负载比较高的服务,会部署更多台服务器.这样,同一环境下的服务提供者数量会大于1.对于服务消费者来说,同一环境下出现了多个服务提供 ...

  3. Dubbo 源码分析 - 集群容错之 Router

    1. 简介 上一篇文章分析了集群容错的第一部分 -- 服务目录 Directory.服务目录在刷新 Invoker 列表的过程中,会通过 Router 进行服务路由.上一篇文章关于服务路由相关逻辑没有 ...

  4. zookeeper源码 — 一、单机启动

    zookeeper一般使用命令工具启动,启动主要就是初始化所有组件,让server可以接收并处理来自client的请求.本文主要结构: main入口 配置解析 组件启动 main入口 我们一般使用命令 ...

  5. Dubbo源码学习--集群负载均衡算法的实现

    相关文章: Dubbo源码学习文章目录 前言 Dubbo 的定位是分布式服务框架,为了避免单点压力过大,服务的提供者通常部署多台,如何从服务提供者集群中选取一个进行调用, 就依赖Dubbo的负载均衡策 ...

  6. Dubbo 源码分析 - 集群容错之 Directory

    1. 简介 前面文章分析了服务的导出与引用过程,从本篇文章开始,我将开始分析 Dubbo 集群容错方面的源码.这部分源码包含四个部分,分别是服务目录 Directory.服务路由 Router.集群 ...

  7. Dubbo源码(七) - 集群

    前言 本文基于Dubbo2.6.x版本,中文注释版源码已上传github:xiaoguyu/dubbo 集群(cluster)就是一组计算机,它们作为一个总体向用户提供一组网络资源.这些单个的计算机系 ...

  8. dubbo源码分析- 集群容错之Cluster(一)

    1.集群容错的配置项 failover - 失败自动切换,当出现失败,重试其他服务器(缺省),通常用于读操作,但重试会带来更长的延时. failfast - 快速失效,只发起一次调用,失败立即报错.通 ...

  9. zookeeper 源码(一) 选举和同步数据

    前言 在开始阅读代码前我们先来了解一下zk 的大致结构,具体大概要实现的核心功能有那些,心中有个大概的框架阅读代码时再深入其中的细节,就会非常好懂,本人觉得这是一个阅读源码的好方法,可以最快地切入到源 ...

  10. zookeeper源码之服务端

    zookeeper服务端主要包括一下几个模块:     1.启动模块. 2.核心执行模块 3.数据管理模块. 启动模块 读取配置文件,启动程序.详见:zookeeper源码之服务端启动模块. 核心执行 ...

随机推荐

  1. pytest框架学习-测试用例发现机制以及用例执行命令

    pytest是什么 pytest是python的一种单元测试框架,与python自带的unittest测试框架类似,但是比unittest框架使用起来更简洁,效率更高. Pytest安装 安装命令: ...

  2. Pikachu漏洞靶场 (SSRF服务端请求伪造)

    SSRF(Server-Side Request Forgery:服务器端请求伪造) curl 点击 累了吧,来读一首诗吧 url是这样的: http://192.168.171.30/pikachu ...

  3. C#数据结构与算法系列(十七):时间复杂度(下)

    1.常见的时间复杂度 常数阶:O(1) 对数阶:O(log2n) 线性阶:O(n) 线性对数阶:O(nlog2n) 平方阶:O(n^2) 立方阶:O(n^3) k次方阶:O(2^n) 常见的算法时间复 ...

  4. 智能对联模型太难完成?华为云ModelArts助你实现!手把手教学

    摘要:农历新年将至,听说华为云 AI 又将开启智能对对联迎接牛气冲天,让我们拭目以待!作为资深 Copy 攻城狮,想要自己实现一个对对联的模型,是不能可能完成的任务,因此我搜罗了不少前人的实践案例,今 ...

  5. 常用的echo和cat,这次让我折在了特殊字符丢失问题上

    摘要:用过linux的都知道,echo和cat是我们常用的展示内容和写入内容的方式. 本文分享自华为云社区<echo和cat,重定向到文件时,解决特殊字符丢失问题>,作者: 大金(内蒙的) ...

  6. 【鲲鹏 DevKit黑科技揭秘】│如何实现全链路系统问题90%精准诊断?

    摘要:DevKit系统诊断工具是鲲鹏性能分析工具的子工具之一,能够针对内存.网络.存储等常见故障和异常,提供精准定位和诊断能力,帮助用户识别出源代码中的问题点,提升程序的可靠性,故障定位准确率高达90 ...

  7. Centos7 怎么永久关闭防火墙

    1.连接到centos主机,然后输入命令"systemctl status firewalld.service"并按下回车键. 2.然后在下方可以查看得到 " activ ...

  8. App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法

    iOS 备案查看信息 iOS平台Bundle ID 公钥 证书SHA-1指纹 IOS平台服务器域名 获取 Bundle ID: 或者 https://developer.apple.com/accou ...

  9. 神经网络优化篇:详解动量梯度下降法(Gradient descent with Momentum)

    动量梯度下降法 还有一种算法叫做Momentum,或者叫做动量梯度下降法,运行速度几乎总是快于标准的梯度下降算法,简而言之,基本的想法就是计算梯度的指数加权平均数,并利用该梯度更新的权重. 例如,如果 ...

  10. MAC SAP for JAVA配置

    一.自定义应用程序服务器配置 conn = /H/<SAP路由器服务器地址(如果有)>/S/3299 /H/<SAP服务器地址>/S/32<Instance_no> ...