yum的搭建

搭建本地yum仓库的步骤

1. 创建光盘目录,挂载光盘

2. 进入/etc/yum/repos.d目录下,备份所有配置文件

3. 利用一个含有大写M的配置文件作为配置文件的模板

4. 在模板里将enabled改成1,保持退出

5. 情况旧yum缓存:yum -y clean all

6. 生成新的yum缓存:yum makecache
搭建云yum仓库
搭建云仓库的步骤,
在下载云源之前先按装wget命令
就是将原来的配置文件移走,在从网上下载一个,命令wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
这个是163的源地址 http://mirrors.163.com/.help/CentOS6-Base-163.repo


定制本地化yum源
需要安装的命令createrepo
在云yum的基础上将配置文件/etc/yum.conf 里边的keepcache=0 改成 =1
然后安装命令的包会保存到/var/cache/yum/x86/6里边的各个文件下的pakeage里。
然后把里边的rpm包都拿出来,存放到另一个自己专门的目录里,在用createrepo将rpm从新生成一个索引文件,就可以用了,在自己编写一个配置文件脚本

[模板的名字]
name=模板名
baseurl=:///放的那个包的路径
gpgcheck=0
enabled=1

 yum搭建的脚本

#!/bin/bash
mkdir -p /media/cdrom
umount /dev/sr0 &>/dev/null
mount /dev/sr0 /media/cdrom &>/dev/null
dir=/etc/yum.repos.d
[ -d $dir ] || mkdir -p $dir
cd $dir
mv * /tmp/
cat >/etc/yum.repos.d/local.repo << KOF
[local]
name=localrepo
baseurl=file:///media/cdrom/
KOF
yum -y clean all &>/dev/null
[ $? -eq 0 ] || echo "clean erro"
yum makecache &>/dev/null || echo "erro cache"

which "wget"
[ $? -eq 0 ] || /usr/bin/yum -y install wget &>/dev/null
/usr/bin/wget http://mirrors.aliyun.com/repo/epel-6.repo
[ $? -eq 0 ] || (/bin/echo "yun源出错" && exit)
/usr/bin/yum -y clean all &>/dev/null
/usr/bin/yum makecache &>/dev/null
[ $? -eq 0 ] || (/bin/echo "yun缓存错误" && exit)
/usr/bin/yum -y install pcre-deved openssl-devel &>/dev/null
[ $? -eq 0 ] || /bin/echo "pcre error"
原文地址:https://www.cnblogs.com/cash-su/p/9844369.html