Linux系统中虚拟机CentOS时间与本地时间不一致
程序员文章站
2024-01-23 18:04:34
...
Linux系统中虚拟机CentOS时间与本地时间不一致
修改前时间
**[root@localhost shaole]# date
2021年 04月 23日 星期五 03:43:19 CST**
安装时间同步插件
<pre>[root@localhost shaole]# **yum install ntpdate**
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00
(2/4): extras/7/x86_64/primary_db | 232 kB 00:00
(3/4): base/7/x86_64/primary_db | 6.1 MB 00:01
(4/4): updates/7/x86_64/primary_db | 7.1 MB 00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 ntpdate.x86_64.0.4.2.6p5-28.el7.centos 将被 升级
--> 正在处理依赖关系 ntpdate = 4.2.6p5-28.el7.centos,它被软件包 ntp-4.2.6p5-28.el7.centos.x86_64 需要
---> 软件包 ntpdate.x86_64.0.4.2.6p5-29.el7.centos.2 将被 更新
--> 正在检查事务
---> 软件包 ntp.x86_64.0.4.2.6p5-28.el7.centos 将被 升级
---> 软件包 ntp.x86_64.0.4.2.6p5-29.el7.centos.2 将被 更新
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在更新:
ntpdate x86_64 4.2.6p5-29.el7.centos.2 base 87 k
为依赖而更新:
ntp x86_64 4.2.6p5-29.el7.centos.2 base 549 k
事务概要
================================================================================
升级 1 软件包 (+1 依赖软件包)
总下载量:635 k
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
警告:/var/cache/yum/x86_64/7/base/packages/ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm: 头V3 RSA/SHA256 Signature, ** ID f4a80eb5: NOKEY
ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm 的公钥尚未安装
(1/2): ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm | 87 kB 00:00
(2/2): ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm | 549 kB 00:00
--------------------------------------------------------------------------------
总计 1.5 MB/s | 635 kB 00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索**
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : ntpdate-4.2.6p5-29.el7.centos.2.x86_64 1/4
正在更新 : ntp-4.2.6p5-29.el7.centos.2.x86_64 2/4
清理 : ntp-4.2.6p5-28.el7.centos.x86_64 3/4
清理 : ntpdate-4.2.6p5-28.el7.centos.x86_64 4/4
验证中 : ntp-4.2.6p5-29.el7.centos.2.x86_64 1/4
验证中 : ntpdate-4.2.6p5-29.el7.centos.2.x86_64 2/4
验证中 : ntp-4.2.6p5-28.el7.centos.x86_64 3/4
验证中 : ntpdate-4.2.6p5-28.el7.centos.x86_64 4/4
更新完毕:
ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2
作为依赖被升级:
ntp.x86_64 0:4.2.6p5-29.el7.centos.2
完毕!
[root@localhost shaole]# service ntpdate restart
Redirecting to /bin/systemctl restart ntpdate.service
</pre>
删除时区、设置时区上海
<pre>[root@localhost shaole]# **rm -rf /etc/localtime**
[root@localhost shaole]# **ln -s/usr/share/zoneinfo/Asia/Shanghai /etc/localtime**
</pre>
查看设置之后的时间
[root@localhost shaole]# date
2021年 04月 22日 星期四 19:46:48 CST