下龙山一号楼

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

安装前需要安装好jdk

##
检测集群时间是否同步
检测防火墙是否关闭
检测主机 ip映射有没有配置

 

tar -zxvf jdk-8u221-linux-x64.tar.gz

mv jdk1.8.0_221 /usr/local/
#这里建议用单引号,因为双引号会输出变量的值
echo 'export JAVA_HOME=/usr/local/jdk1.8.0_221' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
source /etc/profile

java -version

tar
-zxf zookeeper-3.4.14.tar.gz
mv zookeeper-3.4.14 /usr/local/

cd /usr/local/zookeeper-3.4.14/conf
cp zoo_sample.cfg zoo.cfg


 修改zoo.cfg配置文件

# The number of milliseconds of each tick

# 心跳的时间间隔,毫秒
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take

# 集群中的follower服务器(F)与leader服务器(L)之间初始连接时能容忍的最多心跳数
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement

# 标识leader与follower之间发送消息,能容忍请求和应答时间长度
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.

# 保存数据的目录,默认情况下zookeeper将写数据的日志文件也保存在这个目录里
dataDir=/tmp/zookeeper
# 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.A=B:C:D中的A是一个数字,表示这个服务器的编号,B是这个服务器的IP地址或主机名(需要写hosts文件),C第一个端口用来集群成员的信息交换,表示这个服务器与集群中的leader服务器交换信息的端口,D是在leader挂掉时专门用来进行选举leader所用的端口。
例:

  1. server.1=hadoop05:2888:3888
  2. server.2=hadoop06:2888:3888
  3. server.3=hadoop07:2888:3888

另外需要在存放数据的目录下创建一个名为 myid 的文件

touch myid

echo "服务器编号" >> myid

这里的服务器编号就是上面的server后面跟着的数字

posted on 2019-09-19 15:26  下龙山王俊凯  阅读(181)  评论(0编辑  收藏  举报