CentOS7--配置时间同步
思韵闪耀
2021-04-23
0
1.安装ntpdate工具
sudo yum -y install ntp ntpdate
2.设置系统时间与网络时间同步
sudo ntpdate cn.pool.ntp.org
3.将系统时间写入硬件时间
 sudo hwclock --systohc
4.查看系统时间
timedatectl
#得到
      Local time: 四 2017-09-21 13:54:09 CST
  Universal time: 四 2017-09-21 05:54:09 UTC
        RTC time: 四 2017-09-21 13:54:09
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: yes
      DST active: n/a
如果没有执行步骤3,则Local time与RTC time显示的值可能不一样

编辑配置文件(vim /etc/ntp.conf),注释默认ntp服务地址,使用国内地址(有两个网站可以参考:https://www.pool.ntp.org/zone/cn  和  http://www.ntp.org.cn/  可以自行查找合适的ntp服务器),具体修改部分突出显示,如下:
 

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
server cn.ntp.org.cn
server ntp.aliyun.com

修改完成后保存退出,并重启ntp(systemctl restart ntpd)

【!!!】这里需要注意的是,在使用ntp服务器时,如果有防火墙,则需要开启ntp服务器的udp协议123端口,否则其他虚拟机不能成功同步时间。


【版权声明】
本站部分内容来源于互联网,本站不拥有所有权,不承担相关法律责任。如果发现本站有侵权的内容,欢迎发送邮件至masing@13sy.com 举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

相关内容

将IIS设置克隆到新服务器...
将IIS设置克隆到新服务器的最佳方法是使用IIS配置文件。以下是详...
2025-06-06
搭建Git服务器及本机克隆...
Git是什么?Git是目前世界上最先进的分布式版本控制系统。SVN...
2025-03-17
ubuntu环境下搭建gi...
操作环境:服务器:Ubuntu 24.04.2 LTS+git 2...
2025-03-17
Ubuntu防火墙ufw的...
一、不使用IPv6打开UFW配置。sudo vim /e...
2024-12-28
ubuntu防火墙命令介绍
ubuntu在开启ufw防火墙前,为了避免与iptables现有规...
2024-07-21
ubuntu防火墙ufw详...
ubuntu防火墙为ufw,本文为大家介绍ubuntu系统防火墙的...
2024-04-28

热门资讯

SIOCADDRT: Netw... SIOCADDRT: Network is unreachable SIOCADDRT: 网络不可达...
centos7下创建新用户和组 linux下添加,删除,修改,查看用户和用户组 1 .增加一个test组 groupadd test...
linux通过sed 修改文件... 13sy.txt里面内容如下 A; B; C; write by luohao199621; 1.要...
关于cannot remove... 关于cannot remove directory: Directory not empty的解决办...
mount: unknown ... mount: unknown filesystem type LVM2_member解决方案 系统启...
OpenMediaVault安... OpenMediaVault 是一个基于Debian的专用 Linux 发行版,用于构建网络连接存储...
centos7 双网卡双网关的... 最近公司需要在一台服务器上同时使用内网和外网,并且都需要跨网段访问,因此需要双网关,但是一台机子上只...
ethtool 命令详解 1 概述 ethtool 是用于查询及设置网卡参数的命令。 2 命令详解 2.1 命令格式 (1) ...
CentOS7单网卡设置双IP... linux系统CentOS7单网卡设置双IP的方法,centos7.5、7.6、7.7设置双IP教程...
Linux进程状态D,S,Z的... Linux进程状态top,ps中看到进程状态D,S,Z的含义 在top和ps命令中有一列显示进程状态...