centos时间不同步网络问题

新装的CentOS系统服务器可能设置了错误的,需要调整时区并调整时间.如下是CentOS系统使用NTP来从一个时间服务器同步:
第一步: 把当前时区调整为上海就是+8区,想改其他时区也可以去看看/usr/share/zoneinfo目录;
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
第二步:利用ntpdate同步标准时间
ntpdate us.pool.ntp.org
注:没有安装ntpdate的可以yum一下: yum install -y ntpdate

 

有时候使用过程中突然断电或者终止系统进程也会导致时间不能同步了

 

会报错:

Note: System times on machines may be out of sync. Check system time and time zones.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl.instantiateException(SerializedExceptionPBImpl.java:168)

解决办法:

 date

service ntpd stop        关闭时间服务器

 ntpdate us.pool.ntp.org    更新时间

 service ntpd start        开启

date              查看时间

 

posted @ 2015-11-17 16:19  暗夜小精灵~~  阅读(595)  评论(0编辑  收藏  举报