在生产环境中难免会遇到,一些服务器需要安装centos,一些服务器需要安装ubuntu,或者一些系统需要安装centos6.4一些系统需要安装centos6.5,这时PXE就满足不了我们的要求。本文将介绍cobbler来实现此功能。
Cobbler必选的服务:
u TFTP
u Rsync
u DHCP
u DNS(根据需求)
Cobbler 命令:
u Import
u Sync
u Reposync
u Build ISO
核心概念:
Distros:定义启动内核、initrd文件等
Profiles:指定kickstart 指定level
Cobbler:
前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可进行类似下面的安装过程。
注意关闭selinux
wget http://mirrors.opencas.cn/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum clean all
# yum install cobbler cobbler-web pykickstart debmirror -y
# service httpd start
# service cobblerd start
# cobbler check
执行“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 : 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.
4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync
5 : comment ‘dists‘ on /etc/debmirror.conf for proper debian support
6 : comment ‘arches‘ on /etc/debmirror.conf for proper debian support
7 : 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
8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
Restart cobblerd and then run ‘cobbler sync‘ to apply changes.
如上各问题的解决方法如下所示:
1、修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如172.16.100.15;
2、修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如172.16.100.16;
3、如果当前节点可以访问互联网,执行“cobbler get-loaders”命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
4、执行“chkconfig rsync on”命令即可;
5、注释/etc/debmirror.conf文件中的“@dists="sid";”一行;
6、注释/etc/debmirror.conf文件中的“@arches="i386";”一行;
7、执行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings文件中default_password_crypted参数的值;
8、执行“yum install cman fence-agents”命令安装相应的程序包即可;
接着重启cobblerd,而后执行“cobbler sync”同步新的配置至cobbler。
二、安装DHCP
yum install dhcp -y
vim /etc/dhcp/dhcpd.conf
option domain-name "magedu.com";
option domain-name-servers 192.168.10.254,172.16.0.1;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.21 192.168.10.100;
option routers 192.168.10.254;
}
next-server 192.168.10.254;
filename="pxelinux.0";
service dhcpd start
service xinetd restart
cobbler sync
导入镜像文件:
插入光盘
挂载 [root@localhost ~]# mount /dev/cdrom /misc/cd
cobbler import --name="rhel-6.5-x86_64" --path=/misc/cd
cobbler distro list 查看
配置Kickstart
yum install system-config-kickstart -y
system-config-kickstart
kickstart配置参照网上其他例子,这里不做介绍
vim defcault.cfg
url --url="http://192.168.100.1/cobbler/ks_mirror/rhel-5.4-x86"
cp /root/rhel-x86.cfg /var/lib/cobbler/kickstarts
cobbler profile add --name=rhel-5.4-i386-basic --distro=rhel-5.4-i386 --kickstart=/var/lib/cobbler/kickstarts/rhel-x86.cfg
拷贝ks.cfg文件
cp /var/lib/cobbler/kickstarts/ks.cfg /var/www/html/cobbler/ks.cfg
编辑并修改
vim /var/lib/tftpboot/pxelinux.cfg/default
ks=http://192.168.19.42/cobbler/ks.cfg
重启服务
service cobblerd restart
Cobbler list 查看
开启虚拟机测试!!!
cobbler自动化部署多种类型的操作系统,一个软件全部搞定
原文地址:http://xinzong.blog.51cto.com/10018904/1694856