cobbler简介
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、yum仓库、构造系统ISO镜像。支持命令行管理,web界面管理,还提供了API接口,方便二次开发。
cobbler的核心概念
Distros(发行版):表示一个操作系统,它承载了内核和initrd的信息,以及内核参数等其他数据
Profile(配置文件):包含一个发行版、一个kickstart文件以及可能的存储库,还包含更多特定的内核参数等其他数据
Systems(系统):表示要配给的额机器。它包含一个配置文件或一个镜像,还包含IP和MAC地址、电源管理(地址、凭据、类型)、(网卡绑定、设置valn等)
安装配置cobbler
安装cobbler之前,需要首先安装cobbler依赖的一些服务:httpd、tftp、dhcp、rsync。
yum -y install httpd tftp-server rsync dhcp
yum -y install cobbler
cobbler可行管理这些服务中的部分甚至全部,但需要配置/etc/cobbler/settings文件中的“manager_dhcp”、“manage_tftpd”、“manage_rsync”、“manage_dns”来定义,同时各种服务都有着不同的实现方式,如果进行自定义,需要通过修改/etc/cobbler/modules.conf配置文件中各个服务的模块参数的值来实现。
这里先不采用cobbler管理,手动配置dhcp服务
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
配置dhcp服务,编辑配置文件/etc/dhcp/dhcpd.conf
#option domain-name"magedu.com";#option domain-name-servers172.16.253.85;subnet172.16.0.0netmask255.255.0.0{range172.16.0.1172.16.0.100;filename"pxelinux.0";next-server172.16.253.85;}
启动服务,并设置为开机自动启动
systemctl enable tftp.socket dhcpd
systemctl start xinted tftp.socket dhcpd httpd cobblerd
然后使用cobbler check检查cobbler的运行环境,第一次运行可能会存在如下错误():
cobbler check1:The'server'fieldin/etc/cobbler/settings must besetto something other than localhost,or kickstarting features will not work.Thisshould be a resolvable hostname or IPforthe boot server as reachable by all machines that will use it.2:ForPXE to be functional,the'next_server'fieldin/etc/cobbler/settings must besetto something other than127.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,ifyou 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.Filesinthis 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/rsync5:comment out'dists'on/etc/debmirror.confforproper debian support6:comment out'arches'on/etc/debmirror.confforproper debian support7:Thedefault password used by the sample templatesfornewly installed machines(default_password_cryptedin/etc/cobbler/settings)is stillsetto'cobbler'and should be changed,try:"openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"to generate new one
依次解决上述错误:
1、vim /etc/cobbler/settings
next_server: 172.16.253.85 解决第1个报错
server: 172.16.253.85 解决第2个报错
default_password_crypted:”$6$ycj3gRS8$9DjGjCg4bmZMA06UbJc.XXxoX35RR66AfCDNqHMKWUeQ1xlIicJCMCA6Uq32itdaWri2MwxF4BrnbSqy8yQ0Z0″
解决第6个报错
2、yum -y install syslinux 解决第3个报错
3、第4个报错忽略
4、安装ksvalidator
yum -y install pykickstart 解决第5个报错
5、由于无fencing设备,忽略
修改完成后重启cobbler服务
cobbler sync
systemctl restart cobblerd
定义cobbler
可以通过其指定外部的安装引导内核及ramdisk文件的方式实现。或使用已经有现成的安装树(如OS的安装镜像)import导入的方式。
挂载光盘镜像,这里以centos6.7为例
mount /dev/sr0 /data
cobbler import –name=centos6.7 –path=/data
mkdir /var/www/html/centos
ln -s /var/www/cobbler/ks_mirror/centos6.7/ /var/www/html/centos/
导入光盘镜像,导入完成后,在/var/www/cobbler/ks_mirror目录下会生成一个–name指定的名称的目录,这个目录与挂载在本地的光盘镜像目录一致
制作kickstart文件,在图形界面启动system-config-kickstart
注意:如果此处无法显示,请尝试修改/etc/yum.repo.d/xxx.repo中的yum源id为development 如:
[development]
name=added from:file:///data/baseurl=file:///data/
enabled=1
gpgcheck=0
生成ks.cfg文件如下
#platform=x86,AMD64,orIntelEM64T#version=DEVEL#InstallOS instead of upgrade
install#Keyboardlayouts
keyboard'us'#Rootpassword
rootpw--iscrypted $1$iWvg.11Q$xWlQBI.14Ss9zbdWtqV.L1#Systemtimezone
timezoneAsia/Shanghai#Usenetwork installation
url--url="http://172.16.253.85/centos"#Systemlanguage
lang en_US#Firewallconfiguration
firewall--disabled#Systemauthorization information
auth--useshadow--passalgo=sha512#Usegraphical install
graphical
firstboot--disable#SELinuxconfiguration
selinux--disabled#Rebootafter installation
reboot#Systembootloader configuration
bootloader--location=mbr#Partitionclearing information
clearpart--all#Diskpartitioning information
part/boot--fstype="ext4"--size=200part/--fstype="ext4"--size=10240part swap--fstype="swap"--size=1024%packages@base%end
检查ks文件语法,kickstart文件默认放在/var/lib/cobbler/kickstarts/目录下
ksvalidator /var/lib/cobbler/kickstarts/ks.cfg
[root@magedu~]#cobbler distro list
centos6.7-x86_64
指定kickstart文件
cobbler profile add--name=centos6.7--distro=centos6.7-x86_64--kickstart=/var/lib/cobbler/kickstarts/ks.cfg
[root@magedu~]#cobbler sync
task started:2016-08-11_125253_sync
task started(id=Sync,time=ThuAug1112:52:532016)..........running python triggers from/var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
测试自动安装
安装过程基本无须手动干预,安装过程不再赘述,检查系统及配置
cobbler服务器验证
安装完毕
网友评论