1.備份並刪除原始的repo源文件html
[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文件 linux
[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.清除全部緩存sql
[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.重建本地緩存centos
[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!
#2、局域網yum源配置服務器
1.所需工具
createrepo:倉庫文件建立工具
httpd,ftp:傳輸工具curl
2.環境準備
server:ikulin 10.10.10.1
client:localhost 10.10.10.3
linux:centos7ide
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啓動httpd服務
[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"
故障排除:
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
故障排除:
[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.