禁用 MongoDB 升级时重启(RPM 包)
Disable MongoDB restart on upgrade (RPM package)
MongoDB RPM 包(由官方 repo.mongodb.org 存储库提供,从版本 3.4.1 开始)在包升级时自动无条件地重启服务器。此行为被硬编码到 postun 处理程序中:
if test -ge 1
then
/usr/bin/systemctl restart mongod >/dev/null 2>&1 || :
fi
这是一种不便且危险的行为,尤其是当您使用配置管理工具来设置您的服务器时。例如,我想 运行 一个完整的 Ansible 剧本来首先设置我的服务器,然后一个接一个地手动重启 MongoDB 以完全控制情况。
有什么方法可以改变或禁用它吗?替代 MongoDB 包,也许?或者一些模糊的 yum/rpm 命令选项来禁用 scriptlet?
我知道我可以切换到简单的 .tar.gz 安装,但这是最后的选择。
如果您先下载 rpm 并使用 rpm
手动安装;您可以使用 --nopostun
选项:
rpm -Uvh mongodb***rpm --nopostun
来自 rpm 手册页:
--noscripts
--nopre
--nopost
--nopreun
--nopostun
--nopretrans
--noposttrans
Don't execute the scriptlet of the same name. The --noscripts option is equivalent to
--nopre --nopost --nopreun --nopostun --nopretrans --oposttrans
and turns off the execution of the corresponding %pre, %post, %preun, %postun %pretrans, and %posttrans scriptlet(s).
afaik yum
无法处理 --nopostun
和其他标志。
MongoDB RPM 包(由官方 repo.mongodb.org 存储库提供,从版本 3.4.1 开始)在包升级时自动无条件地重启服务器。此行为被硬编码到 postun 处理程序中:
if test -ge 1
then
/usr/bin/systemctl restart mongod >/dev/null 2>&1 || :
fi
这是一种不便且危险的行为,尤其是当您使用配置管理工具来设置您的服务器时。例如,我想 运行 一个完整的 Ansible 剧本来首先设置我的服务器,然后一个接一个地手动重启 MongoDB 以完全控制情况。
有什么方法可以改变或禁用它吗?替代 MongoDB 包,也许?或者一些模糊的 yum/rpm 命令选项来禁用 scriptlet?
我知道我可以切换到简单的 .tar.gz 安装,但这是最后的选择。
如果您先下载 rpm 并使用 rpm
手动安装;您可以使用 --nopostun
选项:
rpm -Uvh mongodb***rpm --nopostun
来自 rpm 手册页:
--noscripts --nopre --nopost --nopreun --nopostun --nopretrans --noposttrans Don't execute the scriptlet of the same name. The --noscripts option is equivalent to --nopre --nopost --nopreun --nopostun --nopretrans --oposttrans and turns off the execution of the corresponding %pre, %post, %preun, %postun %pretrans, and %posttrans scriptlet(s).
afaik yum
无法处理 --nopostun
和其他标志。