部署zookeeper实践

1.解压zookeeper

2.设置环境变量

[email protected]:~/zookeeper-3.4.6/conf$ sudo vim /etc/profile

export JAVA_HOME=/usr/programs/jdk1.7.0_65

export HADOOP_HOME=/home/hadoop/hadoop-1.2.1

export HADOOP_CONF_DIR=/home/hadoop/hadoop-1.2.1/conf

export MAHOUT_HOME=/home/hadoop/mahout-distribution-0.9

export MAHOUT_CONF_DIR=/home/hadoop/mahout-distribution-0.9/conf

export ZOOKEEPER_HOME=/home/hadoop/zookeeper-3.4.6

export PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$MAHOUT_HOME/bin:$PATH

3.新建zookeeper临时目录

[email protected]:~/zookeeper-3.4.6$ mkdir temp

4.修改文件 zoo_sample.cfg

[email protected]:~/zookeeper-3.4.6/conf$ sudo vim zoo_sample.cfg

修改dataDir=/home/hadoop/zookeeper-3.4.6/temp

增加

server.0=namenode:2888:3888

server.1=datanode1:2888:3888

server.2=datanode2:2888:3888

5.重命名zoo.sample.cfg

[email protected]:~/zookeeper-3.4.6/conf$ mv zoo_sample.cfg zoo.cfg

6.在第3步创建的文件夹下面新建文件,内容为0

[email protected]:~/zookeeper-3.4.6/temp$ vim myid

0

7.把zookeeper复制到各个节点

scp -r zookeeper-3.4.6/ [email protected]:/home/hadoop/

scp -r zookeeper-3.4.6/ [email protected]:/home/hadoop/

8.修改各个节点的myid

[email protected]:~/zookeeper-3.4.6$ ssh datanode1

[email protected]:~$ cd zookeeper-3.4.6/temp/

[email protected]:~/zookeeper-3.4.6/temp$ vim myid

1

[email protected]:~/zookeeper-3.4.6$ ssh datanode2

[email protected]:~$ cd zookeeper-3.4.6/temp/

[email protected]:~/zookeeper-3.4.6/temp$ vim myid

2

9.开启zookeeper

[email protected]:~/zookeeper-3.4.6/bin$ zkServer.sh start

JMX enabled by default

Using config: /home/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

你会发现多了一个zookeeper.out的文件,并且里面是报错的,报错的原因是其他节点没有开zookeeper,你得按照上面的方式在每个节点开启zookeeper

[email protected]:~/zookeeper-3.4.6/bin$ ls

README.txt  zkCleanup.sh  zkCli.cmd  zkCli.sh  zkEnv.cmd  zkEnv.sh  zkServer.cmd  zkServer.sh  zookeeper.out

10.一个错误

如果你zookeeper的环境变量没有配,会出现这样的情况

[email protected]:~/zookeeper-3.4.6/bin$ sh zkServer.sh

JMX enabled by default

zkServer.sh: 81: /home/hadoop/zookeeper-3.4.6/bin/zkEnv.sh: Syntax error: "(" unexpected (expecting "fi")

11.命令行的操作

进入命令行

[email protected]:~/zookeeper-3.4.6/bin$ zkCli.sh

Connecting to localhost:2181

2014-11-16 01:18:30,600 [myid:] - INFO  [main:[email protected]] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT

2014-11-16 01:18:30,604 [myid:] - INFO  [main:[email protected]] - Client environment:host.name=namenode

2014-11-16 01:18:30,605 [myid:] - INFO  [main:[email protected]] - Client environment:java.version=1.7.0_65

2014-11-16 01:18:30,608 [myid:] - INFO  [main:[email protected]] - Client environment:java.vendor=Oracle Corporation

2014-11-16 01:18:30,608 [myid:] - INFO  [main:[email protected]] - Client environment:java.home=/usr/programs/jdk1.7.0_65/jre

2014-11-16 01:18:30,609 [myid:] - INFO  [main:[email protected]] - Client environment:java.class.path=/home/hadoop/zookeeper-3.4.6/bin/../build/classes:/home/hadoop/zookeeper-3.4.6/bin/../build/lib/*.jar:/home/hadoop/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/hadoop/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/home/hadoop/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/home/hadoop/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/home/hadoop/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/home/hadoop/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/home/hadoop/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/home/hadoop/zookeeper-3.4.6/bin/../conf:

2014-11-16 01:18:30,610 [myid:] - INFO  [main:[email protected]] - Client environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib

2014-11-16 01:18:30,610 [myid:] - INFO  [main:[email protected]] - Client environment:java.io.tmpdir=/tmp

2014-11-16 01:18:30,611 [myid:] - INFO  [main:[email protected]] - Client environment:java.compiler=<NA>

2014-11-16 01:18:30,614 [myid:] - INFO  [main:[email protected]] - Client environment:os.name=Linux

2014-11-16 01:18:30,614 [myid:] - INFO  [main:[email protected]] - Client environment:os.arch=i386

2014-11-16 01:18:30,615 [myid:] - INFO  [main:[email protected]] - Client environment:os.version=3.5.0-23-generic

2014-11-16 01:18:30,615 [myid:] - INFO  [main:[email protected]] - Client environment:user.name=hadoop

2014-11-16 01:18:30,615 [myid:] - INFO  [main:[email protected]] - Client environment:user.home=/home/hadoop

2014-11-16 01:18:30,616 [myid:] - INFO  [main:[email protected]] - Client environment:user.dir=/home/hadoop/zookeeper-3.4.6/bin

2014-11-16 01:18:30,618 [myid:] - INFO  [main:[email protected]] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 [email protected]

Welcome to ZooKeeper!

2014-11-16 01:18:30,653 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)

2014-11-16 01:18:30,665 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Socket connection established to localhost/127.0.0.1:2181, initiating session

JLine support is enabled

2014-11-16 01:18:30,679 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x49b7dc68450002, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[zk: localhost:2181(CONNECTED) 0] ls /

[zookeeper]

[zk: localhost:2181(CONNECTED) 1] ls /zookeeper

[quota]

[zk: localhost:2181(CONNECTED) 2] ls /zookeeper/quota

[]

[zk: localhost:2181(CONNECTED) 3] create /key value

Created /key

[zk: localhost:2181(CONNECTED) 5] ls /

[key, zookeeper]

[zk: localhost:2181(CONNECTED) 6] get /key

value

cZxid = 0x100000006

ctime = Sun Nov 16 01:20:15 PST 2014

mZxid = 0x100000006

mtime = Sun Nov 16 01:20:15 PST 2014

pZxid = 0x100000006

cversion = 0

dataVersion = 0

aclVersion = 0

ephemeralOwner = 0x0

dataLength = 5

numChildren = 0

12.测试zookeeper的一致性

在上一步(11.命令行的操作)里面,我们在namenode里面往zookeeper里面放了key,现在我们看看在其他节点datanode1是否也会出现这个

[email protected]:~/zookeeper-3.4.6/bin$ ssh datanode1

[email protected]:~$ zkCli.sh

[zk: localhost:2181(CONNECTED) 2] get /key

value

cZxid = 0x100000006

ctime = Sun Nov 16 01:20:15 PST 2014

mZxid = 0x100000006

mtime = Sun Nov 16 01:20:15 PST 2014

pZxid = 0x100000006

cversion = 0

dataVersion = 0

aclVersion = 0

ephemeralOwner = 0x0

dataLength = 5

numChildren = 0

也是出现了key文件,表示在各个节点是有同步的

13.最后补充一个查看mode的命令

[email protected]:~/zookeeper-3.4.6/bin$ zkServer.sh status

JMX enabled by default

Using config: /home/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: leader

时间: 2024-11-05 13:04:22

部署zookeeper实践的相关文章

Elasticstack 5.1.2 集群日志系统部署及实践

Elasticstack 5.1.2 集群日志系统部署及实践 一.ELK Stack简介 ELK Stack 是Elasticsearch.Logstash.Kibana三个开源软件的组合,在实时数据检索和分析场合,三者通常是配合共用的. 可参考:https://www.elastic.co/products 二.Elasticstack重要组件 Elasticsearch: 准实时索引 Logtash: 收集数据,配置使用 Ruby DSL Kibana 展示数据,查询聚合,生成报表 Kafk

单台服务器部署zookeeper集群

单台部署集群 不建议使用单台部署多台服务,因为并没有实现冗余.使用多台服务器部署zookeeper集群才是生产环境使用的方案. 系统环境 [[email protected] ~]# uname -rm 2.6.32-504.el6.x86_64 x86_64 [[email protected] ~]# cat/etc/redhat-release CentOS release 6.6 (Final) 设置java堆 交换会严重降低zookeeper的性能,所以设置java对大小非常重要.为了

多台服务器部署zookeeper服务器

系统环境 # uname -rm 2.6.32-504.el6.x86_64 x86_64 # cat  /etc/redhat-release CentOS release 6.6 (Final) 服务器角色 主机名 IP node1 192.168.56.3 node2 192.168.56.4 node3 192.168.56.5 设置java堆 [[email protected] ~]# vim   /app/zookeeper/conf/java.env exportJVMFLAGS

Cobbler自动化部署最佳实践

第1章 Cobbler自动化部署最佳实践 运维自动化在生产环境中占据着举足轻重的地位,尤其是面对几百台,几千台甚至几万台的服务器时,仅仅是安装操作系统,如果不通过自动化来完成,根本是不可想象的. 面对生产环境中不同服务器的需求,该如何实现批量部署多版本的操作系统呢?Cobbler便可以的满足这一实际需求,实现多版本操作系统批量部署. 笔者QQ:572891887 Linux架构交流群:471443208 1.1 Cobbler简介 Cobbler是一个快速网络安装linux的服务,而且在经过调整

部署Zookeeper集群

本文是针对大数据开发环境来写的,配置比较简单.zookeeper的介绍.工作原理.特点自行查阅某度百科,说的非常明白.再次需要强调一下,zookeeper集群中的机器节点数是2n-1(奇数)的. 准备工作: 下载 zookeeper-3.4.6.tar.gz http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz 虚拟机环境:(本文使用的配置) ip地址         hostname 1

mesos 集群安装部署zookeeper(2)

三:集群安装配置 ############################################################## 配置zookeeper集群    (172.16.7.12~13 执行) ############################################################### 1:部署环境介绍: 服务器IP地址主机名安装服务 172.16.7.12ctn-7-12.ptmind.com zookeeper   myid=1 17

Linux环境快速部署Zookeeper集群

一.部署前准备: 1.下载ZooKeeper的安装包:http://zookeeper.apache.org/releases.html 我下载的版本是zookeeper-3.4.9. 2.将下载的zookeeper-3.4.9包放到/opt目录下,目录结构如下图所示: 3.在/tmp目录下新建一个zookeeper目录,并在zookeeper目录下新建一个data目录. 4.三台linux系统的ip: ip1:10.43.98.6 ip2:10.43.98.8 ip3:10.43.98.18

ubuntu14.04 server 部署 zookeeper 集群服务器

zookeeper是什么? Apache ZooKeeper 是一个面向分布式应用程序的高性能协调服务器.它使用一个简单的接口暴露公共服务(比如命名和配置管理.同步和组服务),让用户不必从头开始编程.它为实现共识.组管理.领导者选举和到场协议(presence protocol)配备了现成的支持. 下面是我在ubuntu14.04 server中部署 zookeeper集群服务器的经验 zookeeper集群服务器的部署 1.安装jdk 之前安装jdk都是自己手动配置环境,这次为了偷懒就使用了a

单台机器部署zookeeper集群

做测试没有多台机器又不想做虚拟机, 通过单独配置zoo.conf实现单机器部署zookeeper集群. 1. 集群配置文件编写 zookeeper服务1: clientPort=2181 dataDir=/var/data/zookeeper/1.machine tickTime=2000 initLimit=5 syncLimit=2 server.1=127.0.0.1:20881:30881 server.2=127.0.0.1:20882:30882 server.3=127.0.0.1