CentOS Linux release 7.9.2009 升级ntp到4.2.8p171 背景2 升级步骤2.1 检查ntpd版本2.2 下载部署包2.3 安装依赖包2.4 备份原有配置文件2.5 移除ntp2.6 解压安装包2.7 生成systemd管理配置文件2.8 还原配置文件2.9 启动服务2.10 检查ntpd版本
低版本的ntp会有漏洞,需要升级到最新版本4.2.8p17。
# ntpd --version

# wget https://archive.ntp.org/ntp4/ntp-4.2/ntp-4.2.8p17.tar.gz

# yum install gcc gcc-c++ openssl-devel libstdc++* libcap* -y


# scp /etc/ntp.conf /etc/ntp.conf.bak

# yum remove ntp ntpdate -y

# tar -zxf ntp-4.2.8p17.tar.gz
# cd ntp-4.2.8p17/
# install -v -m710 -o ntp -g ntp -d /var/lib/ntp
# ./configure --prefix=/usr --bindir=/usr/sbin --enable-all-clocks --enable-parse-clocks --docdir=/usr/share/doc/ntp-4.2.8p17 --enable-all-clocks --enable-parse-clocks --enable-clockctl CFLAGS="-fPIC"
# make && make install
注意:此处CFLAGS=“-fPIC”,p15不需要这个参数,但是p17要有;否则会报下面错误
/usr/bin/ld: ./libevent/.libs/libevent_core.a(evutil.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_core.a(evutil_rand.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_core.a(log.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_core.a(select.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_core.a(poll.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_core.a(epoll.o): relocation R_X86_64_32S against `.rodata.epollops_changelist' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_core.a(signal.o): relocation R_X86_64_32 against `.bss.signals.6714' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libevent/.libs/libevent_pthreads.a(evthread_pthread.o): relocation R_X86_64_PC32 against symbol `pthread_self@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[4]: *** [sntp] Error 1
make[4]: Leaving directory `/root/ntp-4.2.8p17/sntp'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/root/ntp-4.2.8p17/sntp'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/ntp-4.2.8p17/sntp'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/ntp-4.2.8p17'





# cat > /usr/lib/systemd/system/ntpd.service << EOF
[Unit]
Description=Network Time Service
After=syslog.target ntpdate.service sntp.service
[Service]
Type=forking
EnvironmentFile=-/etc/sysconfig/ntpd
ExecStart=/usr/sbin/ntpd -u root:root \$OPTIONS
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF

# scp /etc/ntp.conf.bak /etc/ntp.conf

# systemctl daemon-reload
# systemctl enable ntpd
# systemctl restart ntpd
# systemctl status ntpd

# ntpd --version

👍 点赞,你的认可是我创作的动力!
⭐️ 收藏,你的青睐是我努力的方向!
✏️ 评论,你的意见是我进步的财富!

原文作者:超哥的IT私房菜;如有侵权,请联系管理员删除。