美文网首页
centos系统同步 网络时间

centos系统同步 网络时间

作者: 彩色的炮灰 | 来源:发表于2021-09-16 16:25 被阅读0次
    使用阿里云oss上传文件配置文件报错如下:

    可以看到提示时间不一致,此时查看centos服务器时间确实和网络时间不同步。

    [root@localhost ~]# ./ossutil64 cp /opt/1.txt oss://backup-yema/test/
    Total num: 1, size: 9,121. Dealed num: 0, Transfer size: 9,121. When error happens.
    average speed 19000(byte/s)
    Error: oss: service returned error: StatusCode=403, ErrorCode=RequestTimeTooSkewed, ErrorMessage="The difference between the request time and the current time is too large.", RequestId=6142FB42EE8B493238084E71, File=/opt/1.txt

    解决方法:centos系统系统同步网络时间
    在解决问题之前,我们首先来了解下面几个知识点:

    1. date命令:

    date

    显示系统时间
    2.hwclock命令 (即hardwareclock系统硬件时间)

    hwclock

    显示硬件时间

    hwclock -w

    将系统时间写入到系统硬件当中
    3.ntpdate
    ntpdate 是一个linux时间同步服务软件
    查看本机是否安装ntpdate服务,如果没有安装,请 yum install -y ntpdate
    同步时间

    1. 输入ntpdate time.nist.gov同步网络时间

    结果:16 Sep 16:14:30 ntpdate[4787]: step time server 132.163.97.6 offset -1210.548432 sec

    出现上述结果代表时间同步成功

    如果上面time.nist.gov服务器同步不了,可以换下面几个时间服务器试试:
    time.nist.gov
    time.nuri.net
    0.asia.pool.ntp.org
    1.asia.pool.ntp.org
    2.asia.pool.ntp.org
    3.asia.pool.ntp.org

    2.同步时间成功后调整硬件时间

    hwclock -w

    执行成功后, 查看系统硬件时间(不出意外的话,现在date和hwclock现实的时间均为internet时间)

    date

    hwclock

    执行上述命令,显示的时间应该一样的

    相关文章

      网友评论

          本文标题:centos系统同步 网络时间

          本文链接:https://www.haomeiwen.com/subject/tkorgltx.html