首先安装NTP服务并配置服务器列表,然后启动服务并设置开机自启,最后可通过chrony替代或手动同步确保时间准确。

如果您发现系统时间不准确,可能导致日志记录混乱、认证失败等问题,这通常是因为没有启用自动时间同步。通过配置NTP服务,可以让LINUX系统定期与网络时间服务器同步,确保时间精确。
本文运行环境:Dell PowerEdge R750,Ubuntu 22.04 Server
在大多数Linux发行版中,默认可能未安装完整的NTP服务组件。需要手动安装ntp或chrony软件包以启用时间同步功能。
1、打开终端并执行以下命令更新软件包列表:sudo apt update。
2、安装NTP服务程序:sudo apt install ntp。
3、确认服务已安装成功:dpkg -l | grep ntp。
NTP客户端通过连接预设的时间服务器来校准本地时间。修改配置文件可指定使用哪些NTP服务器进行同步。
1、编辑主配置文件:sudo nano /etc/ntp.conf。
2、查找包含"server"的行,在文件中添加或替换为以下公共NTP服务器:
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
3、保存并关闭文件。
完成安装和配置后,必须启动NTP守护进程,并设置其随系统启动自动运行。
1、启动NTP服务:sudo systemctl start ntp。
2、设置开机自启:sudo systemctl enable ntp。
3、检查服务状态:sudo systemctl status ntp,确认显示active (running)。
chrony是现代Linux系统中推荐的时间同步工具,尤其适用于经常休眠或网络不稳定的设备。
1、安装chrony组件:sudo apt install chrony。
2、编辑配置文件:sudo nano /etc/chrony/chrony.conf。
3、添加或确认存在如下服务器条目:
server time.google.com iburst
server time.apple.com iburst
4、重启chrony服务:sudo systemctl restart chrony。
5、查看同步状态:chronyc tracking。
在某些情况下,如系统长时间离线导致时间偏差过大,NTP服务可能无法自动纠正,需先手动同步一次。
1、停止NTP服务:sudo systemctl stop ntp。
2、使用ntpdate命令立即同步时间:sudo ntpdate pool.ntp.org。
3、重新启动NTP服务:sudo systemctl start ntp。
以上就是LINUX系统如何配置NTP服务来同步时间_Linux时间同步与NTP配置教程的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号