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
相关推荐
lifeng432114 分钟前
在 CentOS 上将 Ansible 项目推送到 GitHub 的完整指南
centos·github·ansible
MyY_DO19 分钟前
通讯录实现(Linux+Cpp)
linux·运维·服务器
独行soc21 分钟前
2025年渗透测试面试题总结-腾讯[实习]玄武实验室-安全工程师(题目+回答)
linux·安全·web安全·面试·职场和发展·渗透测试·区块链
Nightmare00428 分钟前
ubuntu22.04安装taskfile
运维·服务器·taskfile
自动驾驶小卡2 小时前
ubuntu 常用操作指令(与域控制器交互相关)
linux·ubuntu·操作指令
意如流水任东西2 小时前
Linux开发工具(apt,vim,gcc)
linux·服务器
XMAIPC_Robot2 小时前
基于RK3568的多网多串电力能源1U机箱解决方案,支持B码,4G等
linux·fpga开发·能源·边缘计算
程序猿小D2 小时前
第14节 Node.js 全局对象
linux·前端·npm·node.js·编辑器·vim
文牧之2 小时前
Oracle 的 SEC_CASE_SENSITIVE_LOGON 参数
运维·数据库·oracle