IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> zookeeper 安装以及简单使用 -> 正文阅读

[大数据]zookeeper 安装以及简单使用

因为我需要使用kafka消息队列。所以就在本机安装一下 安装的时候看到需要用到zookeeper又去学习了一下 zookeeper

官网下载zookeeper文件

https://zookeeper.apache.org/

本人安装版本Apache ZooKeeper 3.7.0    下载tar包

因为我是ubuntu 系统所以我直接浏览器下载 在家目录有个下载包里面

cd 下载

cd ..

在家目录创建一个zookeeper文件夹 然后安装
mkdir zookeeper

接下来将 下载里面的zookerper包 MV到刚刚创建的目录
解压
tar zxvf zookeeper-3.4.13.tar.gz
备份配置文件
cd conf
 cp  configuration.xsl{,.bak}
cp  log4j.properties{,.bak}
cp  zoo_sample.cfg{,.bak}
创建文件存放点
在自己创建的zookeeper文件架下创建一个自定义存放数据的目录

mkdir ZKdata

cd ZKdata


pwd
修改配置文件
cp zoo_sample.cfg zoo.cfg
vim 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=/home/ywz/zookeeper/zookeeper-3.4.13/zkdata
# 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

上面的 dataDir 路径改成刚刚配置文件路径
启动
启动的文件在bin目录下

cd bin/

./zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看状态
./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: standalone   # 表示的是单个主机

如果没启动查看状态的话就是
	ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
停止服务
./zkServer.sh stop

ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
bin目录下的客户端
bin 目录下面有很多的客户端 可以直接./启动 后面不用加任何的参数
	zkServer.sh

客户端如果进去的话则 quit 退出 ls / 查看当前节点
配置参数解读(# 就是翻译)
# 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=/home/ywz/zookeeper/zookeeper-3.4.13/zkdata


# 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
选举机制
半数机制 半数以上可用(奇数最好)

配置文件并没有指定的 Naster 和 Skave 但是工作的时候只有一个节点为Leader 其他的为 Follower Leader是通过内部的选举机制临时产生

假设五个
第一台查看有几台服务器   投票投自己 发现五台选自己的一共就一票 
第二台投自己也是一票 但是第一台没成功 第一台就把票数投在了第二台但是第二台还是没成功
第三台 投自己一票 第一台 第二台 因为没成功 则全投给了第三台 那么第三台就是主
第四台第五台.... 没机会了 
节点类型Node
持久(Persistent)  客户与服务端断开后, 此节点不删除
	每个节点有自己的顺序 所以能区分不同多个节点
短暂(Ephemeral) 客户与服务端断开后, 新节点删除

节点理解

				              /根
				              
     节点|   节点|     	节点|       节点|
分布式就算了 我是开发能够使用kafka就好了 等我有机会部署我在讲 - -
  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2021-07-10 11:34:54  更:2021-07-10 11:35:25 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/5 0:08:45-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码