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
相关推荐
酷爱码2 分钟前
Nginx的核心功能--正向代理、反向代理、缓存和Rewrite
运维·nginx·缓存
熙曦Sakura32 分钟前
【Linux网络】TCP全连接队列
linux·网络·tcp/ip
脚比路长1 小时前
win11 安装 wsl ubuntu 18.04后换源失败!
linux
菜鸟康2 小时前
Linux——CMake的快速入门上手和保姆级使用介绍、一键执行shell脚本
linux·运维·服务器
卷卷的小趴菜学编程2 小时前
Linux系统之----基础IO
linux·运维·服务器·文件·fopen·文件操作符·位图传递标志位
码上飞扬2 小时前
Java大师成长计划之第22天:Spring Cloud微服务架构
java·运维·云计算
陈苏同学3 小时前
[已解决] VS Code / Cursor / Trae 的 PowerShell 终端 conda activate 进不去环境的常见问题
linux·windows·conda
我不是秃头sheep3 小时前
Ubuntu 安装 Docker(镜像加速)完整教程
linux·ubuntu·docker
重启就好3 小时前
【Ansible】之inventory主机清单
运维·ansible
靡樊3 小时前
网络基础概念
linux·服务器·网络·c++·学习