centos7虚拟机时间和本地时间相差8小时

安装ntp和ntpdate

在安装centos7虚拟机的时候,已经将时区设置为了Asia/shanghai,但还是出现时间不准,相差了8小时
可以安装ntp和ntpdate,使用 NTP 公共时间服务器池(NTP Public Pool Time Servers)http://www.pool.ntp.org 同步你的服务器时间。

安装步骤

  1. 安装:sudo yum install ntpdate ntp -y
  2. 允许服务:sudo systemctl enable ntpd && sudo systemctl enable ntpdate
  3. 开启服务:sudo systemctl start ntpdate && sudo systemctl start ntpd
原文地址:https://www.cnblogs.com/HachikoT/p/13048889.html