1、安装ntpd同步网络时间:

yum install -y ntpd

2、编辑 ntp.conf 文件:

vim /etc/ntp.conf

server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst

3、设置系统时间为北京时间:

timedatectl set-timezone Asia/Shanghai

4、启动ntp服务、设置开机自启:

systemctl start ntpd

systemctl enable ntpd

5、验证是否生效:

date #查看返回的时间时候正常

ntpdate time.nist.gov

date #再查看时间是否同步