Why Adding a Server with OAT Breaks yum and How to Fix It
This guide explains why using OAT to add a server can render yum unusable due to a broken Python interpreter, analyzes the underlying script logic that causes the failure, and provides two practical remediation methods—including fixing the Python symlink and adjusting the installation script—along with the full script for reference.
1. Fault Description
When adding a server via OAT (OceanBase Automation Tool) version 4.4.0, the yum command becomes unavailable, producing the error:
bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directoryThe OAT task also reports a dependency‑installation failure and suggests using the oat.server.ignore_deps parameter to skip it.
2. Error Analysis
Manual execution on the target host confirms that yum fails with the same interpreter error, indicating that OAT altered the Python environment. Inspecting the OAT script reveals a loop that processes package‑command pairs. For entries where pkg matches python, the script runs: yum install --nogpgcheck -y $pkg Because the host’s default /usr/bin/python points to a non‑existent interpreter (or to /usr/bin/python3 which is missing), the subsequent yum invocation fails.
The script’s conditional logic checks
if [[ "$pkg" == "python2" && "$python_version" =~ ^2 ]] || [[ "$pkg" == "python3" && "$python_version" =~ ^3 ]]; then, but when pkg is simply python, the condition never matches, leading to an unconditional yum install --nogpgcheck -y python. This replaces the system Python with the version from the yum repository, breaking the interpreter link.
3. Solution Methods
Method 1 – Modify the OAT script
Change the condition to compare against python instead of python2 / python3:
if [[ "$pkg" == "python" && "$python_version" =~ ^2 ]] || [[ "$pkg" == "python" && "$python_version" =~ ^3 ]]; thenRe‑run the OAT task; the script will now skip the unnecessary yum install python step.
Method 2 – Restore a valid Python interpreter
Replace the broken /usr/bin/python with a working binary, e.g. link it to the existing Python 2 interpreter:
rm -f /usr/bin/python && ln -s /usr/bin/python2 /usr/bin/pythonAlternatively, create a symlink for /usr/bin/python3 pointing to the Python 2 binary if only Python 2 is present:
ln -s /usr/bin/python2 /usr/bin/python34. Appendix – Full OAT Script Extract
os_type=centos7_or_uosc
final_exit_code=0
install_failed_deps=""
if [[ "$os_type" =~ ^(centos7_or_uosc|redhat9_or_rocky9|kylin_like)$ ]]; then
for cmd_pkg in mysql:mariadb python:python ifconfig:net-tools mtr:mtr tar:tar strings:binutils dig:bind-utils :libaio curl:curl :libatomic nc:nc ip:iproute gdb:gdb sar:sysstat perf:perf top:procps-ng asar:antsar
do
cmd=$(echo "$cmd_pkg" | cut -d':' -f1)
pkg=$(echo "$cmd_pkg" | cut -d':' -f2)
if [[ "$pkg" == "antsar" ]]; then
if ! rpm --quiet --query antsar; then
rpm -i /tmp/antsar-2.1.9-20250905115440.alios7.x86_64.rpm.y82oIAzZ.rpm
tmp_exit_code=$?
if [[ $tmp_exit_code != 0 ]]; then
final_exit_code=$tmp_exit_code
install_failed_deps="$install_failed_deps $pkg"
fi
fi
elif [[ "$pkg" =~ ^python ]]; then
python_version=$(python -V 2>&1 | awk '{print $2}')
if [[ "$pkg" == "python2" && "$python_version" =~ ^2 ]] || [[ "$pkg" == "python3" && "$python_version" =~ ^3 ]]; then
continue
fi
yum install --nogpgcheck -y $pkg
tmp_exit_code=$?
if [[ $tmp_exit_code != 0 ]]; then
final_exit_code=$tmp_exit_code
install_failed_deps="$install_failed_deps $pkg"
else
python_version=$(python -V 2>&1 | awk '{print $2}')
if [[ "$pkg" == "python2" ]]; then
if ! echo "$python_version"|grep -q "^2"; then
alternatives --install /usr/bin/python python /usr/bin/python2 1
fi
else
if ! echo "$python_version"|grep -q "^3"; then
alternatives --install /usr/bin/python python /usr/bin/python3 1
fi
fi
fi
else
if [[ -n "$cmd" ]] && which "$cmd" >/dev/null 2>&1; then
continue
fi
yum install --nogpgcheck -y $pkg
tmp_exit_code=$?
if [[ $tmp_exit_code != 0 ]]; then
final_exit_code=$tmp_exit_code
install_failed_deps="$install_failed_deps $pkg"
fi
fi
done
fi
if [[ $final_exit_code != 0 ]]; then
echo "Install deps${install_failed_deps} failed. If you are sure that the dependencies that failed to install are not needed, you can ignore them by specifying the system parameter oat.server.ignore_deps" >&2
fi
exit $final_exit_codeTechnical reference: https://github.com/actiontech/sqle
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
