redhat红帽官方软件仓库同步方案
說明:本方案為紅帽官方鏡像源同步方案,方案中以紅帽7版本為案例(附帶6跟8版本的方法以及腳本),每個rpms大概需要60G左右空間。其中同步的賬號為紅帽開發(fā)者賬號,不涉及商業(yè)利益。
一:同步環(huán)境準(zhǔn)備
1:redhat操作系統(tǒng)安裝(6,7,8)
?????? 本文不具體贅述redhat系統(tǒng)安裝方式,安裝前規(guī)劃好各級目錄,同步所需空間以及帶寬需求即可。
2:注冊到紅帽訂閱系統(tǒng)(subscription-manager)
1):subscription-manager具體用法
2):注冊綁定紅帽賬號:subscription-manager register
?????? 執(zhí)行subscription-manager register會提示輸入賬號密碼(賬號密碼不在此處提供),輸入賬號密碼后系統(tǒng)提示綁定成功。
3)列出系統(tǒng)所有可用的訂閱,并記錄你在系統(tǒng)激活的訂閱池Id。
執(zhí)行subscription-manager list --available –all,列出系統(tǒng)所有可用的訂閱,并記錄訂閱池ID。
4):使用訂閱池id激活訂閱。
???? 執(zhí)行subscription-manager attach --pool=Pool ID5):關(guān)閉當(dāng)前系統(tǒng)所有倉庫
?????? 執(zhí)行:subscription-manager repos --disable="*"
6):僅打開rhel-7-server-rpms倉庫
???????? 執(zhí)行subscription-manager repos --enable=rhel-7-server-rpms7):列出當(dāng)前系統(tǒng)開啟的倉庫。
???????????? 執(zhí)行:yum repolist,如果需要列出所有倉庫包括被關(guān)閉的則執(zhí)行yum repolist all。8):測試下載軟件包
?????? 執(zhí)行yum install XXX
到這里同步環(huán)境已經(jīng)準(zhǔn)備好, 以上對repo倉庫的操作為示例,只針對當(dāng)前服務(wù)器有影響,后續(xù)同步軟件包的過程,不會檢查repo倉庫是否關(guān)閉/開啟,只要對應(yīng)的配置(/etc/yum.repos.d/)存在,即可同步。
二:軟件倉庫同步
1:安裝reporsync命令
?????? 執(zhí)行:yum install yum-utils
RHEL 6/7 版本需要的reposync命令需要單獨(dú)安裝rpm包:?yum-utils?RHEL 8 版本則是集成在dnf命令中
2:確認(rèn)需要同步的各個rpms
本文以以下常見的幾個倉庫為例。
rhel-7-server-rpms
rhel-7-server-optional-rpms
rhel-7-server-extras-rpms
rhel-7-server-supplementary-rpms
rhel-ha-for-rhel-7-server-rpms
rhel-rs-for-rhel-7-server-rpms
rhel-7-server-debug-rpms
rhel-7-server-optional-debug-rpms
rhel-7-server-extras-debug-rpms
rhel-7-server-supplementary-debug-rpms
rhel-7-server-ansible-2-rpms
rhel-7-server-ansible-2-debug-rpms
rhel-ha-for-rhel-7-server-debug-rpms
rhel-rs-for-rhel-7-server-debug-rpms
3:編寫同步所需腳本
此處提供6,7,8三個系統(tǒng)版本的同步腳本
#!/bin/bashdownload_path="/repos"reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-optional-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-extras-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-supplementary-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-ha-for-rhel-6-server-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-rs-for-rhel-6-server-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-optional-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-extras-debuginfo reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-6-server-supplementary-debuginfo reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-ha-for-rhel-6-server-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-rs-for-rhel-6-server-debug-rpms #!/bin/bash#定義下載回來的包存放的目錄 download_path="/repos"cat << EOF > /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - \$basearch baseurl=http://mirrors.aliyun.com/epel/7/\$basearch failovermethod=priority enabled=1 gpgcheck=0 EOFreposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-optional-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-extras-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-supplementary-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-ha-for-rhel-7-server-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-rs-for-rhel-7-server-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=epel reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-optional-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-extras-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-supplementary-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-ansible-2-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-7-server-ansible-2-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-ha-for-rhel-7-server-debug-rpms reposync --plugins --newest-only --delete --download_path=$download_path --repoid=rhel-rs-for-rhel-7-server-debug-rpms#--plugins 啟用yum插件支持 #--newest-only 每次回購僅下載最新的軟件包。 #--download_path 軟件包存放地址 #--repoid 需要下載的倉庫ID #!/bin/bashdownload_path="/repos"cat << EOF > /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux \$releasever - \$basearch baseurl=https://mirrors.aliyun.com/epel/\$releasever/Everything/\$basearch enabled=1 gpgcheck=0 [epel-modular] name=Extra Packages for Enterprise Linux Modular \$releasever - \$basearch baseurl=https://mirrors.aliyun.com/epel/\$releasever/Modular/\$basearch enabled=1 gpgcheck=0 EOFdnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=rhel-8-for-x86_64-appstream-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=rhel-8-for-x86_64-baseos-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=rhel-8-for-x86_64-highavailability-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=rhel-8-for-x86_64-resilientstorage-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=rhel-8-for-x86_64-appstream-debug-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=rhel-8-for-x86_64-baseos-debug-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=epel dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=epel-modular dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=codeready-builder-for-rhel-8-x86_64-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=ansible-2-for-rhel-8-x86_64-rpms dnf reposync --newest-only --delete --download-path=$download_path --download-metadata --repoid=ansible-2-for-rhel-8-x86_64-debug-rpms4:執(zhí)行腳本同步
?????? 1):執(zhí)行sh 7_repo_update.sh
轉(zhuǎn)存失敗重新上傳取消
2)查看發(fā)現(xiàn)包正在陸續(xù)下載回來
轉(zhuǎn)存失敗重新上傳取消
至此紅帽倉庫開始同步,等待同步完成即可。以上提供的腳本可加入定時任務(wù)定時增量同步。
總結(jié)
以上是生活随笔為你收集整理的redhat红帽官方软件仓库同步方案的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [工具]Microsoft To-Do,
- 下一篇: SuperMemo导出html,使用思维