时间同步及zookeeper安装

本文详细介绍了在Linux环境中进行时间同步的步骤,包括安装ntp服务,配置ntp.conf文件,启动服务并检查同步状态。同时,文章还阐述了Zookeeper的安装过程,包括解压安装包,配置zoo.cfg,创建dataDir与myid文件,以及启动和检查Zookeeper服务的状态。通过这些步骤,可以确保多台服务器的时间同步和Zookeeper集群的正确部署。
摘要由CSDN通过智能技术生成

时间同步及zookeeper安装

时间同步

第一步:安装ntp:yum -y install ntp
第二步:配置/etc/ntp.conf

# 这里修改为本机的IP地址
restrict 本机IP地址 mask 255.255.255.0 nomodify notrap

#下面四个服务地址注掉,改成下面的配置
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

#一台作为同步标准的主机按照下面配置
server 127.127.1.0
fudge 127.127.1.0 stratum 10

#其余几台配置
server 同步标准主机的IP profer

第三步:
启动ntp服务:service ntpd start
设置开机自启:chkconfig ntpd on
第四步:
查看是否设置成功:ntpq -p
查看是否同步成功:ntpstat
在这里插入图片描述
三台显示同步(synchronised)就同步成功了

zookeeper安装

第一步:上传压缩包并解压
第二步:配置conf/zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=50	#这里是同步线程上限,稍微调大一点,也可以不调整
# 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=/opt/zookeeper/zkData		#重点配置
# 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.0=num01:2287:3387
server.1=num02:2287:3387
server.2=num03:2287:3387

该文件原名是zoo.sample.cfg,配置完成后改名为zoo.cfg
第三步:创建上面的dataDir文件夹,并在这个文件夹下面创建myid文件(没有后缀),里面写zoo.cfg文件中对应的server后面的数字即可
第四步:启动服务,运行bin目录下面的zkServer.sh:./zkServer.sh start

启动完成后:运行jps可以看到
在这里插入图片描述
执行命令./zkServer.sh status:可以看到
在这里插入图片描述
Mode为foollower的是从结点,Leader是主结点。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值