(01)安装zookeeper集群

  本篇记录在3台服务器(192.168.7.151、192.168.7.152、192.168.7.153)上安装zookeeper集群的过程

一、安装过程

  1、解压(zookeeper-3.4.6.tar.gz在/usr/local下)

[[email protected] local]# tar -zxvf zookeeper-3.4.6.tar.gz

  2、配置环境变量

[[email protected] zookeeper-3.4.6]# vim /etc/profile

  添加如下配置:

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$ZOOKEEPER_HOME/bin:$PATH

  3、使配置文件立即生效

[[email protected] zookeeper-3.4.6]# source /etc/profile

  4、修改配置文件(先根据 zoo_sample.cfg 创建一个配置文件)

[[email protected] conf]# cp zoo_sample.cfg zoo.cfg
[[email protected] ~]# vim /usr/local/zookeeper-3.4.6/conf/zoo.cfg

  修改项如下:

dataDir=/usr/local/zookeeper-3.4.6/tmpserver.1=192.168.7.151:2888:3888server.2=192.168.7.152:2888:3888server.3=192.168.7.153:2888:3888

  tmp是新建的目录,存放数据文件,未修改之前的配置是:dataDir=/tmp/zookeeper

  第一台server,ID号是1,通信端口是2888,选举端口是3888。第二台server,ID号是2 ... ...

  5、在数据存放目录(/usr/local/zookeeper-3.4.6/tmp)创建id文件myid(名称不能变),文件内容只有一个1

[[email protected] tmp]# vim myid

  6、在152、153服务器上也安装,远程拷贝过去

[[email protected] local]# scp -r zookeeper-3.4.6/ [email protected]:/usr/local
[[email protected] local]# scp -r zookeeper-3.4.6/ [email protected]:/usr/local

  7、修改152、153的myid文件内容为2、3

  8、修改152、153的环境变量,如步骤2、3。

二、测试是否安装成功

  1、启动,在三台服务器上分别执行启动命令

zkServer.sh start

  2、执行状态命令,查看leader与follower,如果能查出服务是leader还是follower说明集群启动成功

zkServer.sh status

  3、启动客户端命令,在一个服务器上创建一个数据

zkCli.sh
[zk: localhost:2181(CONNECTED) 1] ls /  #查看/目录下只有一个zookeeper
[zookeeper]
[zk: localhost:2181(CONNECTED) 2] create /mydata helloworld  #在/目录下创建一个mydata,里面的内容是helloworld
Created /mydata
[zk: localhost:2181(CONNECTED) 3] ls /  #查看/目录下,多了一个mydata
[zookeeper, mydata]
[zk: localhost:2181(CONNECTED) 4] get /mydata  #查看mydata的内容,输出helloworld
helloworld
cZxid = 0x100000004
ctime = Fri Jan 10 22:12:33 CST 2020
mZxid = 0x100000004
mtime = Fri Jan 10 22:12:33 CST 2020
pZxid = 0x100000004
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 10
numChildren = 0
[zk: localhost:2181(CONNECTED) 5] 

  4、登录另外两台服务器的客户端,执行以下命令,也可以获取第一台服务器写入的数据,验证成功

[zk: localhost:2181(CONNECTED) 1] get /mydata
helloworld
cZxid = 0x100000004
ctime = Fri Jan 10 22:12:33 CST 2020
mZxid = 0x100000004
mtime = Fri Jan 10 22:12:33 CST 2020
pZxid = 0x100000004
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 10
numChildren = 0
[zk: localhost:2181(CONNECTED) 2] 

原文地址:https://www.cnblogs.com/javasl/p/12044446.html

时间: 2024-11-05 11:30:32

(01)安装zookeeper集群的相关文章

Ubuntu16.04安装zookeeper集群

http://apache.fayea.com/zookeeper/ [email protected]:/usr/local/zookeeper-3.4.9# vim /etc/profile #Zookeeper Home export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.9 export PATH=$PATH:$ZOOKEEPER_HOME/bin [email protected]:/usr/local/zookeeper-3.4.9# mki

Linux安装zookeeper集群

测试在Linux虚拟机:node02.node03.node04装入zookeeper集群 1.下载zookeeper.地址:http://archive.apache.org/dist/zookeeper/ 拷贝下载zookeeper放入Linux机器中,我这里放入在software目录下. 解压:zookeeper到指定目录tar  -xf  zookeeper-3.4.6.tar.gz  /opt/ht 配置zookeeper的环境变量:vi  /etc/profile 进入zookeep

安装zookeeper集群及出现的问题

A:安装zookeeper(完全分布式(使用虚拟机安装)) 1.上传zk安装包 2.解压 3.配置(先在一台节点上配置)    3.1添加一个zoo.cfg配置文件    $ZOOKEEPER/conf    mv zoo_sample.cfg zoo.cfg        3.2修改配置文件(zoo.cfg)        dataDir=/itcast/zookeeper-3.4.5/data                server.1=itcast05:2888:3888      

docker 使用compose安装zookeeper集群

新建文件 docker-compose.yml version: '2' services: zookeeper1: image: zookeeper container_name: zk1.cloud ports: - "2181:2181" environment: - SERVER_ID=1 - ADDITIONAL_ZOOKEEPER_1=server.1=0.0.0.0:2888:3888 - ADDITIONAL_ZOOKEEPER_2=server.2=zk2.cloud

Linux下安装zookeeper集群

首先,准备三台Linux虚拟机 三台机器 centos01 :192.168.1.168(lxs001)   centos03 :192.168.1.178(lxs003)   centos03 :192.168.1.188(lxs003)  三台机器 下载 zookeeper: 进入 opt 目录 下载 zookeeper:wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz 解压zookee

安装zookeeper集群

1.时间同步检查 ntpdate time.nist.gov 2.关闭防火墙 service iptables stop 3.上传zookeeper-3.4.6到/root(说明:请自行下载) 4.解压zookeeper-3.4.6 tar -zxvf zookeeper-3.4.6 5.移动zookeeper-3.4.6到/home mv zookeeper-3.4.6 /home cd /home/zookeeper-3.4.6 ls cd conf/ ls 6.创建zookeeper的配置

CentOS 7 安装 zookeeper集群

1.安装jdk yum -y install java-1.8.0-openjdk 2.下载并解压 tar -zxvf zookeeper-3.4.12.tar.gz -C /usr/local 3.改名 cd /usr/localmv zookeeper-3.4.12 zookeeper 上面的操作,三台虚拟机相同 4.修改配置文件 将/conf目录下的zoo_sample.cfg文件拷贝一份, 命名为为zoo.cfgcd /usr/local/zookeeper/confcp zoo_sam

大数据高可用集群环境安装与配置(05)——安装zookeeper集群

1. 下载安装包 登录官网下载安装包 https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 2. 执行命令下载并安装 cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz tar -zxvf zookeeper-3.4.14.tar.gz mv zookeep

centos7 安装zookeeper 集群

data 创建myid  设置1 zookeeper默认端口2181  同步端口 20881 和 30881 设置zoo.cfg文件