linux时间同步
虚拟机时间同步:
[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
时间同步成功!
分享即成长
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现