自動化運維之自定義yum源

本文記錄創建自定義yum倉庫,目的爲方便安裝定製的rpm包及開源組件版本統一。

一、Build Local Repository

1、搭建web服務,自己定製的rpm包tengine,所以安裝起來就很簡單了。

#cd /home/master/software

#rpm -ivh rpm -ivh tengine-2.1.0-0.el6.x86_64.rpm

#vi /opt/config/tengine/vhost/yum.conf

server {
        listen 80;
        server_name yum.ttp.cc;
        location / {
          root /opt/yum;
          index index.htm index.html;
        }
}

#/etc/init.d/rc.tengine start

2、安裝createrepo(如果系統有安裝這個包,忽略這步)

#yum install createrepo -y

3、自定義repo文件

#cd /etc/yum.repos.d

#vi ttpai.repo

[centos]
name=ttpai centos yum
baseurl=http://yum.ttp.cc/centos/$releasever/os/$basearch/Packages
gpgcheck=0
priority=2

[updates]
name=ttpai centos update
baseurl=http://yum.ttp.cc/centos/$releasever/updates/$basearch/Packages
gpgcheck=0
priority=2

[epel]
name=ttpai epel yum
baseurl=http://yum.ttp.cc/epel/$releasever/$basearch
gpgcheck=0
priority=3

[ttpai]
name=ttpai local yum
baseurl=http://yum.ttp.cc/ttpai/
gpgcheck=0
priority=1

#createrepo -v /opt/yum/

After creating repository, disable or rename the existing repositories.

4、Now update the repository files:

#yum clean all

#yum update

//列出本地倉庫的軟件包

[root@localhost yum.repos.d]# ls -l /opt/yum/
總用量 275740
#ls -l /opt/yum
drwxrwxr-x 3 master master 4096 8月  31 09:54 centos
drwxrwxr-x 3 master master 4096 8月  31 09:55 epel
drwxr-xr-x 2 root   root   4096 9月   7 14:24 repodata
-rw-rw-r-- 1 master master  304 8月  31 10:45 rsync_mirror.sh
drwxrwxr-x 3 master master 4096 9月   7 11:15 ttpai

二、Client Side Configuration

#cd /etc/yum.repos.d

#vi ttpai.repo

[centos]
name=ttpai centos yum
baseurl=http://yum.ttp.cc/centos/$releasever/os/$basearch/Packages
gpgcheck=0
priority=2

[updates]
name=ttpai centos update
baseurl=http://yum.ttp.cc/centos/$releasever/updates/$basearch/Packages
gpgcheck=0
priority=2

[epel]
name=ttpai epel yum
baseurl=http://yum.ttp.cc/epel/$releasever/$basearch
gpgcheck=0
priority=3

[ttpai]
name=ttpai local yum
baseurl=http://yum.ttp.cc/ttpai/
gpgcheck=0
priority=1

#yum clean all

#yum update

//驗證rpm包是否爲自定義倉庫的包

[root@s03 yum.repos.d]# yum list all |grep tomcat
apache-tomcat-apis.noarch                   0.1-1.el6                    centos
glite-security-trustmanager-tomcat6.noarch  2.5.5-6.el6                  epel   
jakarta-commons-collections-tomcat5.noarch  3.2.1-3.4.el6                centos
jakarta-commons-dbcp-tomcat5.noarch         1.2.1-13.8.el6               centos
jakarta-commons-pool-tomcat5.x86_64         1.3-12.7.el6                 centos
jglobus-ssl-proxies-tomcat.noarch           2.1.0-2.el6                  epel   
tomcat.noarch                               7.0.33-4.el6                 epel   
tomcat.x86_64                               1:6.0.43-0.el6               ttpai  
tomcat-admin-webapps.noarch                 7.0.33-4.el6                 epel   
tomcat-docs-webapp.noarch                   7.0.33-4.el6                 epel   
tomcat-dubbo.x86_64                         7.0.62-0.el6                 ttpai  
tomcat-el-2.2-api.noarch                    7.0.33-4.el6                 epel   
tomcat-javadoc.noarch                       7.0.33-4.el6                 epel   
tomcat-jsp-2.2-api.noarch                   7.0.33-4.el6                 epel   
tomcat-jsvc.noarch                          7.0.33-4.el6                 epel   
tomcat-lib.noarch                           7.0.33-4.el6                 epel   
tomcat-servlet-3.0-api.noarch               7.0.33-4.el6                 epel   
tomcat-webapps.noarch                       7.0.33-4.el6                 epel   
tomcat6.x86_64                              6.0.24-90.el6                centos
tomcat6-admin-webapps.x86_64                6.0.24-90.el6                centos
tomcat6-docs-webapp.x86_64                  6.0.24-90.el6                centos
tomcat6-el-2.1-api.x86_64                   6.0.24-90.el6                centos
tomcat6-javadoc.x86_64                      6.0.24-90.el6                centos
tomcat6-jsp-2.1-api.x86_64                  6.0.24-90.el6                centos
tomcat6-lib.x86_64                          6.0.24-90.el6                centos
tomcat6-servlet-2.5-api.x86_64              6.0.24-90.el6                centos
tomcat6-webapps.x86_64                      6.0.24-90.el6                centos
tomcatjss.noarch                            2.1.0-4.el6                  centos

三、腳本同步源centos和epel

#cat rsync_mirror.sh
#!/bin/sh
#rsync -avz  rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/* /opt/yum/centos/6/os/x86_64/Packages/
rsync -avz  rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64/Packages/* /opt/yum/centos/6/updates/x86_64/Packages/
rsync -avz  rsync://mirrors.ustc.edu.cn/epel/6/* /opt/yum/epel/6                                                                                                                                           

參考鏈接:http://www.unixmen.com/setup-local-yum-repository-on-centos-rhel-scientific-linux-6-4                                                                                    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章