Cobbler部署yum仓库配置 (2013-04-11 10:54:03)转载▼

标签: cobbler kickstart 批量安装系统 自动安装系统 it 分类: Linux

yum仓库配置管理


6.1 首先导入系统镜像


参考:http://blog.sina.com.cn/s/blog_61c07ac50101d079.html

导入完毕后,进行下面的步骤

6.2 添加镜像


base、updates库使用163的repo源并增加EPEL库

base

cobbler repo add --name=centos5.8-x86_64-Base --mirror=http://mirrors.163.com/centos/5/os/x86_64/

将定义的仓库大写名字Base修改为小写base

cobbler repo edit --name=centos5.8-x86_64-base --mirror=http://mirrors.163.com/centos/5/os/x86_64/ --arch=x86_64 --breed=yum

updates

cobbler repo add --name=centos5.8-x86_64-updates --mirror=http://mirrors.163.com/centos/5/updates/x86_64/ --arch=x86_64 --breed=yum

添加EPEL仓库

cobbler repo add --name=centos5.8-x86_64-epel --mirror=http://mirrors.ustc.edu.cn/epel/5/x86_64/ --arch=x86_64 --breed=yum

6.3 同步yum仓库内容到本地


时间较长,注意磁盘容量是否满足。

cobbler reposync

task started: 2013-03-26_111553_reposync

task started (id=Reposync, time=Tue Mar 26 11:15:53 2013)

hello, reposync

run, reposync, run!

creating: /var/www/cobbler/repo_mirror/centos5.8-x86_64-updates/.origin/centos5.8-x86_64-updates.repo

running: /usr/bin/reposync -l -m -d --config=/var/www/cobbler/repo_mirror/centos5.8-x86_64-updates/.origin/centos5.8-x86_64-updates.repo --repoid=centos5.8-x86_64-updates --download_path=/var/www/cobbler/repo_mirror -a x86_64

………………略…………………………

received on stdout:

received on stderr:

*** TASK COMPLETE ***

6.4 repo添加到profle,


安装系统时会自动添加仓库配置

cobbler profile edit --name=centos5.8-x86_64 --repos="centos5.8-x86_64-base centos5.8-x86_64-epel centos5.8-x86_64-updates" --distro=centos5.8-x86_64  --kickstart=/var/lib/cobbler/kickstarts/centos5u8-x64.cfg

6.4 删除仓库配置


cobbler repo remove  --name=centos5.8-x86_64- updates

6.5 添加更新仓库源计划任务


cobbler reposync --tries=3 --no-fail

 

加入crontab 每周日更新一次即可

echo  "0 2  * *  0 cobbler reposync --tries=3 --no-fail" >> /var/spool/cron/root

 

注意检查crond是否启动

/etc/init.d/crond status

crond is stopped

/etc/init.d/crond start

Starting crond:                                            [  OK  ]

chkconfig crond on  

6.6 装机自动配置yum


如果你想安装系统时自动配置yum,请进行以下配置。

vim /etc/cobbler/settings

yum_post_install_mirror: 1

在装机脚本ks文件加入以下内容

%post

# Start yum configuration

$yum_config_stanza

# End yum configuration

 

下面的参数PXE安装系统是会引用你添加的cobbler repo配置

注意可能将系统、应用部署到较新版本,根据情况而配置

$yum_repo_stanza

这两个参数都来自Kickstart snippets,很值得研究https://github.com/cobbler/cobbler/wiki/Kickstart-snippets

 

系统安装自动配置的yum

cat /etc/yum.repos.d/cobbler-config.repo  

[core-0]

name=core-0

baseurl=http://172.17.10.14/cobbler/ks_mirror/centos5.8-x86_64

enabled=1

gpgcheck=0

priority=1

 

 

[centos5.8-x86_64-base]

name=centos5.8-x86_64-base

baseurl=http://172.17.10.14/cobbler/repo_mirror/centos5.8-x86_64-base

enabled=1

priority=99

gpgcheck=0

 

 

[centos5.8-x86_64-epel]

name=centos5.8-x86_64-epel

baseurl=http://172.17.10.14/cobbler/repo_mirror/centos5.8-x86_64-epel

enabled=1

priority=99

gpgcheck=0

 

 

[centos5.8-x86_64-updates]

name=centos5.8-x86_64-updates

baseurl=http://172.17.10.14/cobbler/repo_mirror/centos5.8-x86_64-updates

enabled=1

priority=99

gpgcheck=0