标签:
# 1、创建epel存放目录
mkdir /var/www/html/epel/6Server/x86_64 -p
# 2、安装apache
yum install httpd
/etc/init.d/httpd start
# 3、创建同步脚本
mkdir /server/scripts
cat > /server/scripts/yum_rsync.sh << EOF
/usr/bin/rsync -avrt rsync://mirrors.ustc.edu.cn/epel/6Server/x86_64/ /var/www/html/epel/6Server/x86_64
EOF
# 4、创建计划任务,每天同步epel源
cat >> /var/spool/cron/root << EOF
# 20150707 by test
0 1 * * * root /server/scripts/yum_rsync.sh
EOF
# 5、指向yum源
cat >> /etc/yum.repos.d/CentOS-Base.repo << EOF
[test-epel]
name=CentOS-\$releasever-epel
baseurl=http://172.16.0.114/epel/6Server/\$basearch
#baseurl=http://172.16.0.114/epel/6Server/x86_64/
enabled=1
gpgcheck=0
EOF
# 6、测试
[root@yum ~]# yum repolist
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
test-epel | 4.4 kB 00:00
updates | 3.4 kB 00:00
repo id repo name status
base CentOS-6 - Base - mirrors.aliyun.com 6,518
extras CentOS-6 - Extras - mirrors.aliyun.com 38
test-epel CentOS-6-epel 11,653
updates CentOS-6 - Updates - mirrors.aliyun.com 1,307
repolist: 19,516
# 1、创建yum源的目录
mkdir /tmp/CentOS6.6 /media/cdrom
# 2、将centos光盘
mount -r /dev/cdrom /media/cdrom
# 3、拷贝文件到可以写的位置
cp /media/cdrom/Packages/* /tmp/CentOS6.6/
# 4、创建yum仓库
yum -y install createrepo
cd /tmp
createrepo /tmp/CentOS6.6/
createrepo -g /tmp/CentOS6.6/
# 5、生成相应的文件
[root@localhost repodata]# ls /tmp/CentOS6.6/repodata
2492566dbeda19963c5a8a638185aa1e858aa6dea5f145b7090a7816fa63162e-filelists.sqlite.bz2
280947c3ee9847a2312ddb02e6b91ecacbbc29bde81d4c094e2e9f25e210ead7-primary.sqlite.bz2
73d30f44b66092492893e3ce0bbf8c20ffd625b7eca70b04c6776e216e1149a4-filelists.xml.gz
858abeedbb1e06aacfff0cd8d90f7948fdcd232f82e1dfb3c4f308cb7d79b314-other.xml.gz
970f7ec74fbca72ff525949a31dcfae8fd98a5ed27674b978e441593b2dddf5d-other.sqlite.bz2
aa9011cf9321a5b1eab983fba6612218dab558a2618a1ad5a5a0d0f6f0026446-primary.xml.gz
repomd.xml
# 6、对默认的YUM仓库改名,创建自己的地址
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# 7、创建自己的yum源
cat > /etc/yum.repos.d/cat my.repo << EOF
[myrepo]
name=myrepo
baseurl=file:///tmp/CentOS6.6
gpgcheck=0
EOF
# 8、创建成功
[root@localhost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
myrepo | 2.9 kB 00:00 ...
myrepo/primary_db | 3.4 MB 00:00 ...
repo id repo name status
myrepo myrepo 4,184
repolist: 4,184
标签:
原文地址:http://www.cnblogs.com/kwstars/p/4628454.html