maehachi08 Anything Blog

2012年04月25日
Cobblerでyumレポジトリのミラーサイトを構築

Cobbler repoコマンドでミラーレポジトリの構築

今日、会社ではまった内容なので、メモがてら記事にします。
cobblerにはyumレポジトリを構築できる素晴らしい機能が備わっていて、以前記事にもしました。
この時はローカルに配置したRPMパッケージ群をyumレポジトリ化することにチャンレンジしたのですが、今回は公開されているyumレポジトリのミラーサイトを構築したいと思います。

yumレポジトリのミラーレポジトリ構築

まずは確実に構築できる正しいコマンドを紹介します。

# cobbler repo add --name="CentOS6.2-x86_64-epel" --breed=rsync --mirror=rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/

# cobbler repo report --name=CentOS6.2-x86_64-epel

# cobbler reposync --only=CentOS6.2-x86_64-epel
task started: 2012-04-25_204838_reposync
task started (id=Reposync, time=Wed Apr 25 20:48:38 2012)
hello, reposync
run, reposync, run!
running: rsync -rltDv  --exclude-from=/etc/cobbler/rsync.exclude rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/ /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received: Welcome to JAIST Public Mirror Service (ftp.jaist.ac.jp).
If you have any problem, please contact ftp-admin@jaist.ac.jp.

receiving incremental file list
./
repodata/
repodata/repomd.xml

sent 228 bytes  received 508400 bytes  113028.44 bytes/sec
total size is 7036570339  speedup is 13834.41

running: createrepo  -c cache -s sha /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
7225/7225 - globus-libxml2-1.8-1.el6.x86_64.rpm                                 h.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata

creating: /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel/config.repo
running: chown -R root:apache /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received:
running: chmod -R 755 /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received:
*** TASK COMPLETE ***

今回はまったこと(mirrorオプションとbreedオプション)

  1. mirrorオプションのURLは rsync:// で指定すること
# cobbler repo add --name="CentOS6.2-x86_64-epel" --mirror=http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/

# cobbler repo report --name=CentOS6.2-x86_64-epel
Name                           : CentOS6.2-x86_64-epel
Arch                           : x86_64
Breed                          : yum
Comment                        :
Createrepo Flags               : <<inherit>>
Environment Variables          : {}
Keep Updated                   : True
Mirror                         : http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/
Mirror locally                 : True
Owners                         : ['admin']
Priority                       : 99
RPM List                       : []
Yum Options                    : {}

# cobbler reposync --only=CentOS6.2-x86_64-epel
task started: 2012-04-25_185515_reposync
task started (id=Reposync, time=Wed Apr 25 18:55:15 2012)
hello, reposync
run, reposync, run!
creating: /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel/.origin/CentOS6.2-x86_64-epel.repo
running: /usr/bin/reposync -l -m -d --config=/var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel/.origin/CentOS6.2-x86_64-epel.repo --repoid=CentOS6.2-x86_64-epel --download_path=/var/www/cobbler/repo_mirror -a x86_64
received:
Exception occured: cobbler.cexceptions.CX
Exception value: 'cobbler reposync failed'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 123, in die
    raise CX(msg)

Exception occured: cobbler.cexceptions.CX
Exception value: 'cobbler reposync failed'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 119, in run
    self.sync(repo)
   File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 150, in sync
    return self.yum_sync(repo)
   File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 383, in yum_sync
    utils.die(self.logger,"cobbler reposync failed")
   File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 131, in die
    raise CX(msg)

reposync failed, tries left: 0
reposync failed, retry limit reached, skipping
running: chown -R root:apache /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received:
running: chmod -R 755 /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received:
Exception occured: cobbler.cexceptions.CX
Exception value: 'overall reposync failed, at least one repo failed to synchronize'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 123, in die
    raise CX(msg)

Exception occured: cobbler.cexceptions.CX
Exception value: 'overall reposync failed, at least one repo failed to synchronize'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/remote.py", line 95, in run
    rc = self._run(self)
   File "/usr/lib/python2.3/site-packages/cobbler/remote.py", line 239, in runner
    3), name=name, nofail=True, logger=self.logger)
   File "/usr/lib/python2.3/site-packages/cobbler/api.py", line 636, in reposync
    return reposync.run(name)
   File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 135, in run
    utils.die(self.logger,"overall reposync failed, at least one repo failed to synchronize")
   File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 131, in die
    raise CX(msg)

!!! TASK FAILED !!!

mirrorオプションとbreedオプションの修正と新たなエラー

# cobbler repo report --name=CentOS6.2-x86_64-epel
Name                           : CentOS6.2-x86_64-epel
Arch                           : x86_64
Breed                          : yum
Comment                        :
Createrepo Flags               : <<inherit>>
Environment Variables          : {}
Keep Updated                   : True
Mirror                         : http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/
Mirror locally                 : True
Owners                         : ['admin']
Priority                       : 99
RPM List                       : []
Yum Options                    : {}


# cobbler repo edit --name=CentOS6.2-x86_64-epel --mirrro=rsync://ftp.riken.jp/Linux/fedora/epel/6/x86_64/

# cobbler repo edit --name=CentOS6.2-x86_64-epel --breed=rsync

# cobbler repo report --name=CentOS6.2-x86_64-epel
Name                           : CentOS6.2-x86_64-epel
Arch                           : x86_64
Breed                          : rsync
Comment                        :
Createrepo Flags               : <<inherit>>
Environment Variables          : {}
Keep Updated                   : True
Mirror                         : rsync://ftp.riken.jp/Linux/fedora/epel/6/x86_64/
Mirror locally                 : True
Owners                         : ['admin']
Priority                       : 99
RPM List                       : []
Yum Options                    : {}

# cobbler reposync --only=CentOS6.2-x86_64-epel
task started: 2012-04-25_195317_reposync
task started (id=Reposync, time=Wed Apr 25 19:53:17 2012)
hello, reposync
run, reposync, run!
running: rsync -rltDv  --exclude-from=/etc/cobbler/rsync.exclude rsync://ftp.riken.jp/Linux/fedora/epel/6/x86_64/ /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received: -------------------------------------------------------------------------
  This ftp/http/rsync service is an unsupported service of RIKEN
Nishina Center for Research Support. Use entirely at your own risk
- no warranty is expressed or implied. All transfers are logged.
Request and questions should be sent to <admin@ftp.riken.jp>

(news) 2009.03.27 ftp.riken.jp is connected to WAN at 10 Gbps.
--------------------------------------------------------------------------


Exception occured: cobbler.cexceptions.CX
Exception value: 'cobbler reposync failed'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 123, in die
    raise CX(msg)

Exception occured: cobbler.cexceptions.CX
Exception value: 'cobbler reposync failed'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 119, in run
    self.sync(repo)
   File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 154, in sync
    return self.rsync_sync(repo)
   File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 228, in rsync_sync
    utils.die(self.logger,"cobbler reposync failed")
   File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 131, in die
    raise CX(msg)

reposync failed, tries left: 0
reposync failed, retry limit reached, skipping
running: chown -R root:apache /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received:
running: chmod -R 755 /var/www/cobbler/repo_mirror/CentOS6.2-x86_64-epel
received:
Exception occured: cobbler.cexceptions.CX
Exception value: 'overall reposync failed, at least one repo failed to synchronize'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 123, in die
    raise CX(msg)

Exception occured: cobbler.cexceptions.CX
Exception value: 'overall reposync failed, at least one repo failed to synchronize'
Exception Info:
  File "/usr/lib/python2.3/site-packages/cobbler/remote.py", line 95, in run
    rc = self._run(self)
   File "/usr/lib/python2.3/site-packages/cobbler/remote.py", line 239, in runner
    3), name=name, nofail=True, logger=self.logger)
   File "/usr/lib/python2.3/site-packages/cobbler/api.py", line 636, in reposync
    return reposync.run(name)
   File "/usr/lib/python2.3/site-packages/cobbler/action_reposync.py", line 135, in run
    utils.die(self.logger,"overall reposync failed, at least one repo failed to synchronize")
   File "/usr/lib/python2.3/site-packages/cobbler/utils.py", line 131, in die
    raise CX(msg)

!!! TASK FAILED !!!

実はrsyncをサポートしていなかった理研のレポジトリ

サブタイトル通りなのですが、上記でこのようなメッセージが出力されていました。

received: -------------------------------------------------------------------------
  This ftp/http/rsync service is an unsupported service of RIKEN
Nishina Center for Research Support. Use entirely at your own risk
- no warranty is expressed or implied. All transfers are logged.
Request and questions should be sent to <admin@ftp.riken.jp>

(news) 2009.03.27 ftp.riken.jp is connected to WAN at 10 Gbps.
--------------------------------------------------------------------------

ってことでjaistのレポジトリを試してみます。

# cobbler repo report --name=CentOS6.2-x86_64-epel
Name                           : CentOS6.2-x86_64-epel
Arch                           : x86_64
Breed                          : rsync
Comment                        :
Createrepo Flags               : <<inherit>>
Environment Variables          : {}
Keep Updated                   : True
Mirror                         : rsync://ftp.riken.jp/Linux/fedora/epel/6/x86_64/
Mirror locally                 : True
Owners                         : ['admin']
Priority                       : 99
RPM List                       : []
Yum Options                    : {}

# cobbler repo edit --name=CentOS6.2-x86_64-epel --mirror=rsync://ftp.riken.jp/Linux/fedora/epel/6/x86_64/

# cobbler repo report --name=CentOS6.2-x86_64-epel
Name                           : CentOS6.2-x86_64-epel
Arch                           : x86_64
Breed                          : rsync
Comment                        :
Createrepo Flags               : <<inherit>>
Environment Variables          : {}
Keep Updated                   : True
Mirror                         : rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/
Mirror locally                 : True
Owners                         : ['admin']
Priority                       : 99
RPM List                       : []
Yum Options                    : {}

# cobbler reposync --only=CentOS6.2-x86_64-epel

まとめ

詳しくは調べてないですが、breedオプションでプロトコルを正しく指定しないといけないこと、mirror先のURLも正しいプロトコルから始まるようにしないといけないこと、rsyncをサポートしないyumレポジトリサイトがあることを頭の隅に入れておかないとはまる可能性が大です!