真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

怎么在CentOS中添加、啟用和禁用一個(gè)倉庫

這篇文章主要介紹“怎么在CentOS中添加、啟用和禁用一個(gè)倉庫”,在日常操作中,相信很多人在怎么在CentOS中添加、啟用和禁用一個(gè)倉庫問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么在CentOS中添加、啟用和禁用一個(gè)倉庫”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

成都創(chuàng)新互聯(lián)是一家專業(yè)提供渠縣企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站制作、網(wǎng)站建設(shè)、H5高端網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為渠縣眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進(jìn)行中。

在基于 RPM 的系統(tǒng)上,例如 RHEL、CentOS 等,我們中的許多人使用 yum 包管理器來管理軟件的安裝、刪除、更新、搜索等。

Linux 發(fā)行版的大部分軟件都來自發(fā)行版官方倉庫。官方倉庫包含大量免費(fèi)和開源的應(yīng)用和軟件。它很容易安裝和使用。

由于一些限制和專有問題,基于 RPM 的發(fā)行版在其官方倉庫中沒有提供某些包。另外,出于穩(wěn)定性考慮,它不會提供***版本的核心包。

為了克服這種情況,我們需要安裝或啟用需要的第三方倉庫。對于基于 RPM 的系統(tǒng),有許多第三方倉庫可用,但所建議使用的倉庫很少,因?yàn)檫@些不會替換大量的基礎(chǔ)包。

這可以在基于 RPM 的系統(tǒng)上完成,比如 RHEL, CentOS, OEL, Fedora 等。

  • Fedora 系統(tǒng)使用 dnf config-manager [options] [section …]

  • 其它基于 RPM 的系統(tǒng)使用 yum-config-manager [options] [section …]

如何列出啟用的倉庫

只需運(yùn)行以下命令即可檢查系統(tǒng)上啟用的倉庫列表。

對于 CentOS/RHEL/OLE 系統(tǒng):

# yum repolistLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfilerepo id                                                       repo name                                                                 statusbase                                                          CentOS-6 - Base                                                           6,706extras                                                        CentOS-6 - Extras                                                            53updates                                                       CentOS-6 - Updates                                                        1,255repolist: 8,014

對于 Fedora 系統(tǒng):

# dnf repolist

如何在系統(tǒng)中添加一個(gè)新倉庫

每個(gè)倉庫通常都提供自己的 .repo 文件。要將此類倉庫添加到系統(tǒng)中,使用 root 用戶運(yùn)行以下命令。在我們的例子中將添加 EPEL 倉庫 和 IUS 社區(qū)倉庫,見下文。

但是沒有 .repo 文件可用于這些倉庫。因此,我們使用以下方法進(jìn)行安裝。

對于 EPEL 倉庫,因?yàn)樗梢詮?CentOS 額外倉庫獲得,所以運(yùn)行以下命令來安裝它。

# yum install epel-release -y

對于 IUS 社區(qū)倉庫,運(yùn)行以下 bash 腳本來安裝。

# curl 'https://setup.ius.io/' -o setup-ius.sh# sh setup-ius.sh

如果你有 .repo 文件,在 RHEL/CentOS/OEL 中,只需運(yùn)行以下命令來添加一個(gè)倉庫。

# yum-config-manager --add-repo http://www.example.com/example.repo Loaded plugins: product-id, refresh-packagekit, subscription-manageradding repo from: http://www.example.com/example.repograbbing file http://www.example.com/example.repo to /etc/yum.repos.d/example.repoexample.repo                                             |  413 B     00:00repo saved to /etc/yum.repos.d/example.repo

對于 Fedora 系統(tǒng),運(yùn)行以下命令來添加一個(gè)倉庫:

# dnf config-manager --add-repo http://www.example.com/example.repoadding repo from: http://www.example.com/example.repo

如果在添加這些倉庫之后運(yùn)行 yum repolist 命令,你就可以看到新添加的倉庫了。Yes,我看到了。

注意:每當(dāng)運(yùn)行 yum repolist 命令時(shí),該命令會自動(dòng)從相應(yīng)的倉庫獲取更新,并將緩存保存在本地系統(tǒng)中。

# yum repolist Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileepel/metalink                                                                                                          | 6.1 kB     00:00* epel: epel.mirror.constant.com* ius: ius.mirror.constant.comius                                                                                                                    | 2.3 kB     00:00repo id                                     repo name                                                                                   statusbase                                        CentOS-6 - Base                                                                              6,706epel                                        Extra Packages for Enterprise Linux 6 - x86_64                                              12,505extras                                      CentOS-6 - Extras                                                                               53ius                                         IUS Community Packages for Enterprise Linux 6 - x86_64                                         390updates                                     CentOS-6 - Updates                                                                           1,255repolist: 20,909

每個(gè)倉庫都有多個(gè)渠道,比如測試(Testing)、開發(fā)(Dev)和存檔(Archive)等。通過導(dǎo)航到倉庫文件位置,你可以更好地理解這一點(diǎn)。

# ls -lh /etc/yum.repos.dtotal 64K-rw-r--r-- 1 root root 2.0K Apr 12 02:44 CentOS-Base.repo-rw-r--r-- 1 root root 647 Apr 12 02:44 CentOS-Debuginfo.repo-rw-r--r-- 1 root root 289 Apr 12 02:44 CentOS-fasttrack.repo-rw-r--r-- 1 root root 630 Apr 12 02:44 CentOS-Media.repo-rw-r--r-- 1 root root 916 May 18 11:07 CentOS-SCLo-scl.repo-rw-r--r-- 1 root root 892 May 18 10:36 CentOS-SCLo-scl-rh.repo-rw-r--r-- 1 root root 6.2K Apr 12 02:44 CentOS-Vault.repo-rw-r--r-- 1 root root 7.9K Apr 12 02:44 CentOS-Vault.repo.rpmnew-rw-r--r-- 1 root root 957 May 18 10:41 epel.repo-rw-r--r-- 1 root root 1.1K Nov 4 2012 epel-testing.repo-rw-r--r-- 1 root root 1.2K Feb 23 2017 ius-archive.repo-rw-r--r-- 1 root root 1.2K Feb 23 2017 ius-dev.repo-rw-r--r-- 1 root root 1.1K May 18 10:41 ius.repo-rw-r--r-- 1 root root 1.2K Feb 23 2017 ius-testing.repo

如何在系統(tǒng)中啟用一個(gè)倉庫

當(dāng)你在默認(rèn)情況下添加一個(gè)新倉庫時(shí),它將啟用它們的穩(wěn)定倉庫,這就是為什么我們在運(yùn)行 yum repolist 命令時(shí)獲取了倉庫信息。在某些情況下,如果你希望啟用它們的測試、開發(fā)或存檔倉庫,使用以下命令。另外,我們還可以使用此命令啟用任何禁用的倉庫。

為了驗(yàn)證這一點(diǎn),我們將啟用 epel-testing.repo,運(yùn)行下面的命令:

# yum-config-manager --enable epel-testing Loaded plugins: fastestmirror==================================================================================== repo: epel-testing =====================================================================================[epel-testing]bandwidth = 0base_persistdir = /var/lib/yum/repos/x86_64/6baseurl =cache = 0cachedir = /var/cache/yum/x86_64/6/epel-testingcost = 1000enabled = 1enablegroups = Trueexclude =failovermethod = priorityftp_disable_epsv = Falsegpgcadir = /var/lib/yum/repos/x86_64/6/epel-testing/gpgcadirgpgcakey =gpgcheck = Truegpgdir = /var/lib/yum/repos/x86_64/6/epel-testing/gpgdirgpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6hdrdir = /var/cache/yum/x86_64/6/epel-testing/headershttp_caching = allincludepkgs =keepalive = Truemdpolicy = group:primarymediaid =metadata_expire = 21600metalink =mirrorlist = https://mirrors.fedoraproject.org/metalink?repo=testing-epel6&arch=x86_64mirrorlist_expire = 86400name = Extra Packages for Enterprise Linux 6 - Testing - x86_64old_base_cache_dir =password =persistdir = /var/lib/yum/repos/x86_64/6/epel-testingpkgdir = /var/cache/yum/x86_64/6/epel-testing/packagesproxy = Falseproxy_dict =proxy_password =proxy_username =repo_gpgcheck = Falseretries = 10skip_if_unavailable = Falsessl_check_cert_permissions = Truesslcacert =sslclientcert =sslclientkey =sslverify = Truethrottle = 0timeout = 30.0username =

運(yùn)行 yum repolist 命令來檢查是否啟用了 “epel-testing”。它被啟用了,我可以從列表中看到它。

# yum repolistLoaded plugins: fastestmirror, securityDetermining fastest mirrorsepel/metalink                                                                                                                                                         |  18 kB     00:00epel-testing/metalink                                                                                                                                                 |  17 kB     00:00 * epel: mirror.us.leaseweb.net * epel-testing: mirror.us.leaseweb.net * ius: mirror.team-cymru.combase                                                                                                                                                                  | 3.7 kB     00:00centos-sclo-sclo                                                                                                                                                      | 2.9 kB     00:00epel                                                                                                                                                                  | 4.7 kB     00:00epel/primary_db                                                                                                                                                       | 6.0 MB     00:00epel-testing                                                                                                                                                          | 4.7 kB     00:00epel-testing/primary_db                                                                                                                                               | 368 kB     00:00extras                                                                                                                                                                | 3.4 kB     00:00ius                                                                                                                                                                   | 2.3 kB     00:00ius/primary_db                                                                                                                                                        | 216 kB     00:00updates                                                                                                                                                               | 3.4 kB     00:00updates/primary_db                                                                                                                                                    | 8.1 MB     00:00 ...repo id                                                                repo name                                                                                                       statusbase                                                                   CentOS-6 - Base                                                                                                  6,706centos-sclo-sclo                                                       CentOS-6 - SCLo sclo                                                                                               495epel                                                                   Extra Packages for Enterprise Linux 6 - x86_64                                                                  12,509epel-testing                                                           Extra Packages for Enterprise Linux 6 - Testing - x86_64                                                           809extras                                                                 CentOS-6 - Extras                                                                                                   53ius                                                                    IUS Community Packages for Enterprise Linux 6 - x86_64                                                             390updates                                                                CentOS-6 - Updates                                                                                               1,288repolist: 22,250

如果你想同時(shí)啟用多個(gè)倉庫,使用以下格式。這個(gè)命令將啟用 epel、epel-testing 和 ius 倉庫:

# yum-config-manager --enable epel epel-testing ius

對于 Fedora 系統(tǒng),運(yùn)行下面的命令來啟用倉庫:

# dnf config-manager --set-enabled epel-testing

如何在系統(tǒng)中禁用一個(gè)倉庫

無論何時(shí)你在默認(rèn)情況下添加一個(gè)新的倉庫,它都會啟用它們的穩(wěn)定倉庫,這就是為什么我們在運(yùn)行 yum repolist 命令時(shí)獲取了倉庫信息。如果你不想使用倉庫,那么可以通過下面的命令來禁用它。

為了驗(yàn)證這點(diǎn),我們將要禁用 epel-testing.repoius.repo,運(yùn)行以下命令:

# yum-config-manager --disable epel-testing ius Loaded plugins: fastestmirror==================================================================================== repo: epel-testing =====================================================================================[epel-testing]bandwidth = 0base_persistdir = /var/lib/yum/repos/x86_64/6baseurl =cache = 0cachedir = /var/cache/yum/x86_64/6/epel-testingcost = 1000enabled = 0enablegroups = Trueexclude =failovermethod = priorityftp_disable_epsv = Falsegpgcadir = /var/lib/yum/repos/x86_64/6/epel-testing/gpgcadirgpgcakey =gpgcheck = Truegpgdir = /var/lib/yum/repos/x86_64/6/epel-testing/gpgdirgpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6hdrdir = /var/cache/yum/x86_64/6/epel-testing/headershttp_caching = allincludepkgs =keepalive = Truemdpolicy = group:primarymediaid =metadata_expire = 21600metalink =mirrorlist = https://mirrors.fedoraproject.org/metalink?repo=testing-epel6&arch=x86_64mirrorlist_expire = 86400name = Extra Packages for Enterprise Linux 6 - Testing - x86_64old_base_cache_dir =password =persistdir = /var/lib/yum/repos/x86_64/6/epel-testingpkgdir = /var/cache/yum/x86_64/6/epel-testing/packagesproxy = Falseproxy_dict =proxy_password =proxy_username =repo_gpgcheck = Falseretries = 10skip_if_unavailable = Falsessl_check_cert_permissions = Truesslcacert =sslclientcert =sslclientkey =sslverify = Truethrottle = 0timeout = 30.0username = ========================================================================================= repo: ius =========================================================================================[ius]bandwidth = 0base_persistdir = /var/lib/yum/repos/x86_64/6baseurl =cache = 0cachedir = /var/cache/yum/x86_64/6/iuscost = 1000enabled = 0enablegroups = Trueexclude =failovermethod = priorityftp_disable_epsv = Falsegpgcadir = /var/lib/yum/repos/x86_64/6/ius/gpgcadirgpgcakey =gpgcheck = Truegpgdir = /var/lib/yum/repos/x86_64/6/ius/gpgdirgpgkey = file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEYhdrdir = /var/cache/yum/x86_64/6/ius/headershttp_caching = allincludepkgs =keepalive = Truemdpolicy = group:primarymediaid =metadata_expire = 21600metalink =mirrorlist = https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos6&arch=x86_64&protocol=httpmirrorlist_expire = 86400name = IUS Community Packages for Enterprise Linux 6 - x86_64old_base_cache_dir =password =persistdir = /var/lib/yum/repos/x86_64/6/iuspkgdir = /var/cache/yum/x86_64/6/ius/packagesproxy = Falseproxy_dict =proxy_password =proxy_username =repo_gpgcheck = Falseretries = 10skip_if_unavailable = Falsessl_check_cert_permissions = Truesslcacert =sslclientcert =sslclientkey =sslverify = Truethrottle = 0timeout = 30.0username =

運(yùn)行 yum repolist 命令檢查 “epel-testing” 和 “ius” 倉庫是否被禁用。它被禁用了,我不能看到那些倉庫,除了 “epel”。

# yum repolistLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfile * epel: mirror.us.leaseweb.netrepo id                                                                     repo name                                                                                                  statusbase                                                                        CentOS-6 - Base                                                                                             6,706centos-sclo-sclo                                                            CentOS-6 - SCLo sclo                                                                                          495epel                                        Extra Packages for Enterprise Linux 6 - x86_64                                              12,505extras                                                                      CentOS-6 - Extras                                                                                              53updates                                                                     CentOS-6 - Updates                                                                                          1,288repolist: 21,051

或者,我們可以運(yùn)行以下命令查看詳細(xì)信息:

# yum repolist all | grep "epel*\|ius*" * epel: mirror.steadfast.netepel                       Extra Packages for Enterprise Linux 6 enabled: 12,509epel-debuginfo             Extra Packages for Enterprise Linux 6 disabledepel-source                Extra Packages for Enterprise Linux 6 disabledepel-testing               Extra Packages for Enterprise Linux 6 disabledepel-testing-debuginfo     Extra Packages for Enterprise Linux 6 disabledepel-testing-source        Extra Packages for Enterprise Linux 6 disabledius                        IUS Community Packages for Enterprise disabledius-archive                IUS Community Packages for Enterprise disabledius-archive-debuginfo      IUS Community Packages for Enterprise disabledius-archive-source         IUS Community Packages for Enterprise disabledius-debuginfo              IUS Community Packages for Enterprise disabledius-dev                    IUS Community Packages for Enterprise disabledius-dev-debuginfo          IUS Community Packages for Enterprise disabledius-dev-source             IUS Community Packages for Enterprise disabledius-source                 IUS Community Packages for Enterprise disabledius-testing                IUS Community Packages for Enterprise disabledius-testing-debuginfo      IUS Community Packages for Enterprise disabledius-testing-source         IUS Community Packages for Enterprise disabled

對于 Fedora 系統(tǒng),運(yùn)行以下命令來啟用一個(gè)倉庫:

# dnf config-manager --set-disabled epel-testing

或者,可以通過手動(dòng)編輯適當(dāng)?shù)?repo 文件來完成。為此,打開相應(yīng)的 repo 文件并將值從 enabled=0 改為 enabled=1(啟用倉庫)或從 enabled=1 變?yōu)?enabled=0(禁用倉庫)。

即從:

[epel]name=Extra Packages for Enterprise Linux 6 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

改為:

[epel]name=Extra Packages for Enterprise Linux 6 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

到此,關(guān)于“怎么在CentOS中添加、啟用和禁用一個(gè)倉庫”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!


網(wǎng)頁題目:怎么在CentOS中添加、啟用和禁用一個(gè)倉庫
分享網(wǎng)址:http://weahome.cn/article/gpciee.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部