搭建内部yum仓库(centos6+centos7+epel源)
搭建自己的yum仓库,将自己制作好的rpm包,添加到自己的yum源中。yum仓库服务端配置如下 :1. 创建yum仓库目录 mkdir -p /data/yum_data/
安装apache软件 [root@yum yum_data]# /etc/init.d/httpd start
#根据自己服务器ip地址进行配置 [root@yum yum_data]# echo "192.168.30.130 yum.nulige.com" >>/etc/hosts [root@yum yum_data]# tail -1 /etc/hosts #在window系统中添加hosts解析 192.168.30.130 yum.nulige.com #访问网站 在浏览器中输入:yum.nulige.com #修改配置文件/etc/httpd/conf/httpd.conf [root@yum yum_data]# cd /etc/httpd/conf #操作前先备份(运维一定要记住这点)
DocumentRoot "/data/yum_data/" #用搜索 /DocumentRoot 的方法
[root@yum conf]# chown -R apache.apache /data/yum_data/
[root@yum conf]# pwd #把配置移到tmp目录下,少用rm命令。 [root@yum httpd]# mv conf.d/welcome.conf /tmp 重启服务: or [root@yum httpd]# /etc/init.d/httpd restart #在windows系统中,通过浏览器输入yum.nulige.com 访问 5. 添加新的rpm包 #保留yum安装软件时不删除安装包
ll /var/cache/yum/x86_64/6/base/packages #把保留的rpm包,移到yum服务器目录中 [root@yum x86_64]#cd /var/cache/yum/x86_64/6/base/packages [root@yum packages]# mv */data/yum_data/centos/6/os/x86_64 [root@yum x86_64]# ll # 每加入一个rpm包就要更新一下 createrepo --update /data/yum_data/ 配置客户端配置#centos6.X 系统yum源配置 cd /etc/yum.repos.d 1[root@Byum.repos.d]#vilocalyum.repo 2[localyum] 3name=centos6 4baseurl=http://yum.nulige.com/centos/6/os/x86_64/ 5enable=1 6gpgcheck=0 7 8[localepel] 9name=epel 10baseurl= 11enable=1 12gpgcheck=0 13 14[localextra] 15name=extra 16baseurl= 17enable=118gpgcheck=0 备注:注意更改为自己的域名地址 centos7系统yum源配置方法 1[root@Byum.repos.d]#vilocalyum.repo 2[localyum] 3name=centos7 4baseurl=http://yum.nulige.com/centos/7/os/x86_64/ 5enable=1 6gpgcheck=0 7 8[localepel] 9name=epel 10baseurl= 11enable=1 12gpgcheck=0 13 14[localextra] 15name=extra 16baseurl= 17enable=1 18gpgcheck=0 #指定使用localyum库,并且是临时使用内网yum源,服务器重启后失效。 [root@YUM ~]# yum --enablerepo=localyum --disablerepo=base,extras,updates,epel list #永久使用需要修改配置文件将默认的repo文件关闭 cd /etc/yum.repos.d/ 1viCentOS-Base.repo2#在每一个启动的源加上3#enabled=0#改为1就启用,没有此参数也是启用。456[base]7…………8enabled=09[updates]10…………11enabled=012[extras]13…………14enabled=0 备注:还有其他开启的仓库就使用这个办法关闭。 或 使用下面方法,把/etc/yum.repos.d/ 下面的repo结尾文件,全部移到其它目录中去。 1mkdir-p/home/nulige/yum_backup23cd/etc/yum.repos.d45mv*/home/nulige/yum_backup 同步镜公网镜像yum源配置方法 但还有一种企业需求,说的更具体一点,平时大家yum安装软件都是从公网下载的,占用带宽,因此在公司里搭建一个内网yum服务器,但又考虑到如果yum软件的数据库文件repodata不一样,就会有问题。因此我想到的解决方法就是直接使用公网yum源的repodata。
1/usr/bin/rsync-avrsync://mirrors.ustc.edu.cn/centos/6/os/x86_64//data/yum_data/centos/6/os/x86_64/ 2/usr/bin/rsync-avrsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64//data/yum_data/centos/6/extras/x86_64/ 3/usr/bin/rsync-avrsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64//data/yum_data/centos/6/updates/x86_64/ 4/usr/bin/rsync-av--exclude=debugrsync://mirrors.ustc.edu.cn/epel/6/x86_64//data/yum_data/epel/6/x86_64/ #查看同步完成后yum源的大小: 1[root@yumyum_data]#cd..23[root@yumdata]#du-shyum_data412Gyum_data56[root@yumdata]#LANG=en7[root@yumdata]#tree-L3yum_data/8yum_data/9|--centos10|`--611||--extras12||--os13|`--updates14|--epel15|`--616|`--x86_6417`--repodata18|--401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz19|--6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz20|--77a287c136f4ff47df506229b9ba67d57273aa525f06ddf41a3fef39908d61a7-other.sqlite.bz221|--8596812757300b1d87f2682aff7d323fdeb5dd8ee28c11009e5980cb5cd4be14-primary.sqlite.bz222|--dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz23|--f8606d9f21d61a8bf405af7144e16f6d7cb1202becb78ba5fea7d0f1cd06a0b2-filelists.sqlite.bz224`--repomd.xml25269directories,7files (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |