操作系统环境 : CentOS 5.5 i386
软件环境 : cobbler-2.0.11-2.el5
centos要安装cobbler 需要安装一个软件包 epel
偶这里把用到的几个文件上传到网盘了 方便自己和朋友们下载 http://www.uudisc.com/user/txwsqk/files/4193306
(里面包含一个epel,一个kickstart配置文件,还有cobbler get-loaders下载的哪些文件)
下面开始具体的步骤了:
先配置源
找不到好源的看这里 http://mirrors.163.com/.help/
centos的系统
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
#别忘了rpm -ivh epel-release-5-4.noarch.rpm
yum makecache
开始安装软件
yum install cobbler dhcp cman debmirror
修改配置文件
vi /etc/cobbler/dhcp.template
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.100;
# option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.0.110 192.168.0.200;
注: 不要修改/etc/dhcpd.conf 这个文件,过会我们会配置让cobbler接管启动dhcpd的任务,cobbler会把你修改的dhcp.template拷贝到/etc/dhcpd.conf
vi /etc/cobbler/settings (只写出需要修改的地方)
default_password_crypted: "$1$icifbsa$GlSk4KZPpIscQsOpLkZh0/" #过会你运行 cobbler check时 会提示你修改密码 ,这个密码就是你安装系统后的root密码,我在这里先说明而已. 用这个命令实现 "openssl passwd -1 -salt '任意字母' '你的密码' "
manage_dhcp: 1
next_server: 192.168.0.100
server: 192.168.0.100
vi /etc/debmirror.conf (只写出需要修改的地方)
#@dists="sid";
#@arches="i386"; #这两个地方注释掉即可,不然过会 cobbler check 会报错
过会cobbler check 时 还会要求你执行一个命令
cobbler get-loaders
这是下载引导操作系统的必须文件,我在上面的网盘已经提供了 loaders.tar.gz,解压到 /var/lib/cobbler/loaders/,当然你也可以运行上面的命令下载
再修改2个文件
/etc/xinetd.d/tftp
/etc/xinetd.d/rsync
把这2个文件里面的
disable = no
捎带提一句 别忘了关闭防火墙和SELINUX (有时这2个东西很误事 :)
这时候我们启动 httpd (如果不启动httpd , cobbler check 是没法执行滴)
有可能的报错信息如下
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : you need to set some SELinux content rules to ensure cobbler works correctly in your SELinux environment, run the following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*" && \ /usr/sbin/semanage fcontext -a -t public_content_t "/var/www/cobbler/images/.*"
4 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : change 'disable' to 'no' in /etc/xinetd.d/tftp
6 : change 'disable' to 'no' in /etc/xinetd.d/rsync
7 : since iptables may be running, ensure 69, 80, and 25151 are unblocked
8 : debmirror package is not installed, it will be required to manage debian deployments and repositories
9 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
文章有点倒叙了 哈哈 根据报错信息和偶上面修改的地方改改, 改完后执行 cobbler check
[[email protected] loaders]# cobbler check
cobblerd does not appear to be running/accessible
好了 没有报错信息了,cobbler 配置好了。
开始导入操作系统的ISO镜像文件
#先mount iso文件
mount -o loop /path/centos-5.5-i386.iso /mnt
#导入 . --name=名字任意,--path=刚才你mount的路径
cobbler import --path=/mnt --name=centos-5.5-i386
同步所有配置
cobbler sync
启动所有服务
/etc/init.d/xinetd restart
/etc/init.d/httpd restart
/etc/init.d/cobblerd restart
ps: cobbler sync时会自动启动dhcpd的服务。
偶修改完配置时,都是执行 cobbler sync , /etc/init.d/cobblerd restart 这两个命令(为了保险)^_^
重要:用cobbler安装操作系统时,cobbler真正执行的kickstart文件其实不是 /var/lib/cobbler/kickstarts/default.ks,而是 /var/lib/cobbler/kickstarts/sample.ks
学习cobbler配置,最好把kickstart的配置文件也搞懂,默认sample.ks文件会清空硬盘所有分区资料。
下面贴出偶的 sample.ks
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
#clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --enable
# System keyboard
keyboard us
# System language
lang en_US.UTF-8
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot
#Root password
#rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
#zerombr
# Allow anaconda to partition the system as needed
#autopart
%pre
$SNIPPET('log_ks_pre')
$kickstart_start
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%packages
#$SNIPPET('func_install_if_enabled')
#$SNIPPET('puppet_install_if_enabled')
@base
@core
@development-libs
@development-tools
@editors
@text-internet
keyutils
trousers
fipscheck
device-mapper-multipath
imake
lrzsz
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('puppet_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$kickstart_done
# End final steps
这是属于cobbler调用的特殊ks文件,想看真正配置好吧,方法是打开浏览器
http://192.168.0.100/cblr/svc/op/ks/profile/CentOS-5.5-i386
# 192.168.0.100不用解释了吧
#后面的 CentOS-5.5-i386 就是你 cobbler import时指定的 --name
偶是用虚拟机完成此次实验的,本来是在fedora15下用的virtualbox,但是那个网络环境真难搞,一直也不能让另一个虚拟机获得到cobbler所在虚拟机的dhcp分配的ip,无奈回到windows用
vmware,使用hostonly模式轻松搞定。这里再捎带提以下修改vmware bios启动的方法,因为vmware启动界面一闪而过,想按F2进入bios灰常难,方法就是修改虚拟机的开机等待时间
进入到你虚拟机的目录,不是软件安装目录,是你保存虚拟机的目录,里面有个vmx文件,添加一行
bios.bootdelay=5000
让开机画面停留5000毫秒。
大功告成 !