tencent cloud

TencentOS Server

DocumentaçãoTencentOS ServerFAQsTroubleshooting DNF/YUM Issues

Troubleshooting DNF/YUM Issues

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-10-19 16:52:07
Traduzido por IA

Overview

This document summarizes common issues and solutions encountered when the DNF/YUM package manager is used on TencentOS Server.

Issue 1: Unable to Connect to Software Repository

Symptoms

A network connection failure or timeout error occurs when dnf install or yum install is run.

Troubleshooting Steps

Step 1: Test network connectivity.
ping mirrors.tencentyun.com -c 3
If ping fails or resolution is abnormal, check the DNS configuration:
cat /etc/resolv.conf
# Ensure that the nameserver configuration is correct
Step 2: Check the firewall and security groups.
# Check the local firewall
firewall-cmd --list-all

# Check HTTP access
curl -I http://mirrors.tencentyun.com/tlinux/
Step 3: Verify the YUM repository.
dnf repolist
dnf makecache

Issue 2: Corrupted Software Repository Configuration

Symptoms

An error similar to the following occurs when dnf makecache or dnf repolist is run to synchronize the software repository cache:
Error: Failed to synchronize cache for repo '...'

Solution

Check the /etc/yum.repos.d directory:
ls /etc/yum.repos.d/
The standard repo file included with TencentOS Server:
System Version
Standard repo File
TencentOS Server 3
TencentOS.repo,epel.repo
TencentOS Server 4
TencentOS.repo,epol.repo
Note:
If third-party repo files exist in the directory, software source conflicts may occur.
Remove non-system standard repo files:
# Back up existing repo files
mkdir -p /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

# View the system version
cat /etc/os-release

# Reconfigure the standard repository (TencentOS Server 4, consistent with the system default configuration)
cat > /etc/yum.repos.d/TencentOS.repo << 'EOF'
[BaseOS]
name=TencentOS Server $releasever - BaseOS
baseurl=http://mirrors.tencentyun.com/tlinux/$releasever/BaseOS/$basearch/os/
http://mirrors.tencent.com/tlinux/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS-4

[AppStream]
name=TencentOS Server $releasever - AppStream
baseurl=http://mirrors.tencentyun.com/tlinux/$releasever/AppStream/$basearch/os/
http://mirrors.tencent.com/tlinux/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS-4

[extras]
name=TencentOS Server $releasever - extras
baseurl=http://mirrors.tencentyun.com/tlinux/$releasever/extras/$basearch/os/
http://mirrors.tencent.com/tlinux/$releasever/extras/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS-4
EOF
Clear the cache and retry:
dnf clean all
dnf makecache

Issue 3: Software Package Not Found

Symptoms

An error similar to the following occurs when a software package is installed, where <package-name> is the actual package name:
No match for argument: <package-name>
Error: Unable to find a match

Troubleshooting Steps

Step 1: Confirm the system version.
cat /etc/os-release
Step 2: Search for the software package on the mirror site.
Access the directory for the corresponding version on the mirror site and check whether the software package exists.
Step 3: Search for the correct package name.
# Search for software packages (fuzzy match)
dnf search <keyword>

# Find which package provides a command or file
dnf provides /usr/bin/curl
dnf provides "*/libssl.so*"
Step 4: Enable additional software repositories.
# TencentOS Server 4: Enable EPOL (the TencentOS adaptation of EPEL, installed by default in standard images)
dnf install -y epol-release
# Confirm that the EPOL source configuration file exists
ls /etc/yum.repos.d/epol.repo

# For third-party software (such as Docker), you can add the official repo
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Issue 4: YUM/DNF Errors Caused by Python Version Conflicts

Symptoms

When the dnf or yum command is run, an error similar to the following occurs, or the command cannot be executed at all:
SyntaxError: invalid syntax

Cause

The user modified the system default Python version (the /usr/bin/python symlink), causing the dnf/yum scripts to use an incorrect Python interpreter.

Solution

TencentOS Server 4 (using Python 3):
# Check the shebang line of /usr/bin/dnf
head -1 /usr/bin/dnf
# It should be #!/usr/bin/python3

# If it is incorrect, fix it
sed -i '1s|.*|#!/usr/bin/python3|' /usr/bin/dnf
TencentOS Server 3 (using Python 3):
head -1 /usr/bin/dnf
# It should be #!/usr/bin/python3
Recommendation: Access the system Python version through the python3 command, and do not modify the /usr/bin/python symlink. To manage multiple Python versions, use pyenv:
# Use pyenv to manage Python versions (without affecting the system Python)
curl https://pyenv.run | bash
pyenv install 3.11.0
pyenv global 3.11.0

Issue 5: Dependency Conflicts

Symptoms

A dependency conflict error similar to the following occurs when a software package is installed or upgraded:
Error: Problem: package X requires Y, but none of the providers can be installed

Solution

# View dependencies
dnf deplist <package-name>

# View the cause of the conflict
dnf install --best <package-name>

# Skip broken dependencies (not recommended, as it may cause system instability)
dnf install --skip-broken <package-name>

# Try to directly download and install the RPM (ignoring repo dependencies)
dnf download <package-name>
rpm -ivh --nodeps <package>.rpm

Issue 6: GPG Signature Verification Failure

Symptoms

An error similar to the following occurs when a software package is installed:
GPG key retrieval failed

Solution

# Temporarily skip GPG verification (for debugging)
dnf install --nogpgcheck <package-name>

# Import the official Tencent GPG key (built into the system)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS-4

# Permanently skip GPG in the repo file (not recommended, as it reduces security)
# gpgcheck=0

Issue 7: Insufficient Disk Space

Symptoms

An error similar to the following occurs when a software package is installed or dnf-related operations are performed:
OSError: [Errno 28] No space left on device

Solution

# View disk usage
df -h

# Clear the dnf cache
dnf clean all
# Cache location: /var/cache/dnf/

# Clean up old kernels (keep the current and previous versions)
dnf remove $(dnf repoquery --installonly --latest-limit=-2 -q)

# View large files
du -sh /var/cache/dnf/

Quick Reference for Common DNF Commands

# Install a software package
dnf install -y <package-name>

# Update all software packages
dnf update -y

# Update a single software package
dnf update -y <package-name>

# Remove a software package
dnf remove <package-name>

# Search for software packages
dnf search <keyword>

# View software package information
dnf info <package-name>

# List installed software packages
dnf list installed

# View software package update history
dnf history

# Roll back to the last dnf operation
dnf history undo last

# Clear caches
dnf clean all

# Download only without installing
dnf download <package-name>
dnf download --resolve --alldeps <package-name> # Includes all dependencies


Ajuda e Suporte

Esta página foi útil?

comentários