首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Linux系统Zookeeper环境搭建(单机、伪分布式、分布式)

本人现在对zookeeper的环境搭建做一个总结,一般zookeeper的安装部署可以有三种模式,单机模式、伪分布式和分布式,这三种模式在什么时候应用具体看大家的使用场景,如果你只有一台机器且只是想自己开发测试时用,你可以安装个单机模式,简单又实用。如果想装逼但又没有足够的机器,那你可以选择伪分布式的方式搭建,这可以满足你内心高大上的分布式需求又可以满足没有机器的屌丝现状。如果手头有三台以上的服务器,那就可以大展高富帅的风采,直接上真的分布式,真的分布式部署一般是在系统的正式环境中应用。下面我来对这三种搭建模式作个介绍。

04
您找到你想要的搜索结果了吗?
是的
没有找到

zookeeper(单机、伪集群、集群)部署

ZooKeeper是一个分布式的、开源的分布式应用程序协调服务,可以在分布 式环境中实现应用配置管理、统一命名服务、状态同步服务等功能。 ZooKeeper是一种为分布式应用所设计的高可用、高性能的开源协调服务,它提供了一项基本服务:分布式锁 服务。由于ZooKeeper开源的特性,在其分布式锁实现的基础上,又被摸索出了其它的功用,譬如:配置维 护、组服务、分布式消息队列等等。 ZooKeeper维护了一个类似文件系统的数据结构,其内部每个子目录都被 称作znode(目录节点),与文件系统一样,我们可以自由的增删改查znode。ZooKeeper集群适合搭建在奇数 台机器上。只要集群中半数以上主机处于存活,那么服务就是可用的。 ZooKeeper在配置文件中并没有指定 master和slave,但是,ZooKeeper在工作时,只有一个节点为leader,其余节点为follower,leader是通过内部 的选举机制临时产生的。

04

liunx 安装zk

1、创建 /usr/local/services/zookeeper 文件夹:     mkdir -p /usr/local/services/zookeeper 2、进入到 /usr/local/services/zookeeper 目录中:     cd /usr/local/services/zookeeper 3、下载 zookeeper-3.4.9.tar.gz:     wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz 4、解压缩 zookeeper-3.4.9.tar.gz:     tar -zxvf zookeeper-3.4.9.tar.gz 5、进入到 /usr/local/services/zookeeper/zookeeper-3.4.9/conf 目录中:     cd zookeeper-3.4.9/conf/ 6、复制 zoo_sample.cfg 文件的并命名为为 zoo.cfg:     cp zoo_sample.cfg zoo.cfg 7、用 vim 打开 zoo.cfg 文件并修改其内容为如下:     # The number of milliseconds of each tick     # zookeeper 定义的基准时间间隔,单位:毫秒     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=/tmp/zookeeper     # 数据文件夹     dataDir=/usr/local/services/zookeeper/zookeeper-3.4.9/data     # 日志文件夹     dataLogDir=/usr/local/services/zookeeper/zookeeper-3.4.9/logs     # the port at which the clients will connect     # 客户端访问 zookeeper 的端口号     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 8、保存并关闭 zoo.cfg 文件: 9、进入到 /usr/local/services/zookeeper/zookeeper-3.4.9/bin 目录中:     cd ../bin/ 10、用 vim 打开 /etc/ 目录下的配置文件 profile:     vim /etc/profile     并在其尾部追加如下内

02

扫码

添加站长 进交流群

领取专属 10元无门槛券

手把手带您无忧上云

扫码加入开发者社群

相关资讯

热门标签

活动推荐

    运营活动

    活动名称
    广告关闭
    领券