首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

ZooKeeper学习之集群搭建

1.2名字服务 名字服务这个就很好理解了。比如为了通过网络访问一个系统,我们得知道对方的 IP 地址,但是 IP 地址对人非常不友好,这个时候我们就需要使用域名来访问。但是计算机是 不能是域名的。怎么办呢?如果我们每台机器里都备有一份域名到 IP 地址的映射,这个倒 是能解决一部分问题,但是如果域名对应的 IP 发生变化了又该怎么办呢?于是我们有了 DNS 这个东西。我们只需要访问一个大家熟知的(known)的点,它就会告诉你这个域名对应 的 IP 是什么。在我们的应用中也会存在很多这类问题,特别是在我们的服务特别多的时候, 如果我们在本地保存服务的地址的时候将非常不方便,但是如果我们只需要访问一个大家都 熟知的访问点,这里提供统一的入口,那么维护起来将方便得多了。

03

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

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

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

04
领券