mongodb-mongos问题记录

mongodb 启动mongos时报以下错误

Error initializing sharding system: DistributedClockSkewed: clock skew of the cluster ambari01:20000,ambari02:20000,ambari03:20000 is too far out of bounds to allow distributed locking


这个错误是各个节点之间时间不同步,以下为设置时间同步方法

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  #设置时区为北京时间,这里为上海,因为centos里面只有上海。。。    ntpdate us.pool.ntp.org  #时间同步

没有安装ntpdate的可以yum一下    yum install -y ntpdate   

加入定时计划任务,每隔10分钟同步一下时钟   

crontab -e    

把下面的内容粘贴进去保存即可 

0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP