ローカルyumウェアハウスとローカルエリアネットワークyumウェアハウスの構成

10924 ワード

一、CentOSローカルソースの設定


1.元のrepoソースファイルのバックアップと削除
[root@rd-proxy yum.repos.d]# tar -jcv -f CentOS.repo.tar.bz3 CentOS-*
CentOS-Base.repo
CentOS-Debuginfo.repo
CentOS-Media.repo
CentOS-Vault.repo
[root@rd-proxy yum.repos.d]# ll
total 21
-rw-r--r--  2 root root 2294 Oct 30 19:06 CentOS-Base.repo
-rw-r--r--. 2 root root  638 Feb 25  2013 CentOS-Debuginfo.repo
-rw-r--r--  2 root root  630 Oct 30 19:03 CentOS-Media.repo
-rw-r--r--  2 root root 1579 Oct 30 19:12 CentOS.repo.tar.bz2
-rw-r--r--. 2 root root 3664 Feb 25  2013 CentOS-Vault.repo

[root@rd-proxy yum.repos.d]# rm -f CentOS-*
[root@rd-proxy yum.repos.d]# ll
total 5
-rw-r--r-- 2 root root 1579 Oct 30 19:12 CentOS.repo.tar.bz2

2.repoファイルの新規作成
[root@rd-proxy yum.repos.d]# vi Centos-Base.repo
[local_server]
# 
name=This is a local repo
# 
baseurl=file:///media/cdrom
# , 
enable=1
# ,1 0 
gpgcheck=1
# key, key
"Centos-Base.repo" 6L, 89C written

3.すべてのキャッシュをクリア
[root@rd-proxy yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: local_server
Cleaning up Everything
Cleaning up list of fastest mirrors

4.ローカルキャッシュの再構築
[root@rd-proxy yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
local_server                                                                                                                   | 5.0 kB     00:00 ... 
local_server/group_gz                                                                                                          | 210 kB     00:00 ... 
local_server/filelists_db                                                                                                      | 5.8 MB     00:00 ... 
local_server/primary_db                                                                                                        | 4.5 MB     00:00 ... 
local_server/other_db                                                                                                          | 2.0 MB     00:00 ... 
Metadata Cache Created

5.テスト
[root@rd-proxy yum.repos.d]# yum install bind-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bind-utils.i686 32:9.8.2-0.17.rc1.el6 will be installed
--> Processing Dependency: bind-libs = 32:9.8.2-0.17.rc1.el6 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Processing Dependency: liblwres.so.80 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Processing Dependency: libisccfg.so.82 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Processing Dependency: libisccc.so.80 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Processing Dependency: libisc.so.83 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Processing Dependency: libdns.so.81 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Processing Dependency: libbind9.so.80 for package: 32:bind-utils-9.8.2-0.17.rc1.el6.i686
--> Running transaction check
---> Package bind-libs.i686 32:9.8.2-0.17.rc1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                           Arch                        Version                                      Repository                           Size
======================================================================================================================================================
Installing:
 bind-utils                        i686                        32:9.8.2-0.17.rc1.el6                        local_server                        180 k
Installing for dependencies:
 bind-libs                         i686                        32:9.8.2-0.17.rc1.el6                        local_server                        882 k

Transaction Summary
======================================================================================================================================================
Install       2 Package(s)

Total download size: 1.0 M
Installed size: 2.7 M
Is this ok [y/N]: y
Downloading Packages:
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                  23 MB/s | 1.0 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 32:bind-libs-9.8.2-0.17.rc1.el6.i686                                                                                               1/2 
  Installing : 32:bind-utils-9.8.2-0.17.rc1.el6.i686                                                                                              2/2 
  Verifying  : 32:bind-utils-9.8.2-0.17.rc1.el6.i686                                                                                              1/2 
  Verifying  : 32:bind-libs-9.8.2-0.17.rc1.el6.i686                                                                                               2/2 

Installed:
  bind-utils.i686 32:9.8.2-0.17.rc1.el6                                                                                                               

Dependency Installed:
  bind-libs.i686 32:9.8.2-0.17.rc1.el6                                                                                                              
Complete!

#二、ローカルエリアネットワークyumソース構成
1.必要なツールcreaterepo:倉庫ファイル作成ツールhttpd,ftp:転送ツール
2.環境準備server:ikulin 10.10.10.10.1 client:localhost 10.10.10.3 linux:centos 7
3.serverコピーディスクrpmパッケージをローカルhttpディレクトリに
[linxy@ikulin media]$ cp -r Packages/ /var/www/html/yum

4.server生成倉庫の作成
[linxy@ikulin yum]$ createrepo .
Spawning worker 0 with 2398 pkgs
Spawning worker 1 with 2398 pkgs
Spawning worker 2 with 2398 pkgs
Spawning worker 3 with 2397 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

5.serverがhttpサービスを開始
[linxy@ikulin html]$ sudo systemctl restart httpd

6.client構成repoソース
[root@localhost yum.repos.d]# cat CentOS-Base.repo 
[C7]
name=CentOS7
baseurl=http://10.10.10.1/yum
gpgcheck=0

7.clientすべてのキャッシュをクリア
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: C7
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors

8.clientローカルキャッシュの再構築(失敗)
8.1.障害1、ファイアウォールの設定の問題
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
http://10.10.10.1/yum/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to 10.10.10.1:80; No route to host"
Trying other mirror.
^Chttp://10.10.10.1/yum/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted"

トラブルシューティング:
  • 障害提示routeなしではサーバに接続できないが、サーバ上でテストアクセスはok、連通性テストはokであり、ファイアウォールがアクセス要求
  • をブロックしていると判断する.
  • c/sのselinux、iptablesをチェックするのはオフですがcentos 7からデフォルトのファイアウォールはfirewalld、クエリーステータスはオープン
  • です.
  • serverのfirewalldサービスをオフにすると、障害2
  • が発生します.
    8.2.障害2,httpディレクトリ権限設定の問題
    [root@localhost yum.repos.d]# yum makecache
    Loaded plugins: fastestmirror
    http://10.10.10.1/yum/repodata/repomd.xml: [Errno 14] HTTP Error 403 - Forbidden

    トラブルシューティング:
  • 障害プロンプトアクセス拒否、curlを使用してサーバokにアクセスし、下位ディレクトリへのアクセスが拒否され、ディレクトリまたはファイルアクセス権限の設定が正しくないと判断する
  • .
  • yum下の倉庫データディレクトリrepodataをチェックする権限は744であり、非所属ユーザーアクセスは読み取り専用権限のみを有し、ディレクトリは
  • に入るには実行権限を有しなければならない.
  • repodataディレクトリの変更権限は745
    [linxy@ikulin yum]$ ll -d  rep*
    drwxr--r-- 2 root root 4096 Feb 16 22:47 repodata
    [linxy@ikulin yum]$ sudo chmod 745 repodata/
    [linxy@ikulin yum]$ ll -d  rep*
    drwxr--r-x 2 root root 4096 Feb 16 22:47 repodata
    8.3である.Clientローカルキャッシュ再構築
  • 完了
    [root@localhost ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: C7
    Cleaning up everything
    Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
    [root@localhost ~]# du -h /var/cache/yum/
    0   /var/cache/yum/x86_64/7/C7/gen
    0   /var/cache/yum/x86_64/7/C7/packages
    0   /var/cache/yum/x86_64/7/C7
    0   /var/cache/yum/x86_64/7/base/gen
    0   /var/cache/yum/x86_64/7/base/packages
    8.0K    /var/cache/yum/x86_64/7/base
    0   /var/cache/yum/x86_64/7/extras/gen
    0   /var/cache/yum/x86_64/7/extras/packages
    0   /var/cache/yum/x86_64/7/extras
    0   /var/cache/yum/x86_64/7/updates/gen
    0   /var/cache/yum/x86_64/7/updates/packages
    0   /var/cache/yum/x86_64/7/updates
    12K /var/cache/yum/x86_64/7
    12K /var/cache/yum/x86_64
    12K /var/cache/yum/
    
    [root@localhost yum.repos.d]# yum makecache
    Loaded plugins: fastestmirror
    C7                                                                                                                             | 2.9 kB  00:00:00     
    (1/3): C7/primary_db                                                                                                           | 5.7 MB  00:00:00     
    (2/3): C7/filelists_db                                                                                                         | 6.6 MB  00:00:00     
    (3/3): C7/other_db                                                                                                             | 2.4 MB  00:00:00     
    Determining fastest mirrors
    Metadata Cache Created
    [root@localhost yum.repos.d]# du -h /var/cache/yum
    85M /var/cache/yum/x86_64/7/C7/gen
    0   /var/cache/yum/x86_64/7/C7/packages
    99M /var/cache/yum/x86_64/7/C7
    0   /var/cache/yum/x86_64/7/base/gen
    0   /var/cache/yum/x86_64/7/base/packages
    8.0K    /var/cache/yum/x86_64/7/base
    0   /var/cache/yum/x86_64/7/extras/gen
    0   /var/cache/yum/x86_64/7/extras/packages
    0   /var/cache/yum/x86_64/7/extras
    0   /var/cache/yum/x86_64/7/updates/gen
    0   /var/cache/yum/x86_64/7/updates/packages
    0   /var/cache/yum/x86_64/7/updates
    99M /var/cache/yum/x86_64/7
    99M /var/cache/yum/x86_64
    99M /var/cache/yum

    9.テスト検証
    [root@localhost yum.repos.d]# yum search wget
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    ================================================================= N/S matched: wget ==================================================================
    wget.x86_64 : A utility for retrieving files using the HTTP or FTP protocols
    
      Name and summary matches only, use "search all" for everything.

    転載先:https://blog.51cto.com/linxy/2071873