centos配置ntp服务器教程

本文详细介绍了在局域网环境下配置Linux时间服务器(NtpServer)的步骤,包括安装ntp、修改配置文件、手动同步时间、启动服务及设置开机启动等。同时,也讲解了如何在客户端进行相应配置,实现与服务器的时间同步。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当服务器多了,时间准确与否,一致与否是个大问题。虽然这个问题总是被忽略,但是统一一致的时间是很有必要的。下面说一下在局域网内配置Linux时间服务器的方法。
NtpServer篇:

#1.安装ntp
  yum -y install ntp
#2.修改配置文件
vi /etc/ntp.conf
#更改配置文件如下:
#上级同步服务器:北京大学同步地址
server s2m.time.edu.cn
#上级服务器不通时使用本地服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
#记录上次的NTP server与上层NTP server联接所花费的时间
driftfile /var/lib/ntp/drift
#允许访问时间服务器的IP地址
restrict 127.0.0.1 
restrict -6 ::1
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap #允许任何主机跟进行时间同步
#设置日志路径
startsdir /var/log/ntp/
#设置ntp日志文件
logfile /var/log/ntp/ntp.log
#3.手动同步
ntpdate s2m.time.edu.cn
#4.启动服务
service ntpd start
开机启动:
chkconfig ntpd on

Ntp客户端

#1.安装ntp
yum -y install ntp
#2.修改配置文件
注释默认配置,添加刚刚创建的ntpserver
#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 192.168.2.151

至此,ntp服务器配置介绍完毕。
附:修改服务器本地时区

rm -rf localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

转载于:https://www.cnblogs.com/sdhzdtwhm/p/9644606.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值