測試環境 CentOS7
套件管理從最早的 Red Hat Package Manager (#rpm) , 到現在常用的 Yellowdog Updater, Modified (#yum) 現在 Fedora 22 改成 DNF : Dandified Yum (#dnf) 為預設的套件管理工具.
wiki:
DNF is intended to address include poor performance, high memory usage, and the slowness of its iterative dependency resolution. DNF uses libsolv, an external dependency resolver.
因為遇到一個套件一定要用 dnf 來安裝,所以試著在 CentOS7 下來使用 dnf ,YUM 預設並沒有 dnf ,所以我們需要手動新增 dnf 的 Repo 檔 (epel-release) ,或是手動編寫 /etc/yum.repos.d/epel.repo .
[root@localhost ~]# yum install epel-release Loaded plugins: fastestmirror base | 3.6 kB 00:00 extras | 3.4 kB 00:00 nginx | 2.9 kB 00:00 updates | 3.4 kB 00:00 Loading mirror speeds from cached hostfile * base: centos.cs.nctu.edu.tw * extras: centos.cs.nctu.edu.tw * updates: centos.cs.nctu.edu.tw Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: epel-release noarch 7-6 extras 14 k Transaction Summary ================================================================================ Install 1 Package Total download size: 14 k Installed size: 24 k Is this ok [y/d/N]: y Downloading packages: epel-release-7-6.noarch.rpm | 14 kB 00:06 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-6.noarch 1/1 Verifying : epel-release-7-6.noarch 1/1 Installed: epel-release.noarch 0:7-6 Complete! [root@localhost ~]# cat /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1
現在就可以直接透過 yum 安裝 dnf
[root@localhost ~]# yum install dnf
好像因為一些安全性問題 DNF 不再提供,需要自行下載,須自行確認最新版本.
[root@localhost ~]$ wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-0.6.4-2.sdl7.noarch.rpm [root@localhost ~]$ wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-conf-0.6.4-2.sdl7.noarch.rpm [root@localhost ~]$ wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/python-dnf-0.6.4-2.sdl7.noarch.rpm [root@localhost ~]$ yum install dnf-0.6.4-2.sdl7.noarch.rpm dnf-conf-0.6.4-2.sdl7.noarch.rpm python-dnf-0.6.4-2.sdl7.noarch.rpm
使用可以直接參考 dnf 的說明.
[root@localhost ~]# dnf You need to give some command usage: dnf [options] COMMAND List of Main Commands autoremove check-update Check for available package upgrades clean Remove cached data distro-sync Synchronize installed packages to the latest available versions downgrade downgrade a package group Display, or use, the groups information help Display a helpful usage message history Display, or use, the transaction history info Display details about a package or group of packages install Install a package or packages on your system list List a package or groups of packages makecache Generate the metadata cache provides Find what package provides the given value reinstall reinstall a package remove Remove a package or packages from your system repolist Display the configured software repositories repository-packages Run commands on top of all packages in given repository search Search package details for the given string updateinfo Display advisories about packages upgrade Upgrade a package or packages on your system upgrade-to Upgrade a package on your system to the specified version
遇過的問題
CentOS7 ARM 系統透過 yum 找不到 epel-release,只能透過 wget 再手動 rpm.
[root@localhost ~]# yum install epel-release ...No package epel-release available Error: Nothing to do [root@localhost ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm [root@localhost ~]# rpm -Uvh epel-release-latest-7*.rpm
安裝完 dnf 初次會遇到類似下方的錯誤訊息,需要移除 epel-release 並執行 dnf repolist
[root@localhost ~]# dnf repolist Extra Packages for Enterprise Linux 7 - x86_64 616 kB/s | 12 MB 00:19 Failed to open: /var/cache/dnf/x86_64/7/x86_64/7/epel/repodata/a2cc7cbec8f5f02226dc6590b7a6ed439ae7324e9fa52b70e303470895d08066-updateinfo.xml.bz2. [root@localhost ~]# yum remove epel-release Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-6 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: epel-release noarch 7-6 @extras 24 k Transaction Summary ================================================================================ Remove 1 Package Installed size: 24 k Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : epel-release-7-6.noarch 1/1 Verifying : epel-release-7-6.noarch 1/1 Removed: epel-release.noarch 0:7-6 Complete! [root@localhost ~]# dnf repolist CentOS-7 - Base 893 kB/s | 8.8 MB 00:10 CentOS-7 - Updates 1.4 MB/s | 12 MB 00:08 CentOS-7 - Extras 750 kB/s | 569 kB 00:00 Using metadata from Wed Nov 23 20:41:50 2016 repo id repo name status base CentOS-7 - Base 9,007 extras CentOS-7 - Extras 393 nginx nginx repo 41 updates CentOS-7 - Updates 2,560
沒有解決問題,試試搜尋本站其他內容
One thought on “Linux 套件管理 – dnf (Dandified Yum)”