利用cobbler无人值守批量安装centos

准备:

至少两台机器,分别用作cobbler的服务端和安装测试端

准备一个iso的安装文件,最好是4G多的那个dvd包,以前用网易源上那个centos 6.4 x86_64 通过xen安装时就报错:No option 'kernel' in section: 'images-xen',后来换成4G的dvd1就好了。

1、安装cobbler,见安装批量装机工具cobbler过程,本文中使用的版本为2.2.2

2、安装httpd dhcp tftp-server

3、检查cobbler配置情况

cobbler check

根据提示解决大部分问题即可,把 /etc/cobbler/settings 中的 server 和 next_server 设为本服务器的 IP 地址,manage_dhcp 设为 1,以便管理 DHCP;

以下两条可不修改,不影响安装

1) debmirror package is not installed, it will be required to manage debian deployments and repositories 
2) 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

修改allow_dynamic_settings的值为1,这样后面可以用cobbler setting edit --name=option --value=xxx命令来动态修改cobbler配置

修改该配置后重启cobbler服务,然后执行cobbler sync

根据cobbler提供的dhcpd模板配置dhcpd的配置文件:

1)cp /etc/cobbler/dhcp.template /etc/dhcpd.conf

next-server                192.168.1.151; #此值改为你自己运行cobbler server的机器的ip

range dynamic-bootp   192.168.1.10 192.168.1.254; #改成要安装的机器所在的网段,这个不知道是不是必须改,没仔细研究,反正我改了

2) group 部分暂时没搞清啥用 直接删去,否则配置不好会无法启动dhcp服务

note:dhcpd 启动失败时可通过/var/log/massages 查看

修改tftp配置,vi /etc/xinetd/tftp

service tftp
{
disable = no #只需把yes改为no即可,其它默认
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -B 1380 -v -s /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}

备注:cobbler check 的结果中有几项涉及到iptables和selinux的设置的,可以按照提示修改,也可以简单的将iptables和selinux停掉

4、搞一个centos的dvd镜像,如CentOS-6.4-x86_64-bin-DVD1.iso,执行以下命令

mount -t auto -o loop /xxx/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/dvd

cobbler import --name=centos6.4 --path=/mnt/dvd 注意这里一定要指定--name 否则客户机启动时安装菜单中没有对应iso文件的选项

5、至此已完成了安装和配置,保证httpd tftp dhcpd xinetd 对应服务都已启动,执行命令

cobbler sync

6、重启cobbler服务,这一步不知是不是必须 重启几下也无妨

7、把需要安装系统的机器的bios设置为优先通过网络启动,然后重启机器,会看到一个启动界面,第一项默认是local,也就是说20秒如果不选择其它安装选项系统将正常启动,所以不用担心正常机器会受到影响。

之后系统会全自动安装完成,无需人工干预。

说明:

kickstart模板文件在/var/lib/cobbler/kickstarts下面。

这里有篇相关文章,介绍的更详细:http://www.chenshake.com/centos6-4-installation-and-configuration-cobbler-2-4/

原文地址:https://www.cnblogs.com/argb/p/3440824.html