前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Centos7编译安装ntp-4.2.8p11

Centos7编译安装ntp-4.2.8p11

作者头像
阿dai学长
发布2019-04-03 10:20:48
1.8K0
发布2019-04-03 10:20:48
举报
文章被收录于专栏:阿dai_linux阿dai_linux

Centos7编译安装ntp-4.2.8p11

背景

因公司做等保评级,在进行安全漏洞检测时发现ntp需要升级到ntp-4.2.7p25以上版本,经过一番搜索,没有该版本及新版本ntp的yum安装包,所以只能编译安装了,网上搜到两篇文章,但是参考价值一般,所以自己摸索爬坑,在此记录一下。

环境

  • 系统环境:Centos 7.2
  • ntpd版本:4.2.8p11

安装

下载安装包

代码语言:javascript
复制
# 官方下载
$ wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p11.tar.gz

# 解压安装包
$ tar zxvf ntp-4.2.8p11.tar.gz

# 全局配置
$ cd ntp-4.2.8p11/
$ ./configure --prefix=/usr/local/ntp --bindir=/usr/local/ntp/sbin --sysconfdir=/etc --libexecdir=/usr/local/ntp/libexec --docdir=/usr/local/ntp/doc/ntp --enable-linuxcaps  --with-lineeditlibs=readline  --enable-all-clocks --enable-parse-clocks --enable-clockctl --enable-ntpdate-step --enable-libopts-install   # 配置(查看使用指南--help)

# 报错1
"/usr/bin/ld: cannot find -lcap"
# fix
$ find / -name "*libcap.so*""
$ ln -sv /usr/lib64/libcap.so.2 /usr/lib/libcap.so


# 报错2
“ntpd.c:120:29: 致命错误:sys/capability.h:没有那个文件或目录”
# fix
$ yum install -y libcap-devel

$ make && make install   # 编译 && 安装
$ echo $?   # 检测安装过程是否出错,0表示没错

注意: 因本机系统环境已完成初始化部署,所以一些依赖包的安装省略,如果遇到缺少某些lib*查到情况,直接yum安装即可。

配置

安装完成后并没有配置文件生成,需手动创建,官方指定其默认配置文件为:/etc/ntp.conf

代码语言:javascript
复制
$ vim /etc/ntp.conf

driftfile /var/lib/ntp/drift  # 指定时间漂移记录文件,作用:如果ntpd停止并重新启动,它将从该文件初始化频率,并避免可能的长时间间隔重新学习校正。

# 指定remote ntp服务器
server 202.120.2.101  prefer iburst minpoll 4 maxpoll 6  
## prefer:优先使用
## minpoll && maxpoll:
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org

statistics loopstats peerstats clockstats

filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict 10.9.255.1
restrict 10.9.255.2
restrict ::1

启动ntpd

  • 将ntp相关命令加入系统环境变量: cp /usr/local/ntp/sbin/* /usr/lcoal/sbin
  • 将ntpd服务加入系统管理: $ systemctl cat ntpd.service # /usr/lib/systemd/system/ntpd.service Unit Description=Network Time Service After=syslog.target Service Type=forking EnvironmentFile=-/etc/sysconfig/ntpd ExecStart=/usr/local/sbin/ntpd -u ntp:ntp $OPTIONS PrivateTmp=true Install WantedBy=multi-user.target $ systemctl enable ntpd # 加入开机启动 $ systemctl start/stop/status/restart ntpd

Finished(踩坑很多,本次最大的坑为--enable-ipv6相关,如果你在安装过程中也遇到了make无法通过的问题,直接pass该参数吧,具体原因还烦路过的大神多多指教)!!!

参考

代码语言:txt
复制
 (adsbygoogle = window.adsbygoogle || []).push({});
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018/07/22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Centos7编译安装ntp-4.2.8p11
    • 背景
      • 环境
        • 安装
          • 下载安装包
          • 配置
          • 启动ntpd
        • 参考
        相关产品与服务
        脆弱性检测服务
        脆弱性检测服务(Vulnerability detection Service,VDS)在理解客户实际需求的情况下,制定符合企业规模的漏洞扫描方案。通过漏洞扫描器对客户指定的计算机系统、网络组件、应用程序进行全面的漏洞检测服务,由腾讯云安全专家对扫描结果进行解读,为您提供专业的漏洞修复建议和指导服务,有效地降低企业资产安全风险。
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档