Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
kickstart是由dhcp、tftp、http这三种服务有机组成,为有pxe功能的客户端提供自动装机服务。kickstart只是这套系统的名字,并没有这个独立的软件。
cobbler是对kickstart进行二次开发,安装cobbler的过程中,其实已经悄悄地安装了和kickstart一样的服务,因此在工作中安装cobbler直接一条yum命令即可,不需要先把kickstart服务安装配置好。
环境
Linux CentOS6 2.6.32-642.el6.x86_64
cobbler-2.6.11-1.el6.x86_64
cobbler-web-2.6.11-1.el6.noarch
dhcp-4.1.1-51.P1.el6.centos.x86_64
tftp-server-0.49-8.el6.x86_64
pykickstart-1.74.20-1.el6.noarch
httpd-2.2.15-56.el6.centos.3.x86_64
系统环境准备
[root@CentOS6 ~]# getenforce Disabled [root@CentOS6 ~]# /etc/init.d/iptables status iptables: Firewall is not running. [root@CentOS6 ~]# cat /etc/redhat-release CentOS release 6.8 (Final) [root@CentOS6 ~]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
注意:虚拟机VMware模式的DHCP服务关闭,同一台机器上面不允许两个DHCP服务
Cobbler安装配置
[root@CentOS6 ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd [root@CentOS6 ~]# /etc/init.d/httpd restart [root@CentOS6 ~]# /etc/init.d/cobblerd restart [root@CentOS6 ~]# /etc/init.d/xinetd restart
[root@CentOS6 ~]# rpm -ql cobbler
/etc/cobbler # 配置文件目录
/etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
/etc/cobbler/dhcp.template # DHCP服务的配置模板
/etc/cobbler/tftpd.template # tftp服务的配置模板
/etc/cobbler/rsync.template # rsync服务的配置模板
/etc/cobbler/iso # iso模板配置文件目录
/etc/cobbler/pxe # pxe模板文件目录
/etc/cobbler/power # 电源的配置文件目录
/etc/cobbler/users.conf # Web服务授权配置文件
/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template # DNS服务的配置模板
/etc/cobbler/modules.conf # Cobbler模块配置文件
/var/lib/cobbler # Cobbler数据目录
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默认存放kickstart文件
/var/lib/cobbler/loaders # 存放的各种引导程序
/var/www/cobbler # 系统安装镜像目录
/var/www/cobbler/ks_mirror # 导入的系统镜像列表
/var/www/cobbler/images # 导入的系统镜像启动文件
/var/www/cobbler/repo_mirror # yum源存储目录
/var/log/cobbl # 日志目录
/var/log/cobbler/install.log # 客户端系统安装日志
/var/log/cobbler/cobbler.log # cobbler日志
配置Cobbler
[root@CentOS6 ~]# cobbler check
The following are potential configuration items that you may want to fix:
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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download th
em, 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/rsync
6 : file /etc/xinetd.d/rsync does not exist # 这是一个bug
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobb
ler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one9 : 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.
[root@CentOS6 ~]cp /etc/cobbler/settings{,.ori} ##备份 1.[root@CentOS6 ~]# sed -i 's#server: 127.0.0.1#server: 172.16.1.101#' /etc/cobbler/settings ###指定cobbler服务器地址 2.[root@CentOS6 ~]#sed -i 's#yes#no#' /etc/xinetd.d/rsync 3.[root@CentOS6 ~]# sed 's#manage_dhcp: 0#manage_dhcp: 1#' /etc/cobbler/settings ##用Cobbler管理DHCP 4.[root@CentOS6 ~]# sed -n 's/pxe_just_once: 0/ pxe_just_once: 1/' /etc/cobbler/settings ##防止循环装系统,适用于服务器第一启动项是PXE启动。务 5.[root@CentOS6 ~]# sed -i 's#yes#no#' /etc/xinetd.d/tftp 6.[root@CentOS6 ~]# sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'oldboy' '123456'`\"#" /etc/cobbler/settings 7.[root@CentOS6 ~]# sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.101/' /etc/cobbler/settings
问题4解决方法
####http://pan.baidu.com/s/1kVqhMT5###需要从官网下载,我这里已经下载好了。
tar xfP cobbler_load.tar.gz
配置DHCP
[root@CentOS6 ~] vim /etc/cobbler/dhcp.template
:%s/192.168.1/172.16.1/g
镜像挂载
这里我用的是虚拟机VMware,需要把你的镜像文件挂载一下。
创建挂载目录
[root@CentOS6 ~]# mount /dev/cdrom /mnt
Kickstart创建
# Cobbler for Kickstart Configurator for CentOS 6.8 by yao zhang
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end
%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end
%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('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end
使用浏览器访问主页,进一步进行cobber网页配置
点击“import DVD”--》“DVD importer”,这里需要注明路径必须填写,然后单击“run”把镜像文件上传到服务器上面,这里上传的方式使用rsync上传,rsync服务是批量增加的。
点击“events”查看日志。
刚刚上传镜像目录
创建yum源文件,yum源可以使用本地yum源也可以使用外网yum源。
创建完yum源以后需要“reposync”进行同步一下,方可以生效
自定义系统文件