wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm
2、服务安装
yum -y install cobbler httpd rsync tftp xinetd dhcp cman pykickstart
3、修改cobbler配置文件 /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings#开启dhcp功能
sed -i 's/manage_rsync: 0/manage_rsync: 1/' /etc/cobbler/settings #开启rsync功能
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.100/' /etc/cobbler/settings #设置你的 tftp server 地址
sed -i 's/server: 127.0.0.1/server: 192.168.1.100/' /etc/cobbler/settings
#cobbler_server 地址
4、开启cobbler服务前需要做
service iptables stop #关闭防火墙
setenforce 0 #关闭selinux
/etc/xinetd.d/tftp
disable = no #开启tftp服务
/etc/xinetd.d/rsync
disable = no #开启 rsync 服务
openssl passwd -1 -salt 'cocosoa' '00001234' 生成系统安装后的 root 密码,cocosoa是干扰密码,00001234是系统登录密码
vim /etc/cobbler/settings 编辑配置文件,将默认的密码替换为新生成的
default_password_crypted: "$1$cocosoa$oAeSzE7VLKwhMPiBEOJD81"
cobbler get-loaders#下载引导 *** 作系统文件
yum install debmirror -y
vim /etc/debmirror.conf
#@dists="sid" // 注销
#@arches="i386" // 注销
配置dhcp服务,只需要修改cobbler的dhcp模板文件即可
vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.5
option domain-name-servers 192.168.1.1
option subnet-mask 255.255.255.0
range dynamic-bootp192.168.1.100 192.168.1.254
default-lease-time 21600
max-lease-time 43200
next-server192.168.1.122
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi"
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi"
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi"
} else {
filename "pxelinux.0"
}
}
}
注意修改之后,使用cobbler sync 同步下配置文件,不然dhcp无法启动,会报错
5、启动服务
service httpd start 在配置文件中加入ServerName localhost:80
service cobbler start
chkconfig httpd on
chkconfig cobblerd on
chkconfig dhcpd on
chkconfig xinetd on
chkconfig tftp on
chkconfig iptables off
6、导入镜像
cobbler import --path=/media --name=CentOS6.4 --arch=x86_64
touch /var/lib/cobbler/kickstarts/CentOS6.4.ks
cobbler profile add --name=centos6.4 --distro=CentOS6.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS6.4.ks
添加一个profile文件,并使用CentOS6.4-x86_64这个distro,并指定相应的ks文件,ks文件是事先准备好的
vim /etc/cobbler/pxe/pxedefault.template#编辑pxe模板
ONTIMEOUT centos6.4 #修改默认安装的profile为centos6.4,也就是说当你没有选择,超时 *** 作后自动安装此profile
7、编辑kickstarts文件 #可以自己写
vim /var/lib/cobbler/kickstarts/CentOS6.4.ks
install
auth --useshadow --enablemd5
key --skip
bootloader --location=mbr
clearpart --all --initlabel
text
firewall --disabled
keyboard us
lang en_US
url --url=$tree
reboot
rootpw --iscrypted $1$cocosoa$oAeSzE7VLKwhMPiBEOJD81
selinux --disabled
timezone --isUtc Asia/Shanghai
zerombr
autopart
%packages
$SNIPPET('package')
cat /var/lib/cobbler/snippets/package
此文件里写入需要安装的包
下面是扩展目录,可以自己添加单独的配置文件,方便管理
/var/lib/cobbler/snippets
$SNIPPET (文件名) 该文件要到/var/lib/cobbler/snippets下创建编辑。
# System authorization information
auth --useshadow --enablemd #用户登录认证
# System bootloader configuration
bootloader --location=mbr #mbr引导
# Partition clearing information
clearpart --all --initlabel #默认清除所以分区
# Use text mode install
text #默认以文本模式安装
# Firewall configuration
firewall --enabled #防火墙默认开启
# Run the Setup Agent on first boot
firstboot --disable #禁用启动代理
# System keyboard
keyboard us #默认英文键盘
# System language
lang en_US #默认语言英文
# Use network installation
url --url=$tree #网络安装路径
# If any cobbler repo definitions were referenced in the kickstart profile, include them here
$yum_repo_stanza #默认的yum仓库
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot #安装完成后重启
#Root password
rootpw --iscrypted $default_password_crypted #密码是我们/etc/cobbler/settings设置密码
# SELinux configuration
selinux --disabled #默认关闭selinux
# Do not configure the X Window System
skipx #默认没有安装图形界面
# System timezone
timezone America/New_York #默认时区是美国/纽约
# Install OS instead of upgrade
install #定义的是安装系统而不是升级系统
# Clear the Master Boot Record
zerombr #默认清空所有的mbr
# Allow anaconda to partition the system as needed
autopart #默认自动分区
在一台装有 Fedora 9 的服务器上进行了测试,步骤如下:1. 安装相关软件:
yum -y install cobbler tftp-server dhcp httpd xinetd
注意 /var/www/cobbler 目录必须具有足够容纳 Linux 安装文件的空间(移动,建软链接)
2. 检查 cobbler 配置:
cobbler check
按提示解决相关问题,把 /etc/cobbler/settings 中的 server 和 next_server 设为本服务器的 IP 地址,manage_dhcp 设为 1,以便管理 DHCP
3. 导入 Fedora 9 安装 DVD ISO 中的文件:
mount -o loop Fedora9/x86_64/Fedora-9-x86_64-DVD.iso /mnt/dvd/ # 将ISO文件挂载到 /mnt/dvd 目录
cobbler import --mirror=/mnt/dvd --name=FC9-x86-64 # 从 /mnt/dvd 目录导入所有安装文件,命名为 FC9-x86-64
cobbler distro list # 查看导入结果,应显示 FC9-64-i386 和 FC9-64-xen-i386
4. 修改 DHCP 和 Kickstart 配置模板:
vi /etc/cobbler/dhcp.template # DHCP 配置模板,如果已经有一个 dhcpd.conf,可参照修改此模板
vi /etc/cobbler/sample.ks # Kickstart 配置模板
5. 生成并同步所有配置:
cobbler sync
6. 启动相关服务:
service xinetd start # /etc/xinetd.d/tftp 中 disable = no
service dhcpd start
service cobblerd start
曹植七步成诗,而 Cobbler 居然只需要六步。启动另一台新服务器,通过 PXE 启动进入蓝色的 Cobbler 安装界面,选择 Fedora 9 安装项,几分钟之内就能一气呵成,自动完成系统安装。
我也遇到这个问题了,不知道怎么解决:File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 87, in run
rc = self._run(self)
File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 231, in runner
self.logger
File "/usr/lib/python2.6/site-packages/cobbler/api.py", line 892, in import_tree
utils.run_this(rsync_cmd, (spacer, mirror_url, path), self.logger)
File "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 917, in run_this
die(logger,"Command failed")
File "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 134, in die
raise CX(msg)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)