ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)
1、下载源码
官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载

这里选择3.4.10进行下载:
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

下载完成后执行以下命令进行解压:
tar -zxvf zookeeper-3.4.10.tar.gz
2、配置Zookeeper
解压之后,在zookeeper目录下创建以下目录:
- [fendo@localhost ~]$ cd zookeeper-3.4.10/
- [fendo@localhost zookeeper-3.4.10]$ mkdir data
- [fendo@localhost zookeeper-3.4.10]$ mkdir logs
将zookeeper-3.4.10/conf目录下的zoo_sample.cfg文件拷贝一份,命名为zoo.cfg
[fendo@localhost conf]$ cp zoo_sample.cfg zoo.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/fendo/zookeeper-3.4.10/data
- dataLogDir=/home/fendo/zookeeper-3.4.10/logs
- # 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
- server.1=192.168.84.130:2888:3888

其中:
2888端口号是zookeeper服务之间通信的端口。
3888是zookeeper与其他应用程序通信的端口。
然后在dataDir=/home/fendo/zookeeper-3.4.10/data下创建myid文件(编辑myid文件,并在对应的IP的机器上输入对应的编号。如在zookeeper上,myid 文件内容就是1。如果只在单点上进行安装配置,那么只有一个server.1)
vim myid
fendo用户下修改.bash_profile,增加zookeeper配置:
vim /home/fendo/.bash_profile
- # zookeeper env export
- ZOOKEEPER_HOME=/home/fendo/zookeeper-3.4.10 export
- PATH=$ZOOKEEPER_HOME/bin:$PATH

使配置文件生效
source /home/fendo/.bash_profile
关闭防火墙
切换到root用户下,执行以下命令:
systemctl stop firewalld.service
3、测试Zookeeper
启动并测试zookeeper(要用普通用户启动,不要用root):
- #使用fendo用户到/home/fendo/zookeeper-3.4.10/bin目录中执行
- ./zkServer.sh start
- #查看进程
- jps
- 其中,QuorumPeerMain是zookeeper进程,启动正常。
- #查看状态
- ./zkServer.sh status
- #服务器输出信息
- tail -500f zookeeper.out
- #停止zookeeper进程
- ./zkServer.sh stop
设置zookeeper服务开机启动
- # 切换到/etc/rc.d/init.d/目录下
- cd /etc/rc.d/init.d
- # 创建zookeeper文件
- touch zookeeper
- #更新权限
- chmod +x zookeeper
- #编辑文件,在zookeeper里面输入如下内容
- #!/bin/bash
- #chkconfig:2345 20 90
- #description:zookeeper
- #processname:zookeeper
- export JAVA_HOME=/user/local/java/jdk1.7.0_79
- export PATH=$JAVA_HOME/bin:$PATH
- case $1 in
- start)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh start;;
- stop)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh stop;;
- status)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh status;;
- restart)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh restart;;
- *) echo "require start|stop|status|restart" ;;
- esac

然后我们就可以用service zookeeper start/stop来启动停止zookeeper服务了
使用命令把zookeeper添加到开机启动里面
- chkconfig zookeeper on
- chkconfig --add zookeeper
添加完成之后接这个使用chkconfig --list 来看看我们添加的zookeeper是否在里面。

ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)的更多相关文章
- centos7下安装zookeeper&zookeeper集群的搭建
一.centos7下安装zookeeper 1.zookeeper 下载地址 https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 2.安装步骤 ...
- Linux(Centos7)下安装 zookeeper docker版 集群
为了省去麻烦的软件安装,现在开发环境需要的软件越来越习惯于docker安装了,先看下安装后的截图,开发环境正在启动的容器 1.首先系统需要先支持docker …… 由于之前安装几次都没有做流程记录,在 ...
- Centos7下安装ZooKeeper
1.下载源码 zookeeper 需要jdk的支持,需要先安装jdk 官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载 ...
- centos7上安装zookeeper
centos7上安装zookeeper 1 准备工作 1.准备服务器,本次安装采用 centos7系统.内存2G.存储60G的虚拟机服务器一台: 2.服务器安装java环境: 参考文章<cent ...
- Windows下安装ZooKeeper
Windows下安装ZooKeeper 一.简介 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组 ...
- Linux下安装Zookeeper
Zookeeper是一个协调服务,可以用它来作为配置维护.名字服务.分布式部署: 下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路. 一.Zookeeper下载 [ro ...
- 如何在Centos7上安装zookeeper 多实例
一.如何在Centos7上安装zookeeper 多实例 cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zoo ...
- Storm(1)-centos7下安装单机版Strom
1.所需软件: jdk8.zookeeper.storm 2.安装zookeeper单机版 下载:http://zookeeper.apache.org/releases.html#download ...
- Win10下安装zookeeper
Win10下安装zookeeper 注册中心zookeeper的安装 0.去Apache官网下载zookeeper http://zookeeper.apache.org/ 2.找到解压路径的conf ...
随机推荐
- IOS Core Image之二
在上篇博客IOS Core Image之一中了解了下CIImage.CIFilter.CIContext三个类的使用,这篇了解下滤镜链(多滤镜)和人脸检测(不是人脸识别). 一.多滤镜 1.有些效果不 ...
- io多大合适
MySQL的cpu iowait值,<=1/(number of cores).例如,如果是8核的,io wait 应<=12%. "Monitor DB CPU IO wait ...
- winform从table1获取需要的数据转存储到table2中
小技术一个,记录一下 ,以下记录的是用两种方式来实现,数据表的转移 table转存数据之前首先要明确两个函数: Add():是指在最后一行添加一行 InsertAt():可以插入到表中的指定行 需求: ...
- Asp.Net 之字符串和集合的使用
一:object:所有类的基类,所有类都直接或者间接继承自object 二:string 字符串的定义:string str=”” string str=new string(new char[ ...
- 十五、curator recipes之DistributedQueue
简介 curator实现了先入先出的分布式消息队列,它采用的是zookeeper的持久化有序节点. 官方文档:http://curator.apache.org/curator-recipes/dis ...
- Spring Boot学习笔记(二)全局捕获异常处理
非常简单只需要创建自己的异常处理类,加上两个注解,就可以了
- java:模拟队列操作
import java.util.LinkedList; public class Myqueue { private LinkedList<Object> linkedList; pub ...
- poj 1811 Prime Test 大数素数测试+大数因子分解
Prime Test Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 27129 Accepted: 6713 Case ...
- C/C++:判断机器是32位还是64位
要求是不使用sizeof,一开始写了个看似可以,但是有问题的方法: long* a = NULL; ; int n = (char*)b - (char*)a; 这个方法等价于sizeof(long) ...
- csharp: Linq keyword example
/// <summary> /// http://www.dotnetperls.com/linq /// </summary> public partial class Li ...