centos7:ntp 升级:ntp-4.2.8p16

获取文件

[root@localhost ~]# wget https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.8p16.tar.gz

卸载原有的 ntp 软件,centos7 默认 yum 版本都是 4.2.6p5

[root@localhost ~]# yum remove -y ntp ntpdate

解压文件

[root@localhost ~]# tar -zxvf ntp-4.2.8p16.tar.gz

安装依赖

[root@localhost ~]# yum install -y gcc-c++

编译安装

[root@localhost ~]# cd ntp-4.2.8p16
[root@localhost ntp-4.2.8p16]# ./configure --prefix=/usr/local/ntp-4.2.8p16 
[root@localhost ntp-4.2.8p16]# make && make install

创建软链接

[root@localhost ntp-4.2.8p16]# ln -s /usr/local/ntp-4.2.8p16 /usr/local/ntp

make过程可能会出现如下问题:编译错误中没有提示说找不到静态库,那就说明链接了静态库' -lssl -lcrypto',但静态库中没有函数EVP_MD_CTX_new 的定义。

libsntp.a(crypto.o): In function `compute_mac':
/opt/soft/ntp-4.2.8p16/sntp/crypto.c:82: undefined reference to `EVP_MD_CTX_new'
/opt/soft/ntp-4.2.8p16/sntp/crypto.c:120: undefined reference to `EVP_MD_CTX_free'
collect2: error: ld returned 1 exit status
make[4]: *** [sntp] Error 1
make[4]: Leaving directory `/opt/soft/ntp-4.2.8p16/sntp'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/opt/soft/ntp-4.2.8p16/sntp'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/opt/soft/ntp-4.2.8p16/sntp'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/opt/soft/ntp-4.2.8p16'
make: *** [all] Error 2

出现以上问题的原因:大概就是因为你升级了 openssl 导致找不动相关函数的定义,如果你要编译升级 ntp 或者安装 ntp,建议是升级 openssl 之前进行,如果已经升级,可以考虑以下我提供的方法:

1.下载 openssl-1.1.1 进行编译安装

下载地址:/source/old/1.1.1/index.html

2.编译安装

[root@localhost ~]# cd openssl-1.1.1
[root@localhost openssl-1.1.1]# ./config --prefix=/usr/local/openssl-1.1.1
[root@localhost openssl-1.1.1]# make
[root@localhost openssl-1.1.1]# make install

3.重新编译安装 ntp-4.2.8p16,需要指定 openssl

[root@localhost ~]# cd ntp-4.2.8p16
[root@localhost ntp-4.2.8p16]# ./configure --prefix=/usr/local/ntp-4.2.8p16 --with-openssl-libdir=/usr/local/openssl-1.1.1/lib
[root@localhost ntp-4.2.8p16]# make CFLAGS=-fPIC
[root@localhost ntp-4.2.8p16]# make install
[root@localhost ntp-4.2.8p16]# ln -s /usr/local/ntp-4.2.8p16 /usr/local/ntp

4.修改配置文件并启动服务

[root@localhost ~]# /usr/local/ntp/bin/ntpd -c /etc/ntp.conf

你可能感兴趣的:(linux,linux,运维,服务器)