Linux下快速搭建ntp时间同步服务器

简介:
一、搭建时间同步服务器
1、编译安装ntp server
wget [url]http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.4p4.tar.gz[/url]
tar zxvf ntp-4.2.4p4.tar.gz
cd ntp-4.2.4p4
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install

注:如以上下载地址无法访问,请从ntp官方下载网页([url]http://www.ntp.org/downloads.html[/url])寻找下载地址。

2、修改ntp.conf配置文件
vi /etc/ntp.conf

①、第一种配置:允许任何IP的客户机都可以进行时间同步
将“restrict default nomodify notrap noquery”这行修改成:
restrict default nomodify

配置文件示例:/etc/ntp.conf

②、第二种配置:只允许192.168.18.***网段的客户机进行时间同步
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:
restrict 192.168.18.0 mask 255.255.255.0 nomodify

配置文件示例:/etc/ntp.conf

3、以守护进程启动ntpd
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid

4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。

二、配置时间同步客户机
vi /var/spool/cron/root

增加一行,在每天的5点13分、9点13分、14点13分、19点13分与时间同步服务器进行同步
13 5,9,14,19 * * * /usr/sbin/ntpdate 192.168.18.2

备注:如果客户机没有ntpdate,可以下载ntpdate.tar.gz到/usr/sbin/目录,然后解压:
wget [url]http://blog.s135.com/attachment/200708/ntdate.tar.gz[/url]
cd /usr/sbin/
tar zxvf ntpdate.tar.gz
本文转自守住每一天51CTO博客,原文链接:http://blog.51cto.com/liuyu/79371,如需转载请自行联系原作者
相关文章
|
4月前
|
消息中间件 Kubernetes NoSQL
Linux时间校准(ntpdate及NTP客户端代码校准示例)
Linux时间校准(ntpdate及NTP客户端代码校准示例)
|
4月前
|
网络协议 算法 定位技术
利用GPS北斗卫星系统开发NTP网络时间服务器
利用GPS北斗卫星系统开发NTP网络时间服务器
|
5月前
|
监控 Linux 定位技术
Linux【环境部署 01】NTP时间服务器搭建及Linux+Windows客户端使用(一篇学会使用NTP服务)
Linux【环境部署 01】NTP时间服务器搭建及Linux+Windows客户端使用(一篇学会使用NTP服务)
812 0
|
6月前
|
Linux
CentOS7搭建ntp时钟服务器
CentOS7搭建ntp时钟服务器
716 0
|
8月前
NTP服务器时间配置
NTP服务器时间配置
161 0
|
10月前
|
Linux 网络安全
Linux系统之NTP服务器配置
Linux系统之NTP服务器配置
1662 1
|
12月前
|
安全 Linux 网络安全
Linux 时间同步 -NTP 服务器
本文主要介绍如何配置 Linux 服务器集群的时间同步,技术实现上使用 NTP 服务器和客户端同步时间。
447 0
|
Unix Linux
Linux 使用 chrony 进行 NTP 时间同步及自建方法
chrony是网络时间协议的实现。它可以替代ntpd,后者是NTP的参考实现。它在类Unix操作系统上运行,并在GNU GPL v2下发布。
346 0
|
Ubuntu Linux 虚拟化
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
1485 0
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
|
Linux 网络安全
linux篇-CentOS7搭建NTP服务器
linux篇-CentOS7搭建NTP服务器
874 0
linux篇-CentOS7搭建NTP服务器