Create Local Repository

Configure Firewall

  1. [root@localhost ~]# systemctl stop firewalld.service
  2. [root@localhost ~]# systemctl disable firewalld.service

Install Httpd & Start Service

  1. [root@localhost ~]# yum install httpd -y
  2. [root@localhost ~]# systemctl enable httpd.service
  3. [root@localhost ~]# systemctl restart httpd.service
  4. [root@localhost ~]# systemctl status httpd.service

Now, Take the Browser

http://192.168.220.200

Install Reposync

  1. [root@localhost ~]# yum install yum-utils -y

Create Repo Dir

  1. [root@localhost ~]# mkdir /var/www/html/myrepo
  2. [root@localhost ~]# cd /var/www/html/myrepo

List Repo

  1. [root@localhost myrepo]# yum repolist
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4.  * base: mirrors.163.com
  5.  * extras: mirrors.163.com
  6.  * updates: mirrors.aliyun.com
  7. repo id                                                 repo name                                                  status
  8. base/7/x86_64                                           CentOS-7 - Base                                            9,591
  9. extras/7/x86_64                                         CentOS-7 - Extras                                            284
  10. updates/7/x86_64                                        CentOS-7 - Updates                                         1,490
  11. repolist: 11,365

Sync Repo

  1. [root@localhost myrepo]# reposync --repoid=base
  2. [root@localhost myrepo]# reposync --repoid=updates
  3. [root@localhost myrepo]# reposync --repoid=extras
  4. [root@localhost myrepo]# pwd
  5. /var/www/html/myrepo
  6. [root@localhost myrepo]# ls -al
  7. total 0
  8. drwxr-xr-x. 5 root root 47 Dec  6 20:18 .
  9. drwxr-xr-x. 3 root root 20 Dec  6 03:12 ..
  10. drwxr-xr-x. 3 root root 22 Dec  6 03:48 base
  11. drwxr-xr-x. 3 root root 22 Dec  6 20:18 extras
  12. drwxr-xr-x. 3 root root 22 Dec  6 20:06 updates

Install Createrepo

  1. [root@localhost ~]# yum install createrepo -y

Create Repo

  1. [root@localhost ~]# createrepo /var/www/html/myrepo/base
  2. Spawning worker 0 with 9591 pkgs
  3. Workers Finished
  4. Saving Primary metadata
  5. Saving file lists metadata
  6. Saving other metadata
  7. Generating sqlite DBs
  8. Sqlite DBs complete
  9. [root@localhost ~]# createrepo /var/www/html/myrepo/updates
  10. Spawning worker 0 with 1490 pkgs
  11. Workers Finished
  12. Saving Primary metadata
  13. Saving file lists metadata
  14. Saving other metadata
  15. Generating sqlite DBs
  16. Sqlite DBs complete
  17. [root@localhost ~]# createrepo /var/www/html/myrepo/extras
  18. Spawning worker 0 with 284 pkgs
  19. Workers Finished
  20. Saving Primary metadata
  21. Saving file lists metadata
  22. Saving other metadata
  23. Generating sqlite DBs
  24. Sqlite DBs complete

Now, Take the Browser

http://192.168.220.200/myrepo/

Update Client Repo

  1. [root@localhost ~]# diff /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak 
  2. 15c15
  3. < baseurl=http://192.168.220.200/myrepo/base
  4. ---
  5. > mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
  6. 17c17
  7. < gpgcheck=0
  8. ---
  9. > gpgcheck=1
  10. 23c23
  11. < baseurl=http://192.168.220.200/myrepo/updates
  12. ---
  13. > mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
  14. 25c25
  15. < gpgcheck=0
  16. ---
  17. > gpgcheck=1
  18. 31c31
  19. < baseurl=http://192.168.220.200/myrepo/extras
  20. ---
  21. > mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
  22. 33c33
  23. < gpgcheck=0
  24. ---
  25. > gpgcheck=1

Make Client Cache

  1. [root@localhost ~]# yum clean all && yum makecache

Client Example

  1. [root@localhost ~]# yum install vim
  2.  

Leave a Reply

Your email address will not be published. Required fields are marked *