Create a local Yum repository

Source: Internet
Author: User
Tags rsync yum repolist aliyun

First, self-built Epel source
  
 
  1. # 1、创建epel存放目录
  2. mkdir /var/www/html/epel/6Server/x86_64 -p
  3. # 2、安装apache
  4. yum install httpd
  5. /etc/init.d/httpd start

  6. # 3、创建同步脚本
  7. mkdir /server/scripts
  8. cat > /server/scripts/yum_rsync.sh << EOF
  9. /usr/bin/rsync -avrt rsync://mirrors.ustc.edu.cn/epel/6Server/x86_64/  /var/www/html/epel/6Server/x86_64
  10. EOF

  11. # 4、创建计划任务,每天同步epel源
  12. cat >> /var/spool/cron/root << EOF
  13. # 20150707 by test
  14. 0 1 * * * root /server/scripts/yum_rsync.sh
  15. EOF

  16. # 5、指向yum源
  17. cat >> /etc/yum.repos.d/CentOS-Base.repo << EOF
  18. [test-epel]
  19. name=CentOS-\$releasever-epel
  20. baseurl=http://172.16.0.114/epel/6Server/\$basearch
  21. #baseurl=http://172.16.0.114/epel/6Server/x86_64/
  22. enabled=1
  23. gpgcheck=0
  24. EOF

  25. # 6、测试
  26. [[email protected] ~]# yum repolist
  27. Loaded plugins: fastestmirror, security
  28. Loading mirror speeds from cached hostfile
  29. * base: mirrors.aliyun.com
  30. * extras: mirrors.aliyun.com
  31. * updates: mirrors.aliyun.com
  32. base                                                                            | 3.7 kB     00:00    
  33. extras                                                                               | 3.4 kb     00:00    
  34. test-epel                                                                           | 4.4 kb     00:00    
  35. updates                                                                             | 3.4 kb     00:00    
  36. repo id                           Repo name                                                          status
  37. base                               CentOS-6-base-mirrors.aliyun.com                               6,518
  38. extras                             CentOS-6-extras-mirrors.aliyun.com                               
  39. test-epel                          centos-6-epel                                                      11,653
  40. updates                          CentOS-6 - Updates - mirrors.aliyun.com                          1,307
  41. repolist: 19,516

Ii. creating a Yum repository with a disc
  
 
  1. # 1、创建yum源的目录
  2. mkdir /tmp/CentOS6.6 /media/cdrom
  3. # 2、将centos光盘
  4. mount -r /dev/cdrom /media/cdrom
  5. # 3、拷贝文件到可以写的位置
  6. cp /media/cdrom/Packages/* /tmp/CentOS6.6/
  7. # 4、创建yum仓库
  8. yum -y install createrepo
  9. cd /tmp
  10. createrepo /tmp/CentOS6.6/
  11. createrepo -g /tmp/CentOS6.6/
  12. # 5、生成相应的文件
  13. [[email protected] repodata]# ls /tmp/CentOS6.6/repodata
  14. 2492566dbeda19963c5a8a638185aa1e858aa6dea5f145b7090a7816fa63162e-filelists.sqlite.bz2
  15. 280947c3ee9847a2312ddb02e6b91ecacbbc29bde81d4c094e2e9f25e210ead7-primary.sqlite.bz2
  16. 73d30f44b66092492893e3ce0bbf8c20ffd625b7eca70b04c6776e216e1149a4-filelists.xml.gz
  17. 858abeedbb1e06aacfff0cd8d90f7948fdcd232f82e1dfb3c4f308cb7d79b314-other.xml.gz
  18. 970f7ec74fbca72ff525949a31dcfae8fd98a5ed27674b978e441593b2dddf5d-other.sqlite.bz2
  19. aa9011cf9321a5b1eab983fba6612218dab558a2618a1ad5a5a0d0f6f0026446-primary.xml.gz
  20. repomd.xml
  21. # 6、对默认的YUM仓库改名,创建自己的地址
  22. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
  23. # 7、创建自己的yum源
  24. cat > /etc/yum.repos.d/cat my.repo << EOF
  25. [myrepo]
  26. name=myrepo
  27. baseurl=file:///tmp/CentOS6.6
  28. gpgcheck=0
  29. EOF
  30. # 8、创建成功
  31. [[email protected] yum.repos.d]# yum repolist
  32. Loaded plugins: fastestmirror, refresh-packagekit, security
  33. Loading mirror speeds from cached hostfile
  34. myrepo | 2.9 kB 00:00 ...
  35. myrepo/primary_db | 3.4 MB 00:00 ...
  36. repo id repo name status
  37. myrepo myrepo 4,184
  38. repolist: 4,184

Reference article: http://www.osyunwei.com/archives/7918.html

Create a local Yum repository

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.