Due to the company’s equivalent guarantee rating, it was found that ntp needs to be upgraded to ntp-4.2.7p25 or higher during security vulnerability detection. After some searching, there is no yum installation package for this version and the new version of ntp, so I can only compile and install it. I found two articles on the Internet, but the reference value is average, so I explored the pit myself and recorded it here.
# Official download
$ wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p11.tar.gz
# Unzip the installation package
$ tar zxvf ntp-4.2.8p11.tar.gz
# Global configuration
$ 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 #Configuration(View usage guide--help)
# Error 1"/usr/bin/ld: cannot find -lcap"
# fix
$ find /-name "*libcap.so*""
$ ln -sv /usr/lib64/libcap.so.2/usr/lib/libcap.so
# Error 2
“ntpd.c:120:29:Fatal error: sys/capability.h: There is no such file or directory"
# fix
$ yum install -y libcap-devel
$ make && make install #Compile&&installation
$ echo $? #Check if there is an error in the installation process, 0 means yes
*Note: ** Since the initial deployment of the local system environment has been completed, the installation of some dependent packages is omitted. If you encounter a lack of some lib, you can install it directly with yum.
After the installation is complete, there is no configuration file generated, you need to create it manually. The official designation of the default configuration file is: /etc/ntp.conf
.
$ vim /etc/ntp.conf
driftfile /var/lib/ntp/drift #Specify the time drift record file. Function: If ntpd is stopped and restarted, it will initialize the frequency from this file and avoid possible long time intervals to relearn and correct.
# Specify remote ntp server
server 202.120.2.101 prefer iburst minpoll 4 maxpoll 6
## prefer: preferential use
## 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 -4default kod notrap nomodify nopeer noquery
restrict -6default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict 10.9.255.1
restrict 10.9.255.2
restrict ::1
Add ntp related commands to system environment variables:
cp /usr/local/ntp/sbin/* /usr/lcoal/sbin
Add ntpd service to system management:
$ 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 # Join boot start $ systemctl start/stop/status/restart ntpd
Finished (a lot of pits are stepped on, the biggest pit this time is related to --enable-ipv6. If you also encounter a problem that make cannot pass during the installation process, pass this parameter directly. The specific reason is also troubled by the passing gods.) ! ! !
Official website: http://www.ntp.org/documentation.html
Application reference: https://my.oschina.net/adailinux/blog/1633264
( adsbygoogle = window.adsbygoogle || []).push({});
Recommended Posts