xian123 发表于 2017-4-19 09:56:34

RHEL5.5+Zookeeper集群模式安装笔记

  安装环境:
Hyper-V 2008 R2,RHEL5.5,Zookeeper3.4.6
 
  计划:
在三台服务器上安装zookeeper,并实现三者同步:
-16.158.49.120,h1.dssdev
-16.158.49.121,h2.dssdev
-16.158.49.123,h3.dssdev
 
步骤:


[*]下载zookeeper3.4.6,并解压至h1.dssdev的/usr/local/zookeeper

$ pwd
/usr/local/zookeeper/zookeeper-3.4.6
$ ll
total 1564
drwxrwxr-x2 hadoop hadoop    4096 Apr9 06:01 bin
-rwxrwxr-x1 hadoop hadoop   82446 Feb 20 18:14 build.xml
-rwxrwxr-x1 hadoop hadoop   80776 Feb 20 18:14 CHANGES.txt
drwxrwxr-x2 hadoop hadoop    4096 Apr9 05:29 conf
drwxrwxr-x 10 hadoop hadoop    4096 Feb 20 18:14 contrib
drwxrwxr-x2 hadoop hadoop    4096 Feb 20 19:05 dist-maven
drwxrwxr-x6 hadoop hadoop    4096 Feb 20 18:48 docs
-rwxrwxr-x1 hadoop hadoop    1953 Feb 20 18:14 ivysettings.xml
-rwxrwxr-x1 hadoop hadoop    3375 Feb 20 18:14 ivy.xml
drwxrwxr-x4 hadoop hadoop    4096 Feb 20 18:48 lib
-rwxrwxr-x1 hadoop hadoop   11358 Feb 20 18:14 LICENSE.txt
-rwxrwxr-x1 hadoop hadoop   170 Feb 20 18:14 NOTICE.txt
-rwxrwxr-x1 hadoop hadoop    1770 Feb 20 18:14 README_packaging.txt
-rwxrwxr-x1 hadoop hadoop    1585 Feb 20 18:14 README.txt
drwxrwxr-x5 hadoop hadoop    4096 Feb 20 18:14 recipes
drwxrwxr-x8 hadoop hadoop    4096 Feb 20 18:48 src
-rwxrwxr-x1 hadoop hadoop 1340305 Feb 20 18:14 zookeeper-3.4.6.jar
-rwxrwxr-x1 hadoop hadoop   836 Feb 20 18:58 zookeeper-3.4.6.jar.asc
-rwxrwxr-x1 hadoop hadoop      33 Feb 20 18:14 zookeeper-3.4.6.jar.md5
-rwxrwxr-x1 hadoop hadoop      41 Feb 20 18:14 zookeeper-3.4.6.jar.sha1
   
   


[*]修改环境变量

$ vim /etc/profile
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf:
$ source /etc/profile

[*] 修改配置文件zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/zookeeper/data
# 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
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=16.158.49.120:2888:3888
server.2=16.158.49.121:2888:3888
server.3=16.158.49.123:2888:3888

[*]在zoo.cfg中指定的dataDir中创建myid文件,保证每台服务器id不同,如h1.dssdev为1、h2.dssdev为2等
[*]将zookeeper拷贝至其他服务器上
[*]在各台服务器上使用zkServer.sh start或zkServer.sh stop起停zookeeper
[*]使用zkCli.sh –server ip1:port1,ip2:port2,ip3:port3,ip1会被首先链接,后面的ip作为bakcup,如:
   

zkCli.sh -server h1.dssdev:2888,h2.dssdev:2888,h3.dssdev:2888
   
   
  验证:


[*]使用zkCli.sh -server h1.dssdev:2888,h2.dssdev:2888,h3.dssdev:2888链接zookeeper server,执行get / 1注册一个watcher,在根节点下创建或修改一个节点,其他server会收到watch提示
  另,在有2n+1个节点时,zookeeper能容忍n个节点故障,e.g., 如果 zookeeper拥有 5 台机器,那么它就能处理 2 台机器的故障。
   
   
   
页: [1]
查看完整版本: RHEL5.5+Zookeeper集群模式安装笔记