首页 > 系统相关 >centos安装zookeeper服务

centos安装zookeeper服务

时间:2022-11-11 21:45:15浏览次数:60  
标签:bin www centos zookeeper sh apache 安装 3.8

zookeeper介绍
ZooKeeper 是一个开源的分布式协调服务。它是一个为分布式应用提供一致性服务的软件,分布式应用程序可以基于 Zookeeper 实现诸如数据发布/订阅、负载均衡、命名服务、分布式协调/通知、集群管理、Master 选举、分布式锁和分布式队列等功能。

ZooKeeper 的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。

Zookeeper 保证了如下分布式一致性特性:

顺序一致性
原子性
单一视图
可靠性
实时性(最终一致性)
客户端的读请求可以被集群中的任意一台机器处理,如果读请求在节点上注册了监听器,这个监听器也是由所连接的 zookeeper 机器来处理。对于写请求,这些请求会同时发给其他 zookeeper 机器并且达成一致后,请求才会返回成功。因此,随着 zookeeper 的集群机器增多,读请求的吞吐会提高但是写请求的吞吐会下降。

有序性是 zookeeper 中非常重要的一个特性,所有的更新都是全局有序的,每个更新都有一个唯一的时间戳,这个时间戳称为 zxid(Zookeeper Transaction Id)。而读请求只会相对于更新有序,也就是读请求的返回结果中会带有这个zookeeper 最新的 zxid。

配置java环境

详见文章 centos7配置jdk环境

下载地址:https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz
wget https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz

安装zookeeper

使用命令解压

tar -zxvf apache-zookeeper-3.8.0-bin.tar.gz
cd apache-zookeeper-3.8.0-bin
cd conf
cp zoo_sample.cfg 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=/www/server/apache-zookeeper-3.8.0-bin/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.
#
# https://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.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
#zookeeper集群配置
server.1=192.168.31.20:3188:3288 server.2=192.168.31.21:3188:3288 server.3=192.168.31.22:3188:3288

启动zookeeper

进入文件夹的bin目录

cd bin/
./zkServer.sh start
./zkServer.sh status
ps -ef|grep zookeeper
#配置zk环境变量
vim /etc/profile

ZOOKEEPER_HOME=/www/server/apache-zookeeper-3.8.0-bin
PATH=$PATH:$ZOOKEEPER_HOME/bin
export PATH ZOOKEEPER_HOME PATH
source /etc/profile

设置开机自动启动

#开机自启
vi /usr/lib/systemd/system/zookeeper.service 
[Unit]
Description=zookeeper
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/root/apache-zookeeper-3.7.0-bin/bin/zkServer.sh start
ExecReload=/root/apache-zookeeper-3.7.0-bin/bin/zkServer.sh restart
ExecStop=/root/apache-zookeeper-3.7.0-bin/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target
# 设置自启
systemctl enable zookeeper.service
systemctl daemon-reload

# 查看是否自启
systemctl is-enabled zookeeper.service

# 取消自启
systemctl disable zookeeper.service
systemctl daemon-reload
cd /www/server/apache-zookeeper-3.8.0-bin/bin
vi zkEnv.sh
#添加如下设置
JAVA_HOME="/www/server/jdk-19.0.1"

 

 至此 zookeeper以及集群搭建完成

标签:bin,www,centos,zookeeper,sh,apache,安装,3.8
From: https://www.cnblogs.com/mouseOrCat/p/16882115.html

相关文章

  • CentOS 7 升级OpenSSH 9.1p1记录
    因服务器被扫描出漏洞,需要对OpenSSH升级,遇到一些波折,记录如下。安装配置telnet服务OpenSSH用于远程登录,一旦升级失败用不了,将无法远程登录,安装telnet-server备用。yumi......
  • CentOS中卸载安装JAVA
    一、卸载CentOS中原有JAVA1、查看原有JDKrpm-qa|grepjava2、卸载JDKsudoyum-yremovejava-1.6.0-openjdk-1.6.0.41-1.13.13.1.el6_8.x86_64sudoyum-yrem......
  • 安装oh-my-zsh(zsh)出错,raw.githubusercontent.com 无法连接
    最近换了个电脑,又开始倒腾了。安装oh-my-zsh官网地址是:https://ohmyz.sh/正常来说输入下面的指令就可以了sh-c"$(curl-fsSLhttps://raw.github.com/ohmyzsh/ohm......
  • NC-UClient下载安装应用详解
    aliases:[]tags:"#NC"summary:[UClient下载安装NCC应用详解]product:[NCX]author:[yaenli]date:[2022-11-03]1关键文件客户端UClient主日志:UClien......
  • Docker Compose安装部署Jenkins
    流水线可以让项目发布流程更加清晰,docker可以大大减少Jenkins配置。1、前言数据卷挂载到/var磁盘目录下,因为该磁盘空间较大,后面需要挂载容器数据卷,以防内存吃紧。......
  • UE4怎么安装插件?
    UE4安装插件可以先创建一个目录,创建好之后在浏览器中显示,在多出的插件文件夹中导入外部插件包,关闭程序重新启动就可以了,具体操作步骤如下:1、首先打开编辑——插件;2、新......
  • centos8下mysql创建新用户
    1、进入docker下mysqldockerexec-it容器ID/bin/bashmysql-uroot-p2、修改用户密码UPDATEuserSETpassword=PASSWORD('newpassword')whereUSER......
  • Linux Centos7 部署步骤 mysql
    0.首先查看cpu架构uname-a输出内容中有关键词ARM或aarch64就是ARM架构,有关键词x86_64就是X86架构1.下载mysql8(https://dev.mysql.com/)选择 RedHat......
  • CentOS 7 安装 ElasticSearch 8.5
    参考:InstallElasticsearchfromarchiveonLinuxorMacOS|ElasticsearchGuide[8.5]|ElasticInstallKibanafromarchiveonLinuxormacOS|KibanaGuide[......
  • 【MAC】下载安装Tomcat和jenkins
    一、Tomcat1、官网下载(https://tomcat.apache.org/download-10.cgi)download选择Tomcat最新版(目前是10.0版本)在BinaryDistributions下的Core选择tar.gz下载完成后,解......