Zookeeper简介和安装(四)
2018-06-18 01:47:37来源:未知 阅读 ()
一、简介:
Zookeeper是一个分布式协调服务,提供的服务如下:
命名服务:类似于DNS,但仅对于节点
配置管理:服务配置信息的管理
集群管理:Dubbo使用Zookeeper实现服务治理
分布式锁:选举一个leader,这样某一时刻只有一个服务在干活,当leader出问题时释放锁,立即切到另一个服务
二、下载:
点这里
三、三种安装模式:
单机、真分布集群模式、伪分布集群模式
四、伪分布式集群搭建:
1、进入C:\zookeeper-3.3.6\conf目录,将zoo_sample.cfg拷贝成3份,分别为:zoo1.cfg、zoo2.cfg、zoo3.cfg
zoo1.cfg内容:
#心跳时间 tickTime=2000 #初始连接能容忍最多心跳次数 initLimit=10 #leader与follower之间的通信时长 syncLimit=5 #保存数据的目录 dataDir=C:/zookeeper/zk1 #zk监听端口号 clientPort=2181 # server.1=master:2888:3888 server.2=slave1:2889:3889 server.3=slave2:2890:3890
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. dataDir=C:/zookeeper/zk2/ # the port at which the clients will connect clientPort=2182 server.1=master:2888:3888 server.2=slave1:2889:3889 server.3=slave2:2890:3890
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. dataDir=C:/zookeeper/zk3/ # the port at which the clients will connect clientPort=2183 server.1=master:2888:3888 server.2=slave1:2889:3889 server.3=slave2:2890:3890
2、hosts配置
127.0.0.1 master 127.0.0.1 slave1 127.0.0.1 slave2
3、zk保存数据的目录,zk1目录新建myid的文件,内容为1,zk2目录新建myid的文件,内容为2,以此类推

4、进入C:\zookeeper-3.3.6\bin目录,将zkServer.cmd拷贝成3份,分别为:zkServer-1.cmd、zkServer-2.cmd、zkServer-3.cmd
zkServer-1.cmd内容:
@echo off REM Licensed to the Apache Software Foundation (ASF) under one or more REM contributor license agreements. See the NOTICE file distributed with REM this work for additional information regarding copyright ownership. REM The ASF licenses this file to You under the Apache License, Version 2.0 REM (the "License"); you may not use this file except in compliance with REM the License. You may obtain a copy of the License at REM REM http://www.apache.org/licenses/LICENSE-2.0 REM REM Unless required by applicable law or agreed to in writing, software REM distributed under the License is distributed on an "AS IS" BASIS, REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. setlocal call "%~dp0zkEnv.cmd" set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain set ZOOCFG=..\conf\zoo1.cfg echo on java "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %* endlocal
zkServer-2.cmd和zkServer-3.cmd只是set ZOOCFG指定的cfg文件不一样
5、启动zkServer-1.cmd、zkServer-2.cmd、zkServer-3.cmd

标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Maven安装与配置 2020-06-09
- java环境教程:Tomcat下载,安装,设置为Windows服务,启动 2020-06-09
- Java 简介 2020-06-09
- 黑菜菌的JAVA学习笔记 2020-06-09
- Dubbo+Zookeeper集群案例 2020-06-09
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
