zookeeper下载安装部署_zookeeper部署(1),2024年最新34岁大数据开发开发大叔感慨-程序员宅基地

技术标签: 2024年程序员学习  zookeeper  debian  大数据  

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip204888 (备注大数据)
img

正文

mkdir -p /usr/local/zookeeper-3.4.11/temp/zk
cd /usr/local/zookeeper-3.4.11/temp/zk
mkdir data1
mkdir data2
mkdir data3
mkdir log1
mkdir log2
mkdir log3

分别在data1、data2、data3目录下创建myid文件,并分别写入1、2、3,代表zookeeper服务的id

echo 1 > data1/myid
echo 2 > data2/myid
echo 3 > data3/myid


复制三个配置文件:



cp zoo_sample.cfg zoo1.cfg
cp zoo_sample.cfg zoo2.cfg
cp zoo_sample.cfg zoo3.cfg


分别修改zoo1.cfg、zoo2.cfg和zoo3.cfg三个配置文件,这三个配置文件的区别就在于dataDir、dataLogDir 和 clientPort 的不同。


zoo1.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=D:/MySoftware/Install/tools/zookeeper/data
#dataLogDir=D:/MySoftware/Install/tools/zookeeper/log
dataDir=/usr/local/zookeeper-3.4.11/temp/zk/data1
dataLogDir=/usr/local/zookeeper-3.4.11/temp/zk/log1

the port at which the clients will connect

clientPort=2181

server.1=192.168.1.128:2888:3888
server.2=192.168.1.128:2889:3889
server.3=192.168.1.128:2890:3890

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

Metrics Providers

https://prometheus.io Metrics Exporter

#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true


zoo2.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=D:/MySoftware/Install/tools/zookeeper/data
#dataLogDir=D:/MySoftware/Install/tools/zookeeper/log
dataDir=/usr/local/zookeeper-3.4.11/temp/zk/data2
dataLogDir=/usr/local/zookeeper-3.4.11/temp/zk/log2

the port at which the clients will connect

clientPort=2182

server.1=192.168.1.128:2888:3888
server.2=192.168.1.128:2889:3889
server.3=192.168.1.128:2890:3890

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

Metrics Providers

https://prometheus.io Metrics Exporter

#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true


zoo3.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=D:/MySoftware/Install/tools/zookeeper/data
#dataLogDir=D:/MySoftware/Install/tools/zookeeper/log
dataDir=/usr/local/zookeeper-3.4.11/temp/zk/data3
dataLogDir=/usr/local/zookeeper-3.4.11/temp/zk/log3

the port at which the clients will connect

clientPort=2183

server.1=192.168.1.128:2888:3888
server.2=192.168.1.128:2889:3889
server.3=192.168.1.128:2890:3890

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

Metrics Providers

https://prometheus.io Metrics Exporter

#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true



### 3.2、配置环境变量



修改**/etc/profile**文件,在文件最后加上如下配置:



#set zookeeper
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.11
export PATH= J A V A H O M E / b i n : JAVA_HOME/bin: JAVAHOME/bin:JRE_HOME/bin: H A D O O P H O M E / b i n : HADOOP_HOME/bin: HADOOPHOME/bin:ZOOKEEPER_HOME/bin: P A T H : PATH: PATH:HOME/bin


然后执行 **source /etc/profile** 命令使修改立即生效。



### 3.3、启动zookeeper



进入到zookeeper的bin目录下,分别执行下面三个命令,启动zookeeper。



./zkServer.sh start zoo1.cfg
./zkServer.sh start zoo2.cfg
./zkServer.sh start zoo3.cfg


查看zookeeper的状态:


通过下面的命令可以查看三个server哪个是 leader,哪个是follower:



./zkServer.sh status zoo1.cfg
./zkServer.sh status zoo2.cfg
./zkServer.sh status zoo3.cfg


通过客户端连接zookeeper,可以查看zookeeper的节点。



./zkCli.sh -server 192.168.1.128:2181



## 4、集群部署zookeeper



这里以三台计算机为例,在三台计算机上实现zookeeper的集群部署。在三台计算机上都下载zookeeper-3.4.11.tar.gz压缩包,然后解压成zookeeper-3.4.11目录。下面演示先在一台计算机上操作,剩下两台计算机的操作与这一台完全相同。



### 4.1、修改配置文件



类似于伪集群部署,先在 /usr/local/zookeeper-3.4.11 目录下创建 temp/zk子目录,并在temp/zk目录下创建data和logs目录。另外在data目录下创建myid文件,并在myid文件中写入一个1~255之间的任意一个数字,比如为1。这三台计算机中的myid文件的内容都不能相同。假设另两台的myid的数字分别是2和3。



mkdir -p /usr/local/zookeeper-3.4.11/temp/zk
cd /usr/local/zookeeper-3.4.11/temp/zk
mkdir data
mkdir log

在data目录下创建myid文件,并写入1,代表zookeeper服务的id

echo 1 > data1/myid


执行如下命令:mv  zoo\_sample.cfg  zoo.cfg 将zoo\_sample.cfg重命名为zoo.cfg,或者执行 cp  zoo\_sample.cfg  zoo.cfg 生成zoo.cfg文件,然后修改zoo.cfg文件。


在三台计算机的zoo.cfg中都加入下面三行(三台计算机的zoo.cfg内容可以完全相同):



server.1=192.168.1.128:2888:3888
server.2=192.168.1.129:2888:3888
server.3=192.168.1.130:2888:3888


server.X=A:B:C,如果配置的是伪集群模式,三个server的ip地址都相同,所以各个server的B, C参数必须不同。这里是**集群模式,三个****server****的****ip****地址不同,故****B****、****C****可以相同**。



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=D:/MySoftware/Install/tools/zookeeper/data
#dataLogDir=D:/MySoftware/Install/tools/zookeeper/log
dataDir=/usr/local/zookeeper-3.4.11/temp/zk/data
dataLogDir=/usr/local/zookeeper-3.4.11/temp/zk/log

the port at which the clients will connect

clientPort=2181

server.1=192.168.1.128:2888:3888
server.2=192.168.1.129:2888:3888
server.3=192.168.1.130:2888:3888

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

Metrics Providers

https://prometheus.io Metrics Exporter

#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true


clientPort是客户端连接zookeeper服务器的端口,由于这里是集群部署,每台zookeeper服务器的ip地址都不相同(如上面所示),所以**三台服务器的****clientPort****可以相同**。客户端通过下面的命令与其中一个zookeeper服务器建立连接(这里以ip为192.168.1.128的主机为例):


**命令:****bash zkCli.sh -server 192.168.1.128:2181** **以主机号****192.168.1.128****,端口号****2181****连接。**



### 3.2、配置环境变量



修改**/etc/profile**文件,在文件最后加上如下配置:



#set zookeeper
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.11
export PATH= J A V A H O M E / b i n : JAVA_HOME/bin: JAVAHOME/bin:JRE_HOME/bin: H A D O O P H O M E / b i n : HADOOP_HOME/bin: HADOOPHOME/bin:ZOOKEEPER_HOME/bin: P A T H : PATH: PATH:HOME/bin


然后执行 **source /etc/profile** 命令使修改立即生效。



### 3.3、启动zookeeper



在三台计算机上都要进入到zookeeper的bin目录下,执行下面的命令:


**./zkServer.sh start zoo.cfg**



./zkServer.sh start zoo.cfg


在三台计算机上都要进入到zookeeper的bin目录下,执行下面的命令查看zookeeper的状态:


**./zkServer.sh status zoo.cfg**



./zkServer.sh status zoo.cfg


客户端通过下面的命令连接zookeeper服务器,可以查看zookeeper的节点。


**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)**
![img](https://img-blog.csdnimg.cn/img_convert/d8f09bf5e734249b5223d2211dd1a1a9.png)

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

r的bin目录下,执行下面的命令查看zookeeper的状态:


**./zkServer.sh status zoo.cfg**



./zkServer.sh status zoo.cfg


客户端通过下面的命令连接zookeeper服务器,可以查看zookeeper的节点。


**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)**
[外链图片转存中...(img-tSXGHR9x-1713159827005)]

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/2401_84167005/article/details/137778111

智能推荐

while循环&CPU占用率高问题深入分析与解决方案_main函数使用while(1)循环cpu占用99-程序员宅基地

文章浏览阅读3.8k次,点赞9次,收藏28次。直接上一个工作中碰到的问题,另外一个系统开启多线程调用我这边的接口,然后我这边会开启多线程批量查询第三方接口并且返回给调用方。使用的是两三年前别人遗留下来的方法,放到线上后发现确实是可以正常取到结果,但是一旦调用,CPU占用就直接100%(部署环境是win server服务器)。因此查看了下相关的老代码并使用JProfiler查看发现是在某个while循环的时候有问题。具体项目代码就不贴了,类似于下面这段代码。​​​​​​while(flag) {//your code;}这里的flag._main函数使用while(1)循环cpu占用99

【无标题】jetbrains idea shift f6不生效_idea shift +f6快捷键不生效-程序员宅基地

文章浏览阅读347次。idea shift f6 快捷键无效_idea shift +f6快捷键不生效

node.js学习笔记之Node中的核心模块_node模块中有很多核心模块,以下不属于核心模块,使用时需下载的是-程序员宅基地

文章浏览阅读135次。Ecmacript 中没有DOM 和 BOM核心模块Node为JavaScript提供了很多服务器级别,这些API绝大多数都被包装到了一个具名和核心模块中了,例如文件操作的 fs 核心模块 ,http服务构建的http 模块 path 路径操作模块 os 操作系统信息模块// 用来获取机器信息的var os = require('os')// 用来操作路径的var path = require('path')// 获取当前机器的 CPU 信息console.log(os.cpus._node模块中有很多核心模块,以下不属于核心模块,使用时需下载的是

数学建模【SPSS 下载-安装、方差分析与回归分析的SPSS实现(软件概述、方差分析、回归分析)】_化工数学模型数据回归软件-程序员宅基地

文章浏览阅读10w+次,点赞435次,收藏3.4k次。SPSS 22 下载安装过程7.6 方差分析与回归分析的SPSS实现7.6.1 SPSS软件概述1 SPSS版本与安装2 SPSS界面3 SPSS特点4 SPSS数据7.6.2 SPSS与方差分析1 单因素方差分析2 双因素方差分析7.6.3 SPSS与回归分析SPSS回归分析过程牙膏价格问题的回归分析_化工数学模型数据回归软件

利用hutool实现邮件发送功能_hutool发送邮件-程序员宅基地

文章浏览阅读7.5k次。如何利用hutool工具包实现邮件发送功能呢?1、首先引入hutool依赖<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.19</version></dependency>2、编写邮件发送工具类package com.pc.c..._hutool发送邮件

docker安装elasticsearch,elasticsearch-head,kibana,ik分词器_docker安装kibana连接elasticsearch并且elasticsearch有密码-程序员宅基地

文章浏览阅读867次,点赞2次,收藏2次。docker安装elasticsearch,elasticsearch-head,kibana,ik分词器安装方式基本有两种,一种是pull的方式,一种是Dockerfile的方式,由于pull的方式pull下来后还需配置许多东西且不便于复用,个人比较喜欢使用Dockerfile的方式所有docker支持的镜像基本都在https://hub.docker.com/docker的官网上能找到合..._docker安装kibana连接elasticsearch并且elasticsearch有密码

随便推点

Python 攻克移动开发失败!_beeware-程序员宅基地

文章浏览阅读1.3w次,点赞57次,收藏92次。整理 | 郑丽媛出品 | CSDN(ID:CSDNnews)近年来,随着机器学习的兴起,有一门编程语言逐渐变得火热——Python。得益于其针对机器学习提供了大量开源框架和第三方模块,内置..._beeware

Swift4.0_Timer 的基本使用_swift timer 暂停-程序员宅基地

文章浏览阅读7.9k次。//// ViewController.swift// Day_10_Timer//// Created by dongqiangfei on 2018/10/15.// Copyright 2018年 飞飞. All rights reserved.//import UIKitclass ViewController: UIViewController { ..._swift timer 暂停

元素三大等待-程序员宅基地

文章浏览阅读986次,点赞2次,收藏2次。1.硬性等待让当前线程暂停执行,应用场景:代码执行速度太快了,但是UI元素没有立马加载出来,造成两者不同步,这时候就可以让代码等待一下,再去执行找元素的动作线程休眠,强制等待 Thread.sleep(long mills)package com.example.demo;import org.junit.jupiter.api.Test;import org.openqa.selenium.By;import org.openqa.selenium.firefox.Firefox.._元素三大等待

Java软件工程师职位分析_java岗位分析-程序员宅基地

文章浏览阅读3k次,点赞4次,收藏14次。Java软件工程师职位分析_java岗位分析

Java:Unreachable code的解决方法_java unreachable code-程序员宅基地

文章浏览阅读2k次。Java:Unreachable code的解决方法_java unreachable code

标签data-*自定义属性值和根据data属性值查找对应标签_如何根据data-*属性获取对应的标签对象-程序员宅基地

文章浏览阅读1w次。1、html中设置标签data-*的值 标题 11111 222222、点击获取当前标签的data-url的值$('dd').on('click', function() { var urlVal = $(this).data('ur_如何根据data-*属性获取对应的标签对象

推荐文章

热门文章

相关标签