ZooKeeper--集群部署安装
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。
搭建ZooKeeper集群,学习zk相关知识。安装ZooKeeper-3.4.5版本。搭建3台机器集群,其具体配置如下所示:
部署3台机器,安装目录:/usr/lib/zookeeper 配置文件目录:/etc/zookeeper1/conf/zoo.cfg 数据目录:/var/zookeeper1/
其具体的配置文件如下所示:
[aaa@qq.com zookeeper]# cat /etc/zookeeper1/conf/zoo.cfg
dataDir=/var/zookeeper1/
clientPort=2181
server.1=xjs-nn1:2888:3888
server.2=xjs-dn01:2888:3888
server.3=xjs-nn2:2888:3888
initLimit=10
tickTime=9000
maxClientCnxns=0
syncLimit=5
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
jaasLoginRenew=3600000
kerberos.removeHostFromPrincipal=true
kerberos.removeRealmFromPrincipal=true
autopurge.purgeInterval=1
autopurge.snapRetainCount=10
配置文件参数简要介绍如下:
dataDir为数据目录存储地址;
clientPort为客户端连接地址端口,一般为2181;
server.id为集群服务信息配置,集群每台服务器都有独立的id,2888端口号是zookeeper服务之间通信的端口,3888端口是zookeeper与其他应用程序通信的端口;
initLimit 是Leader与learner建立连接中 socket通讯read所阻塞的时间(initLimit * tickTime) 如果是Leaner数量较多或者leader的数量很大, 可以增加此值;
tickTime zk中的时间单元,zk中所有时间都是以这个时间为基础,进行整数倍配置的,如session的最小超时时间是2*tickTime, 每隔tickTime发送一个心跳;
maxClientCnxns 默认:60, 一个client与server最大的socket连接数,根据IP区分,设置为0,取消此限制。可以避免DOS攻击;
syncLimit learner与leader建立连接中,socket通讯read阻塞的时间.其中包括数据同步/数据提交等;
后面参数为Kerberos认证配置,以后再研究。
/usr/lib/zookeeper/bin路径下为zk的相关管理命令客户端:
其中zkServer.sh负责管理服务端,其具体用法:
可以启动,关闭,重启以及查看服务状态,查看集群当前的状态:
可知当前集群1个leader以及2个follower
利用zkCli.sh作为客户端来连接服务器进行管理操作
连接服务端zkCli.sh -server ip:port
./zkCli.sh -server 127.0.0.1:2181
./zkCli.sh 默认连接localhost:2181
连接客户端成功:
[aaa@qq.com bin]# ./zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2019-04-10 11:16:13,902 [myid:] - INFO [main:aaa@qq.com] - Client environment:zookeeper.version=3.4.5-transwarp--1, built on 08/25/2017 07:37 GMT
2019-04-10 11:16:13,906 [myid:] - INFO [main:aaa@qq.com] - Client environment:host.name=xjs-nn1
2019-04-10 11:16:13,907 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.version=1.7.0_71
2019-04-10 11:16:13,907 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.vendor=Oracle Corporation
2019-04-10 11:16:13,908 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.home=/usr/java/jdk1.7.0_71/jre
2019-04-10 11:16:13,908 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.class.path=/usr/lib/zookeeper/bin/../build/classes:/usr/lib/zookeeper/bin/../build/lib/*.jar:/usr/lib/zookeeper/bin/../lib/wagon-provider-api-1.0-beta-6.jar:/usr/lib/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/lib/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/lib/zookeeper/bin/../lib/sisu-guice-2.1.7.jar:/usr/lib/zookeeper/bin/../lib/plexus-utils-3.0.22.jar:/usr/lib/zookeeper/bin/../lib/plexus-sec-dispatcher-1.3.jar:/usr/lib/zookeeper/bin/../lib/plexus-interpolation-1.14.jar:/usr/lib/zookeeper/bin/../lib/plexus-component-annotations-1.5.5.jar:/usr/lib/zookeeper/bin/../lib/plexus-classworlds-2.2.3.jar:/usr/lib/zookeeper/bin/../lib/plexus-cipher-1.4.jar:/usr/lib/zookeeper/bin/../lib/netty-all-4.1.5.transwarp.jar:/usr/lib/zookeeper/bin/../lib/netty-3.2.2.Final.jar:/usr/lib/zookeeper/bin/../lib/maven-settings-builder-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-settings-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-repository-metadata-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-plugin-api-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-model-builder-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-model-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-dependency-tree-2.2.jar:/usr/lib/zookeeper/bin/../lib/maven-core-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-compat-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-artifact-3.0.jar:/usr/lib/zookeeper/bin/../lib/maven-aether-provider-3.0.jar:/usr/lib/zookeeper/bin/../lib/log4j-1.2.15.jar:/usr/lib/zookeeper/bin/../lib/jsr305-1.3.9.jar:/usr/lib/zookeeper/bin/../lib/jmxtrans-agent-1.1.1-transwarp.jar:/usr/lib/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/lib/zookeeper/bin/../lib/jdom-1.1.jar:/usr/lib/zookeeper/bin/../lib/jdependency-1.0.jar:/usr/lib/zookeeper/bin/../lib/guava-11.0.2.jar:/usr/lib/zookeeper/bin/../lib/commons-io-2.2.jar:/usr/lib/zookeeper/bin/../lib/asm-util-5.0.3.jar:/usr/lib/zookeeper/bin/../lib/asm-tree-5.0.3.jar:/usr/lib/zookeeper/bin/../lib/asm-commons-5.0.2.jar:/usr/lib/zookeeper/bin/../lib/asm-analysis-5.0.3.jar:/usr/lib/zookeeper/bin/../lib/asm-5.0.2.jar:/usr/lib/zookeeper/bin/../lib/aether-util-1.7.jar:/usr/lib/zookeeper/bin/../lib/aether-util-0.9.0.M2.jar:/usr/lib/zookeeper/bin/../lib/aether-spi-1.7.jar:/usr/lib/zookeeper/bin/../lib/aether-impl-1.7.jar:/usr/lib/zookeeper/bin/../lib/aether-api-1.7.jar:/usr/lib/zookeeper/bin/../zookeeper-3.4.5-transwarp.jar:/usr/lib/zookeeper/bin/../src/java/lib/*.jar:/usr/lib/zookeeper/bin/../conf:
2019-04-10 11:16:13,909 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-04-10 11:16:13,909 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.io.tmpdir=/tmp
2019-04-10 11:16:13,910 [myid:] - INFO [main:aaa@qq.com] - Client environment:java.compiler=<NA>
2019-04-10 11:16:13,910 [myid:] - INFO [main:aaa@qq.com] - Client environment:os.name=Linux
2019-04-10 11:16:13,911 [myid:] - INFO [main:aaa@qq.com] - Client environment:os.arch=amd64
2019-04-10 11:16:13,911 [myid:] - INFO [main:aaa@qq.com] - Client environment:os.version=3.10.0-327.el7.x86_64
2019-04-10 11:16:13,911 [myid:] - INFO [main:aaa@qq.com] - Client environment:user.name=root
2019-04-10 11:16:13,912 [myid:] - INFO [main:aaa@qq.com] - Client environment:user.home=/root
2019-04-10 11:16:13,912 [myid:] - INFO [main:aaa@qq.com] - Client environment:user.dir=/usr/lib/zookeeper/bin
2019-04-10 11:16:13,914 [myid:] - INFO [main:aaa@qq.com] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 aaa@qq.com
Welcome to ZooKeeper!
2019-04-10 11:16:13,940 [myid:] - INFO [main-SendThread(localhost:2181):aaa@qq.com] - Expect server principal: zookeeper/localhost
2019-04-10 11:16:13,943 [myid:] - INFO [main-SendThread(localhost:2181):aaa@qq.com] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2019-04-10 11:16:13,948 [myid:] - INFO [main-SendThread(localhost:2181):aaa@qq.com] - Socket connection established to localhost/127.0.0.1:2181, initiating session
JLine support is enabled
2019-04-10 11:16:13,969 [myid:] - INFO [main-SendThread(localhost:2181):aaa@qq.com] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x1687496f1dc38bc, negotiated timeout = 30000
[zk: 127.0.0.1:2181(CONNECTED) 0]
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
查看命令行支持的命令,可以利用get ls set create delete 实现对于数据的基本增删改查操作。
创建路径以及数据
查看数据
更新数据
删除数据
推荐阅读
-
ZooKeeper--集群部署安装
-
zookeeper集群部署
-
zookeeper集群模式部署
-
使用Fuel快速部署openstack集群 博客分类: 虚拟化 openstack
-
Spark学习_3(Spark集群YARN模式安装)
-
walter的drill笔试之二-安装与部署 博客分类: drill海量数据处理 drill安装部署分布式
-
ZooKeeper的安装 博客分类: 云计算ZooKeeper ZooKeeper云计算集群echo伪分布式
-
FastDFS 5.08 部署与配置(包括老版本卸载) 博客分类: FastDFStracer.conf安装配置部署5.08升级
-
FastDFS 5.08 部署与配置(包括老版本卸载) 博客分类: FastDFStracer.conf安装配置部署5.08升级
-
linux上独立安装部署spark 博客分类: spark spark安装部署linux1.4