Linux升级NTPD服务器-编译安装ntp-4.2.8p9与配置

本文详细介绍如何在CentOS 6.5 x86_64环境下从源码编译安装ntp-4.2.8p9版本,并配置ntp服务。内容包括安装依赖、编译配置、服务启动及客户端配置等步骤。

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

1. 系统与软件版本

1.1 系统版本

CentOS6.5 x86_64

1.2 ntpd软件版本

ntp-4.2.8p9.tar.gz 

1.3 下载地址

官方下载地址:http://support.ntp.org/bin/view/Main/SoftwareDownloads

参考文档:http://www.linuxfromscratch.org/blfs/view/svn/basicnet/ntp.html

2. 安装前提

2.1 安装依赖包

[root@ntpserver ~]# yum install gcc gcc-c++ openssl-devel libstdc++* libcap*


2.2 备份旧版本的配置文件

1
2
3
4
5
[root@ntpserver ~] # cp -ar /etc/ntp /etc/ntp.bak
[root@ntpserver ~] # cp /etc/ntp.conf /etc/ntp.conf.bak
[root@ntpserver ~] # cp /etc/init.d/ntpd /etc/init.d/ntpd.bak
[root@ntpserver ~] # cp /etc/sysconfig/ntpd /etc/sysconfig/ntpd.bak
[root@ntpserver ~] # cp /etc/sysconfig/ntpdate /etc/sysconfig/ntpdate.bak

 

2.3 卸载yum安装的ntpd服务

1
[root@ntpserver ~] # yum erase ntp ntpdate


3. 编译安装ntp-4.2.8p9

3.1 创建/var/lib/ntp目录

1
[root@ntpserver ~] # install -v -m710 -o ntp -g ntp -d /var/lib/ntp


3.2 编译安装ntpd

1
2
3
4
5
6
7
8
9
10
11
12
[root@ntpserver ntp-4.2.8p9] # ./configure \
--prefix= /usr  \
--bindir= /usr/sbin  \
--sysconfdir= /etc  \
-- enable -linuxcaps \
--with-lineeditlibs=readline \
--docdir= /usr/share/doc/ntp-4 .2.8p9 \
-- enable -all-clocks \
-- enable -parse-clocks \
-- enable -clockctl
  
make  &&  make  install

 

1
2
[root@ntpserver ~] # ntp
ntpd        ntpdate     ntpdc       ntp-keygen  ntpq        ntptime     ntptrace    ntp-wait

4. 创建配置文件

1
2
3
4
5
[root@ntpserver ~] # cp /etc/init.d/ntpd.bak /etc/init.d/ntpd
[root@ntpserver ~] # cp /etc/sysconfig/ntpd.bak /etc/sysconfig/ntpd
[root@ntpserver ~] # cp /etc/sysconfig/ntpdate.bak /etc/sysconfig/ntpdate
[root@ntpserver ~] # mv /etc/ntp.bak /etc/ntp
[root@ntpserver ~] # cp /etc/ntp.conf.bak /etc/ntp.conf


5. 配置ntp.conf

在/etc/ntp.conf配置文件添加以下参数

server 127.127.1.0

fudge 127.127.1.0 stratum 10

启动ntpd服务

[root@ntpserver ~]# service ntpd start


6. 客户端配置

1
2
[root@localhost ~] # date
Sat Aug  8 08:08:13 CST 2015


/etc/ntp.conf添加服务端IP地址

server 10.17.83.106


1
2
3
4
[root@localhost ~] # ntpq -p
      remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
  10.17.83.106    10.17.82.25     12 u    3   64    1    0.628  4279381   0.001

 

等待几分钟,ntpd客户端自动去同步服务端的时间

1
2
3
4
[root@localhost ~] # date
Sat Aug  8 08:11:10 CST 2015
[root@localhost ~] # date
Thu Dec 15 15:28:41 CST 2016


Windows客户端配置

wKioL1hSShHS_jrmAAm0ZEPSbho699.png



wKiom1hSSe2S5a9hAAAc-IDXo7I434.png

本文转自 HMLinux 51CTO博客,原文链接:http://blog.51cto.com/7424593/1883058


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值