Fork me on GitHub

CentOS启用NTP服务

每台服务器的时间,随着时间的运行而会产生误差,为了减少误差所以要进行时间同步

安装ntp
# yum install ntp
配置ntp启动项
# chkconfig ntpd on
同步时间
# ntpdate pool.ntp.org
启动ntpd服务
# /etc/init.d/ntpd start
2 配置时间源
# vi /etc/ntp.conf
server pool.ntp.org   #可选择其他优先服务器
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
3)配置是否为其他PC提供时间服务
# vi /etc/ntp.conf
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
6)验证ntp服务已经运行
# pgrep ntpd
7)初始同步
# ntpdate -u time.lib.tsinghua.edu.cn
8)确认同步成功
# ntpq -p
9)同时建议修改一下 /etc/sysconfig/ntpd 文件
# vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
# 改成 yes 吧!这样主机 BIOS 的时间也会跟着一起改变的 !
3 修改时区
复制相应的时区文件,替换CentOS系统时区文件;或者创建链接文件
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

######################################################

# Install ntp
yum install ntp
# Set the timezone
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# Synchronization
ntpdate pool.ntp.org
# Auto start
echo "ntpdate pool.ntp.org" >> /etc/rc.local
# Crontab
crontab -e
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP

################################################

Refer:http://koyoz.com/blog/?action=show&id=315

posted @   花儿笑弯了腰  阅读(524)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示