ITPub博客

首页 > 数据库 > 数据库开发技术 > CentOS Linux release 7.9.2009 升级ntp到4.2.8p17

CentOS Linux release 7.9.2009 升级ntp到4.2.8p17

原创 数据库开发技术 作者:shuchaoyang 时间:2024-04-19 07:00:00 0 删除 编辑

CentOS Linux release 7.9.2009 升级ntp到4.2.8p17

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版本

1 背景

低版本的ntp会有漏洞,需要升级到最新版本4.2.8p17。

2 升级步骤

2.1 检查ntpd版本

# ntpd --version

2.2 下载部署包

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

2.3 安装依赖包

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

2.4 备份原有配置文件

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

2.5 移除ntp

# yum remove ntp ntpdate -y

2.6 解压安装包

# 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'

2.7 生成systemd管理配置文件

# 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

2.8 还原配置文件

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

2.9 启动服务

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

2.10 检查ntpd版本

# ntpd --version


👍 点赞,你的认可是我创作的动力!

⭐️ 收藏,你的青睐是我努力的方向!

✏️ 评论,你的意见是我进步的财富!


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

请登录后发表评论 登录
全部评论
专注于IT系统集成、运维、架构二十年的IT职场老兵,拥有CCNA、OCA、OCP、PGCA、PGCE认证证书,公众号:超哥的IT私房菜,知识星球:超哥的IT私房菜,目前是多家IT厂商的咨询顾问。

注册时间:2021-08-27

  • 博文量
    552
  • 访问量
    303526