码迷,mamicode.com
首页 > 系统相关 > 详细

linux时间同步

时间:2019-06-20 11:11:39      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:修改时间   extras   上海   tar   packages   --   ntp服务   com   updating   

虚拟机时间同步:

[root@localhost ~]# date
Wed Jun 19 22:17:50 EDT 2019

时间与本地计算机时间快了12小时,查看网上类似问题方案是同步远端服务器的时间

ntp常用服务器

中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz

尝试修改时间:

下载时间同步模块

 1 [root@localhost ~]# yum -y install ntpdate
 2 Loaded plugins: fastestmirror
 3 base                                                     | 3.6 kB     00:00     
 4 extras                                                   | 3.4 kB     00:00     
 5 updates                                                  | 3.4 kB     00:00     
 6 (1/2): extras/7/x86_64/primary_db                          | 205 kB   00:00     
 7 (2/2): updates/7/x86_64/primary_db                         | 6.4 MB   00:05     
 8 Loading mirror speeds from cached hostfile
 9  * base: mirrors.zju.edu.cn
10  * extras: ap.stykers.moe
11  * updates: ap.stykers.moe
12 Resolving Dependencies
13 --> Running transaction check
14 ---> Package ntpdate.x86_64 0:4.2.6p5-28.el7.centos will be installed
15 --> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: ntpdate-4.2.6p5-28.el7.centos.x86_64
16 --> Running transaction check
17 ---> Package openssl-libs.x86_64 1:1.0.1e-42.el7.9 will be updated
18 --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-42.el7.9 for package: 1:openssl-1.0.1e-42.el7.9.x86_64
19 ---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update
20 --> Running transaction check
21 ---> Package openssl.x86_64 1:1.0.1e-42.el7.9 will be updated
22 ---> Package openssl.x86_64 1:1.0.2k-16.el7_6.1 will be an update
23 --> Finished Dependency Resolution
24 
25 Dependencies Resolved
26 
27 ================================================================================
28  Package           Arch        Version                       Repository    Size
29 ================================================================================
30 Installing:
31  ntpdate           x86_64      4.2.6p5-28.el7.centos         base          86 k
32 Updating for dependencies:
33  openssl           x86_64      1:1.0.2k-16.el7_6.1           updates      493 k
34  openssl-libs      x86_64      1:1.0.2k-16.el7_6.1           updates      1.2 M
35 
36 Transaction Summary
37 ================================================================================
38 Install  1 Package
39 Upgrade             ( 2 Dependent packages)
40 
41 Total download size: 1.8 M
42 Downloading packages:
43 Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
44 (1/3): ntpdate-4.2.6p5-28.el7.centos.x86_64.rpm            |  86 kB   00:00     
45 (2/3): openssl-1.0.2k-16.el7_6.1.x86_64.rpm                | 493 kB   00:00     
46 (3/3): openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm           | 1.2 MB   00:18     
47 --------------------------------------------------------------------------------
48 Total                                               96 kB/s | 1.8 MB  00:18     
49 Running transaction check
50 Running transaction test
51 Transaction test succeeded
52 Running transaction
53   Updating   : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64                      1/5 
54   Updating   : 1:openssl-1.0.2k-16.el7_6.1.x86_64                           2/5 
55   Installing : ntpdate-4.2.6p5-28.el7.centos.x86_64                         3/5 
56   Cleanup    : 1:openssl-1.0.1e-42.el7.9.x86_64                             4/5 
57   Cleanup    : 1:openssl-libs-1.0.1e-42.el7.9.x86_64                        5/5 
58   Verifying  : 1:openssl-1.0.2k-16.el7_6.1.x86_64                           1/5 
59   Verifying  : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64                      2/5 
60   Verifying  : ntpdate-4.2.6p5-28.el7.centos.x86_64                         3/5 
61   Verifying  : 1:openssl-libs-1.0.1e-42.el7.9.x86_64                        4/5 
62   Verifying  : 1:openssl-1.0.1e-42.el7.9.x86_64                             5/5 
63 
64 Installed:
65   ntpdate.x86_64 0:4.2.6p5-28.el7.centos                                        
66 
67 Dependency Updated:
68   openssl.x86_64 1:1.0.2k-16.el7_6.1   openssl-libs.x86_64 1:1.0.2k-16.el7_6.1  
69 
70 Complete!

尝试同步远程服务器

[root@localhost ~]# ntpdate -u 210.72.145.44

返回错误:

19 Jun 22:23:08 ntpdate[3361]: no server suitable for synchronization found

尝试修改文件:

[root@localhost ~]# ntpdate -u ntp.api.bz
19 Jun 22:24:20 ntpdate[3362]: step time server 114.118.7.161 offset 3.555703 sec
[root@localhost ~]# date
Wed Jun 19 22:24:31 EDT 2019
[root@localhost ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: overwrite ‘/etc/localtime’? y
[root@localhost ~]# ntpdate pool.ntp.org 
20 Jun 10:27:29 ntpdate[3366]: adjust time server 119.28.183.184 offset 0.079637 sec
[root@localhost ~]# date
Thu Jun 20 10:27:40 CST 2019

时间同步成功!

linux时间同步

标签:修改时间   extras   上海   tar   packages   --   ntp服务   com   updating   

原文地址:https://www.cnblogs.com/bobkingblog/p/11057241.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!