1.最近测试环境出现许多用户多次登录才可成功的情况,查看两台测试环境日志,报错信息为InvalidClaimException: The Token can't be used before 某个时间,经排查分析,可能两台服务器的时间有差值,当在时间较快的服务器生成的token,去时间较慢的服务器验证token,就会出现上述错误,使用clockdiff 192.168.1.138检查两台服务器时间相差1秒多。
2.解决办法就是同步服务器时间,第一通过ntp服务来同步,ntpdate -u XXX,前提是安装了ntp服务,可以通过nptdate -u ntp1.aliyun.com安装。第二可以通过手动设置,当然存在偏差,尽可能使用xshell工具,操作多台机器,发送一次命令 date -s 手动设置时间。
3.ntp常用服务器
国内:
cn.pool.ntp.org 中国开源免费NTP服务器
ntp1.aliyun.com 阿里云NTP服务器
ntp2.aliyun.com 阿里云NTP服务器
time1.aliyun.com 阿里云NTP服务器
time2.aliyun.com 阿里云NTP服务器
国外:
time1.apple.com 苹果NTP服务器
time2.apple.com 苹果NTP服务器
time3.apple.com 苹果NTP服务器
time4.apple.com 苹果NTP服务器
time5.apple.com 苹果NTP服务器
time1.google.com 谷歌NTP服务器
time2.google.com 谷歌NTP服务器
time3.google.com 谷歌NTP服务器
time4.google.com 谷歌NTP服务器
pool.ntp.org 开源免费NTP服务器
4.ntpdate 命令
ntpdate -u cn.pool.ntp.org :网络时间同步命令