码迷,mamicode.com
首页 > 其他好文 > 详细

创建本地 yum 仓库

时间:2015-07-07 20:59:11      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

一、自建epel源

  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. [root@yum ~]# 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                              38
  39. test-epel                        CentOS-6-epel                                                   11,653
  40. updates                          CentOS-6 - Updates - mirrors.aliyun.com                          1,307
  41. repolist: 19,516

二、用光盘创建yum仓库

  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. [root@localhost 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. [root@localhost 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

参考文章:


创建本地 yum 仓库

标签:

原文地址:http://www.cnblogs.com/kwstars/p/4628454.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!