CentOS 7 中时间快了 8 小时

1.查看系统时间

1.1 timeZone显示时区

复制代码
[admin@localhost ~]$ timedatectl
      Local time: Mon 2024-04-15 18:09:19 PDT
  Universal time: Tue 2024-04-16 01:09:19 UTC
        RTC time: Tue 2024-04-16 01:09:19
       Time zone: America/Los_Angeles (PDT, -0700)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2024-03-10 01:59:59 PST
                  Sun 2024-03-10 03:00:00 PDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2024-11-03 01:59:59 PDT
                  Sun 2024-11-03 01:00:00 PST

1.2 修改时区为上海

复制代码
sudo timedatectl set-timezone 'Asia/Shanghai'

2.使用NTP进行时间同步

2.1 安装 NTP 服务器包

复制代码
yum install -y ntp

2.2 从 NTP 公共池时间服务器选择所需的物理服务器

NTP Servers in China, cn.pool.ntp.org

复制代码
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org

2.3 编辑 NTP 配置文件

复制代码
vi /etc/ntp.conf

#在服务器时间池加上中国的

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org

2.4 启动NTP

复制代码
$ sudo systemctl start ntpd

2.5 设置自启

复制代码
$ sudo systemctl enable ntpd
相关推荐
梦想很大很大4 小时前
拒绝“盲猜式”调优:在 Go Gin 项目中落地 OpenTelemetry 链路追踪
运维·后端·go
Sinclair5 小时前
内网服务器离线安装 Nginx+PHP+MySQL 的方法
运维
叶落阁主5 小时前
Tailscale 完全指南:从入门到私有 DERP 部署
运维·安全·远程工作
0xDevNull12 小时前
Linux切换JDK版本详细教程
linux
进击的丸子12 小时前
虹软人脸服务器版SDK(Linux/ARM Pro)多线程调用及性能优化
linux·数据库·后端
甲鱼9291 天前
MySQL 实战手记:日志管理与主从复制搭建全指南
运维
Johny_Zhao2 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
chlk1233 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑3 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件3 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux