烹茶细论

Centos和Ubuntu搭建本地私有源

Centos

1、同步数据

1
rsync -avzLP --exclude '5' --exclude 'isos' --exclude 'SCL' --exclude 'xen4' --exclude 'fasttrack' --exclude 'cr' --exclude 'i386' rsync://mirrors.kernel.org/centos /data/ZdSvrFtp/Soft/mirrors/centos/

将这个写入crontab定时任务里面

1
2
# crontab -e
0 2 * * * bash rsync -avzLP --exclude '*.iso' --exclude '5' --exclude 'isos' --exclude 'SCL' --exclude 'xen4' --exclude 'fasttrack' --exclude 'cr' --exclude 'i386' rsync://mirrors.kernel.org/centos /data/ZdSvrFtp/Soft/mirrors/centos/

2、配置http或者ftp,具体配置就不说了

3、使用私有源
备份/etc/yum.repos.d/CentOS-Base.repo
修改/etc/yum.repos.d/CentOS-Base.repo为下面内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[base]
name=CentOS-6.5 - Base - zdworks_mirrors
baseurl=ftp://192.168.1.19/Soft/mirrors/centos/6.5/os/$basearch/
gpgcheck=1
gpgkey=ftp://192.168.1.19/Soft/mirrors/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6.5 - Updates - zdworks_mirrors
baseurl=ftp://192.168.1.19/Soft/mirrors/centos/6.5/updates/$basearch/
gpgcheck=1
gpgkey=ftp://192.168.1.19/Soft/mirrors/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6.5 - Extras - zdworks_mirrors
baseurl=ftp://192.168.1.19/Soft/mirrors/centos/6.5/extras/$basearch/
gpgcheck=1
gpgkey=ftp://192.168.1.19/Soft/mirrors/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.5 - Plus - zdworks_mirrors
baseurl=ftp://192.168.1.19/Soft/mirrors/centos/6.5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=ftp://192.168.1.19/Soft/mirrors/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.5 - Contrib - zdworks_mirrors
baseurl=ftp://192.168.1.19/Soft/mirrors/centos/6.5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=ftp://192.168.1.19/Soft/mirrors/centos/RPM-GPG-KEY-CentOS-6

4、yum makecache然后就可以使用了

ubuntu

1、同步

1
rsync -avzLP --exclude *.iso --exclude images rsync://mirrors.kernel.org/ubuntu/ /data/ZdSvrFtp/Soft/mirrors/ubuntu/

2、使用私有源
备份/etc/apt/sources.list
修改/etc/apt/sources.list为下面内容

1
2
3
4
5
6
7
8
deb ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise main restricted
deb-src ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise main restricted
deb ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise universe
deb-src ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise universe
deb ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise multiverse
deb-src ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise multiverse
deb ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise main
deb-src ftp://192.168.1.19/Soft/mirrors/ubuntu/ precise main