因公司作等保评级,在进行安全漏洞检测时发现ntp须要升级到ntp-4.2.7p25以上版本,通过一番搜索,没有该版本及新版本ntp的yum安装包,因此只能编译安装了,网上搜到两篇文章,可是参考价值通常,因此本身摸索爬坑,在此记录一下。html
# 官方下载 $ 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安装便可。linux
安装完成后并无配置文件生成,需手动建立,官方指定其默认配置文件为:/etc/ntp.conf
。vim
$ 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
将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该参数吧,具体缘由还烦路过的大神多多指教)!!!oop