[实践OK]用reposync 同步YUM源到本地,搭建本地YUM源服务器 不指定

jackxiang 2016-7-11 14:16 | |
repo只要自己知道RPM位置,自己也可以写:


同步的是ymrepos.d里面的仓库明儿,一般都带x86或啥的,如果有多台不是64位成32位的需要yum下载,则不要用变量,直接写和服务器不一样的变量写死如死x86这样的路径。
关于CentOS6主CentOS7的不同变量了解,下面是centOS7的:
http://rpms.adiscon.com/v8-stable/epel-$releasever/$basearch
http://rpms.adiscon.com/v8-stable/epel-7/x86_64/
单位的机器是CentOS6且是64位的,上面的变量就变成:
http://rpms.adiscon.com/v8-stable/epel-6/x86_64/RPMS/
如果是32位的呢?变量部分会变成如下,就是这样:
http://rpms.adiscon.com/v8-stable/epel-6/i386/RPMS/
http://m.2cto.com/net/201512/455901.html

这个参数不常用,但提到架构问题了x86还是64位的:
  -a ARCH, --arch=ARCH  act as if running the specified arch (default: current
                        arch, note: does not override $releasever. x86_64 is a
                        superset for i*86.)

cat /etc/yum.repos.d/rsyslog.repo |grep releasever
name=Adiscon CentOS-$releasever - local packages for $basearch
#baseurl=http://rpms.adiscon.com/v8-stable/epel-$releasever/$basearch
===============================================================
如果执行的时候yum.repos.d里面的文件url写错了,会出现如下错误,也就是说写的目录下面必须有repodata这个索引文件夹:
http://rpms.adiscon.com/v8-stable/epel-6/i386/RPMS/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
也就是它会去repos的索引里面找,改为:
baseurl=http://rpms.adiscon.com/v8-stable/epel-6/i386          再:yum clean all就可以在64位机器下载同步使用32位,供32位 使用。  
baseurl=http://rpms.adiscon.com/v8-stable/epel-7/x86_64/

上面这些文件形成多个repo,于是就可能在一台X86_64位的机器上下载多种架构的机型,只有配置多个repos文件:
reposync --repoid=rsyslog_v8_32
[rsyslog_v8_32]
baseurl=http://rpms.adiscon.com/v8-stable/epel-6/i386

[rsyslog_v8_64]
baseurl=http://rpms.adiscon.com/v8-stable/epel-6/x86_64
reposync --repoid=rsyslog_v8_64



同样:
[root@iZ25dcp92ckZ tmp]# reposync --repoid=rsyslog_v8_i386
/tmp/rsyslog_v8_i386/RPMS/*.rpm

建立软链接:
ln -s /tmp/rsyslog_v8_i386/RPMS /data/www/yum/centos/6/x86_64/rsyslog_v8_i386
ln -s /tmp/rsyslog_v8_64/RPMS /data/www/yum/centos/6/x86_64/rsyslog_v8_64
这样,两个版本都能同时提供服务了:
直接cd 到/data/www/yum/centos/6/x86_64 ,createrepo --update -d -p -o . .  ,它会扫子目录的如/data/www/yum/centos/6/x86_64/rsyslog_v8_64 和 /data/www/yum/centos/6/x86_64/rsyslog_v8_i386:
cat /etc/yum.repos.d/cntv-irdc.repo
[cntv-irdc]
name=Centos $releasever - $basearch rpm repository
baseurl=http://10.70.41.222/centos/$releasever/$basearch

==============================================================
最终目的是想:elk+kafka+rsyslog+hadoophdfs+zookeeper搭建及其应用,http://www.it165.net/admin/html/201604/7496.html。
CentOS6.5安装配置官方最新版rsyslog:  http://blog.chinaunix.net/uid-21142030-id-5616974.html
总原则及结论:在YUM仓库下建立一个新的目录存放,在上一层建立索引,也可读取到子目录的方法。

同步思想:三台机器,一台用来reposync同步并在上面开一个rsyncd的服务指向,另两台来同步它,
A:上面有crontab去定时reposync,同时有一个定时同步rpm后createrepo --update -d -p -o . . 。
BC两台:  在定时同步A完成后,也需要作一下:createrepo --update -d -p -o . . ,更新一下索引。
步骤零:
关于CentOS6主CentOS7的不同变量了解,下面是centOS7的:
http://rpms.adiscon.com/v8-stable/epel-$releasever/$basearch
http://rpms.adiscon.com/v8-stable/epel-7/x86_64/
单位的机器是CentOS6且是64位的,上面的变量就变成:
http://rpms.adiscon.com/v8-stable/epel-6/x86_64/RPMS/
如果是32位的呢?变量部分会变成如下,就是这样:
http://rpms.adiscon.com/v8-stable/epel-6/i386/RPMS/


步骤一:安装必要的reposync的rpm包和repo同步的源:
rpm 包安装需要: yum-utils-1.1.30-37.el6.noarch
rpm -qf /usr/bin/reposync  安装包是:yum-utils-1.1.30-37.el6.noarch
yum install -y http://rdo.fedorapeople.org/rdo-release.rpm


步骤二:
安装后如何同步:
wget http://rpms.adiscon.com/v8-stable/rsyslog.repo -o /etc/yum.repos.d/rsyslog.repo
/etc/yum.repos.d/rsyslog.repo

http://rpms.adiscon.com/ 里全是各个版本的rpm包。

cd /data/www/yum/centos/6/x86_64/rsyslog_v8

[root@bj_szq_yum_repos_36_172 rsyslog_v8]# reposync --repoid=rsyslog_v8
Error setting up repositories: Cannot retrieve repository metadata (repomd.xml) for repository: rsyslog_v8. Please verify its path and try again

抓取这块咱还需要再商量商量下抓取地址和同步范围:
http://www.rsyslog.com/rhelcentos-rpms/

http://rpms.adiscon.com/v8-stable/rsyslog.repo
http://rpms.adiscon.com/v8-stable/
————————————————————————————
http://king9527.blog.51cto.com/84461/1096111
http://gdlwolf.blog.51cto.com/343866/1729020
http://www.ipcpu.com/2015/08/reposync-yum/
http://www.programgo.com/article/53684909700/

用reposync 同步YUM源到本地,搭建本地YUM源服务器:
http://www.tuicool.com/articles/7rANJj
————————————————————————————
#安装rdo的源文件
yum install -y http://rdo.fedorapeople.org/rdo-release.rpm
#查看源ID的列表
yum repolist
摘自:http://www.ipcpu.com/2015/08/reposync-yum/

发现这个rpm包其实就是向/etc/yum.repos.d里添加一个repo文件,如下:
rpm -qpl rdo-release.rpm
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
/etc/yum.repos.d/rdo-release.repo
/etc/yum.repos.d/rdo-testing.repo

安装发现多了上面这俩文件:
rpm -ihv rdo-release.rpm
准备中...                          ################################# [100%]
正在升级/安装...
1:rdo-release-mitaka-5             ################################# [100%]
[root@iZ25dcp92ckZ yum.repos.d]# ls -lart rdo-*
-rw-r--r-- 1 root root 326 6月  14 05:57 rdo-testing.repo
-rw-r--r-- 1 root root 209 6月  14 05:57 rdo-release.repo
查看仓库:
yum repolist |grep openstack
openstack-mitaka/x86_64 OpenStack Mitaka Repository                        1,182


mkdir -p /data/htdocs/openstack
cd   /data/htdocs/openstack
找仓库:
cat rdo-release.repo |grep openstack-mitaka
[openstack-mitaka]
baseurl=http://mirror.centos.org/centos/7/cloud/$basearch/openstack-mitaka/
找到了:
reposync --repoid=openstack-mitaka

实践如下: du -sh /data/htdocs/openstack/ 277M    /data/htdocs/openstack/
reposync --repoid=openstack-mitaka
Xaw3d-1.6.2-4.el7.x86_64.rpm   FAILED                                                          ]  15 kB/s |  32 kB  12:11:55 ETA
warning: /data/htdocs/openstack/openstack-mitaka/common/Xaw3d-devel-1.6.2-4.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 764429e6: NOKEY
Xaw3d-devel-1.6.2-4.el7.x86_64.rpm 的公钥尚未安装
(1/1182): Xaw3d-devel-1.6.2-4.el7.x86_64.rpm                                                              |  58 kB  00:00:03    
(2/1182): babel-1.3-6.el7.noarch.rpm                                                                      |  15 kB  00:00:01    
(3/1182): babel-2.3.4-1.el7.noarch.rpm                                                                    |  18 kB  00:00:01    
(4/1182): babel-doc-1.3-6.el7.noarch.rpm                                                                  | 208 kB  00:00:14    
(5/1182): babel-doc-2.3.4-1.el7.noarch.rpm                                                                | 234 kB

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/8801/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2016-8-24 19:23
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]