首页 > 代码库 > cobbler自动化安装详解

cobbler自动化安装详解

Cobbler介绍

   cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.改工具使用python开发,小巧轻便,使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。

   Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。

1、安装Cobbler

需要EPEL的YUM源,否则就需要下载源码安装

[root@test ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.0eoNVV: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]

2、yum安装Cobbler组件                                                                     

yum install cobbler colbbler-web pykickstart debmirror

安装后cobbler的配置文件

[root@test cobbler]# ls
auth.conf         completions       named.template  tftpd.template
cheetah_macros    dhcp.template     power           users.conf
cobbler_bash      dnsmasq.template  pxe             users.digest
cobbler.conf      iso               reporting       version
cobblerd_rotate   ldap              rsync.exclude   zone.template
cobblerd.service  modules.conf      rsync.template  zone_templates
cobbler_web.conf  mongodb.conf      settings

3、启动cobbler服务

service cobblerd start
监听端口:
ss -tanulp
LISTEN     0      5                 127.0.0.1:25151                    *:*

4、检查cobbler的配置

首先要启动httpd服务
service httpd start
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 : 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 : debmirror package is not installed, it will be required to manage debian deployments and repositories
6 : 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
7 : 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必须要与外部指令交互的地址。 

2:PXE的服务必须要启动,/etc/cobbler/settings必须要指定web主机通信的地址。

3:pxe和cobbler等所需要的驱动文件。需要安装syslinux等插件

4:需要启动rsync服务

5:debmirror安装包还没有安装。如果不是安装debin系统可以忽略

6:需要定义密码

7:电源管理,需要安装cman,可以忽略

解决错误

1-2修改 vim /etc/cobbler/settings
next_service 192.168.254.2
service  192.168.254.2
3 cobbler get-loaders
4 vim /etc/xinetd.d/rsync   将disable改为no 重启xinetd服务
6 生成随机密码
[root@test tftpboot]# openssl passwd -1 -salt `openssl rand -hex 4`
Password: 
$1$df831563$APGIddt4A3ggUkCWnVDYu1
7 yum -y install cman fenc-agents 可以不用安装

最后重启服务,同步数据

[root@test cobbler]# service cobblerd restart 
Stopping cobbler daemon: [  OK  ]
Starting cobbler daemon: [  OK  ]
cobbler check
cobbler sync

5、启动dhcp服务

service dhcpd start

DHCP的配置在此文中不描述

6、启动tftp服务


二、导入安装光盘镜像文件

先用光盘去加载安装镜像

mount -r /dev/cdrom /var/ftp/pub/centos-6.4-x86_64
cobbler import --name="centos-6.4-x86_64" --path=/var/ftp/pub/centos-6.4-x86_64/
加载后可以查看distro
[root@test ~]# cobbler distro list
   centos-6.4-x86_64

制作一份kickstart.cfg文件。此文不再描述

创建一份profile,profile中需用到profile name distro(加载过的镜像文件) kickstart的文件路径
 cobbler profile add --name=centos-6.4-x86_64-basic --distro=centos-6.4-x86_64 --kickstart=/root/centos6.cfg
[root@test ~]# cobbler list
distros:
   centos-6.4-x86_64

profiles:
   centos-6.4-x86_64           自动生成的profile可以删除
   centos-6.4-x86_64-basic
[root@test ~]# cobbler sync
task started: 2014-12-11_164024_sync
task started (id=Sync, time=Thu Dec 11 16:40:24 2014)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos-6.4-x86_64
removing: /tftpboot/pxelinux.cfg/default
removing: /tftpboot/grub/efidefault
removing: /tftpboot/grub/images
removing: /tftpboot/images/centos-6.4-x86_64
removing: /tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /tftpboot/yaboot
copying: /var/lib/cobbler/loaders/yaboot -> /tftpboot/yaboot
copying distros to tftpboot
copying files for distro: centos-6.4-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-6.4-x86_64/images/pxeboot/vmlinuz -> /tftpboot/images/centos-6.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-6.4-x86_64/images/pxeboot/initrd.img -> /tftpboot/images/centos-6.4-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos-6.4-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-6.4-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos-6.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-6.4-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos-6.4-x86_64/initrd.img
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
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 ***

查看加载后的配置选项

[root@test tftpboot]# cat /tftpboot/pxelinux.cfg/default 

LABEL centos-6.4-x86_64-basic
        kernel /images/centos-6.4-x86_64/vmlinuz
        MENU LABEL centos-6.4-x86_64-basic
        append initrd=/images/centos-6.4-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://192.168.254.2/cblr/svc/op/ks/profile/centos-6.4-x86_64-basic
        ipappend 2


cobbler自动化安装详解