上QQ阅读APP看书,第一时间看更新
2.2.4 ZooKeeper集群安装
HBase不仅依赖Hadoop,还依赖ZooKeeper,接下来搭建ZooKeeper集群。
先在hadoop101服务器上安装ZooKeeper,然后将ZooKeeper相关文件分发到hadoop102和hadoop103服务器上。
(1)下载ZooKeeper安装包
步骤01 进入ZooKeeper官网,选择3.5.9版本的ZooKeeper服务,如图2-11所示。
图2-11 下载ZooKeeper的网页
步骤02 选择对应版本的源码发布包按钮,下载ZooKeeper安装包,如图2-12所示。
图2-12 下载ZooKeeper安装包的网页
(2)上传并解压安装包
步骤01 通过xftp等工具上传已经下载好的ZooKeeper安装包,并把安装包上传到/opt/software/目录中。
安装ZooKeeper的相关命令如下:
#切换到ZooKeeper安装包目录 cd /opt/software/
步骤02 解压ZooKeeper安装包,执行如下命令:
#解压安装包 tar -zxvf zookeeper-3.5.9.tar.gz -C /opt/module/
范例如下:
[root@hadoop101/]#su clay //切换到clay用户 [clay@hadoop101/]$ cd /opt/software/ //切换到安装程序包所在的目录 [clay@hadoop101 software]$ tar -zxvf zookeeper-3.5.9.tar.gz -C /opt/module/ //解压安装包
(3)创建ZooKeeper配置文件
步骤01 执行如下命令切换到ZooKeeper程序目录。
#切换到clay用户 [root@hadoop101/]#su clay #切换到安装程序包所在的目录 [clay@hadoop101/]$ cd /opt/module/zookeeper-3.5.9
步骤02 创建配置文件,执行如下命令:
[clay@hadoop101 software]$ vi zoo.cfg
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/chenjie/zookeeper-3.5.9/tmp #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=hadoop101:2888:3888 server.2=hadoop102:2888:3888 server.3=hadoop103:2888:3888
(4)分发ZooKeeper相关文件并启动
步骤01 在hadoop101服务器上执行如下命令,为其他服务器分发ZooKeeper相关文件。
xsync /opt/module/zookeeper-3.5.9/etc/hadoop/
步骤02 执行上述命令分发文件之后,在各个服务器上执行如下命令启动ZooKeeper服务:
#切换到ZooKeeper程序所在的目录 cd /opt/module/zookeeper-3.5.9/bin #启动ZooKeeper服务 ./zkServer.sh