參考:?reposync - 命令 - -桃枝夭夭- - 博客園
0. 簡介
reposync 命令簡單來說就是可以把指定外網(wǎng)源(repo id)的包同步到本地文件中
1. 安裝 reposync 命令
[root@V10SP1-1 ~]# yum install -y dnf-plugins-core
2. 常用選項(xiàng)以及參數(shù)
選項(xiàng) | 含義 |
---|---|
-c [file] | 指定配置文件運(yùn)行(默認(rèn)配置文件是 /etc/yum.conf ) |
-q | 靜謐運(yùn)行 |
-v | 顯示詳細(xì)操作 |
-h | 獲取幫助 |
-b | 嘗試使用最佳的軟件包版本 |
-C | 只從系統(tǒng)緩存中運(yùn)行,不更新緩存 |
-R [min] | 最大命令等待時(shí)間 |
-y | 所有回答都是 yes |
-x [package] | 排除哪些包 |
-n repoid=[] | 只下載最新的包,相同的跳過 |
-p | 指定下載路徑 |
--delete | 刪除已不在倉庫中的本地軟件包 |
3. 例子
#1. 同步整個源到指定目錄
[root@V10SP1-1 pac]# reposync -p /root/pac
# 2. 同步指定源到指定目錄
[root@V10SP1-1 pac]# reposync --repoid=ks10-adv-updates -p /root/pac/
# 3. 更新同步過的源
[root@V10SP1-1 pac]# reposync -n --repoid=ks10-adv-updates -p /root/pac
4. 使用場景
常見的使用場景就是,一個服務(wù)器集群,只有一臺服務(wù)器能連接外網(wǎng),連接外網(wǎng)那臺服務(wù)器就把外網(wǎng)源的包全部同步下來放在本地,集群中其他服務(wù)器就以這臺服務(wù)器為包庫使用 yum 安裝,當(dāng)然,同步完包之后還需要使用 createrepo 來生成 repodata
5.?reposync同步aliyunyum庫到本地
5.1 軟件安裝:
# yum-utils:reposync同步工具
# createrepo:編輯yum庫工具?
yum?-y install yum-utils createrepo plugin-priorities?
# plugin-priorities:控制yum源更新優(yōu)先級工具,用來控制進(jìn)行yum源檢索的先后順序,
# 建議可以用在client端。
5.2 安裝nginx:
yum –y install Nginx
5.3 修改nginx配置文件:
vi /etc/nginx/nginx.conf
5.4 備份yum庫
mkdir /repo? && mv /etc/yum.repos.d/* /repo?
5.5 建立aliyun yum庫
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
5.6 刷新緩存
yum clean all
yum makecache
5.7 查看倉庫列表
[root@localhost yum.repos.d]# yum repolist
已加載插件:fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
倉庫標(biāo)識倉庫名稱狀態(tài)
baseCentOS-6 - Base - mirrors.aliyun.com6,706
extras CentOS-6 - Extras - mirrors.aliyun.com 46
updates CentOS-6 - Updates - mirrors.aliyun.com 826
repolist: 7,778
5.8 nginx的html目錄
/usr/share/nginx/html/
5.9 建立rpm庫存放目錄
mkdir -p /usr/share/nginx/html/Aliyun/CentOS/7/64bit/{base,extras,updates}
5.10 同步下載rpm包
reposync -p?/usr/share/nginx/html/Aliyun/CentOS/7/64bit
# 同步鏡像到本地
reposync -r base
reposync -r extras
reposync -r updates
5.11 創(chuàng)建yum倉庫?
yum installcreaterepo yum-utils -y
cd base
createrepo ./
cd ../extras
createrepo ./
cd ../updates
createrepo ./
5.12 其他服務(wù)器連接YUM倉庫:
vim /etc/yum.repos.d/test.repo
[base]
name=CentOS-Base(GDS)
baseurl=http://10.63.215.7/Aliyun/CentOS/7/64bit/base
path=/
enabled=1
gpgcheck=0
[updates]
name=CentOS-Updates(GDS)
baseurl=http://10.63.215.7/Aliyun/CentOS/7/64bit/updates
path=/
enabled=1
gpgcheck=0
[extras]
name=CentOS-Extras(GDS)
baseurl=http://10.63.215.7/Aliyun/CentOS/7/64bit/extras
path=/
enabled=1
gpgcheck=0
5.13 建立定時(shí)同步,每周一的3點(diǎn)同步:
crontab -e
0 3 * * 1?/usr/bin/reposync -np???/usr/share/nginx/html/Aliyun/CentOS/7/64bit
參考:centos7搭建自己的yum源 - juandx - 博客園
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CentOS7下的YUM源服務(wù)器搭建詳解_Ivan_fay的博客-CSDN博客文章來源:http://www.zghlxwxcb.cn/news/detail-806555.html
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?同步阿里云鏡像到本地,在本地搭建YUM倉庫 - bamboo233 - 博客園文章來源地址http://www.zghlxwxcb.cn/news/detail-806555.html
到了這里,關(guān)于reposync命令詳解--reposync同步aliyunyum庫到本地的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!