Cobbler实现多系统自动化安装

Cobbler介绍:

 Cobbler能够快速建立多系统同时安装的网络系统安装环境;传统的pxe+dhcp+tftp+kickstart仅能够提供单一系统安装,功能过于简单;如果遇到安装不同操作系统时就遇到瓶颈;而cobbler正好解决了这一问题。Cobbler是增强版的网络系统安装。

Cobbler由不同的组件配合完成系统安装,各组件之间配合如下图所示:

21.png

一、实验环境准备:

(1)一台主机,并且关闭SELinux和iptables防火墙

(2)准备两个两个光盘镜像文件,一个是CentOS-6.5;另一个是CentOS-6.6

(3)tftp,dhcp,cobbler都在一台主机

二、配置Cobbler:

(1)安装Cobbler

[root@node2 ~]# yum -y install cobbler pykickstart debmirror httpd syslinux tfpt dhcp \\需要事先准备好epel源

(2)启动httpd和cobbler

[root@node2 ~]# /etc/init.d/httpd  start
[root@node2 ~]# /etc/init.d/cobblerd start

(3)运行cobbler check检查cobbler环境

[root@node2 ~]# 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : change 'disable' to 'no' in /etc/xinetd.d/rsync
7 : comment out 'dists' on /etc/debmirror.conf for proper debian support
8 : comment out 'arches' on /etc/debmirror.conf for proper debian support
9 : 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
10 : 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.

根据提示完善cobbler运行环境
1、编辑/etc/cobbler/settings,修改如下内容
server: 172.16.2.13  \\默认为127.0.0.1,要修改为cobbler的对外通信的IP
2、编辑/etc/cobbler/settings,修改如下内容:
next_server: 172.16.2.13 \\此处填写tftp的地址,默认为127.0.0.1
3、编辑/etc/sysconfgi/selinux
SELINUX=disabled \\修改完需要重启
4、设置tftp开机启动
[root@node2 ~]# chkconfig tftp on
5、根据提示运行cobbler get-loaders
[root@node2 ~]# cobbler get-loaders 
   \\如果没有网络可以复制/usr/share/syslinux/*  /var/lib/cobbler/loaders
6、设置rsync开机启动
[root@node2 ~]# chkconfig rsync on
7和8注释掉/etc/debmirror.conf的选项
#@dists="sid";
#@arches="i386";  \\注释掉这两个选项
9、生成新的秘钥,添加至/etc/cobbler/settings
[root@node2 ~]# openssl  passwd -1 -salt `openssl rand -hex 4`
Password: 
$1$28999937$ExBtgrSzOiI/ri3NknQQB1
编辑/etc/cobbler/settings配置文件,将生成的秘钥添替换原有的秘钥
default_password_crypted: "$1$28999937$ExBtgrSzOiI/ri3NknQQB1"
10、可以忽略

(4)以上修改操作完以后,进程同步,然后在进行检查

[root@node2 ~]# cobbler sync
task started: 2014-12-16_114120_sync
task started (id=Sync, time=Tue Dec 16 11:41:20 2014)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
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@node2 ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them \\此提示可以忽略

(5)挂载CentOS6.5光盘镜像,导入镜像到cobbler

[root@node2 ~]# mount -r /dev/cdrom /mnt
[root@node2 ~]# mount -r /dev/cdrom /mnt
[root@node2 ~]# cobbler import --name=CentOS-6.5-x86_64 --path=/mnt
task started: 2014-12-16_114737_import
task started (id=Media import, time=Tue Dec 16 11:47:37 2014)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64:
creating new distro: CentOS-6.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64 -> /var/www/cobbler/links/CentOS-6.5-x86_64
creating new profile: CentOS-6.5-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64 for CentOS-6.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6.5-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.5-x86_64/repodata
*** TASK COMPLETE ***

(6)导入CentOS6.6的光盘镜像与CentOS的方法一样,这里就不在讲述了

(7)查看导入的关盘镜像信息

[root@node2 ~]# cobbler distro list
   CentOS-6.5-x86_64
   CentOS-6.6-x86_64

(8)删除导入镜像文件自动生成的profile文件,添加自己定制的profile文件

[root@node2 ~]# cobbler profile remove --name=CentOS-6.5-x86_64; cobbler profile remove --name=CentOS-6.6-x86_64

(9)复制制作好的kickstart文件到/var/lib/cobbler/kickstarts

[root@node2 ~]# cp kickstart_6.6.cfg  /var/lib/cobbler/kickstarts/CentOS-6.6-x86_64
[root@node2 ~]# cp kickstart_6.5.cfg  /var/lib/cobbler/kickstarts/CentOS-6.5-x86_64
[root@node2 ~]# cobbler   profile add  --name=CentOS-6.5-x86_64 --distro=CentOS-6.5-x86_64   --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.5-x86_64 
[root@node2 ~]# cobbler   profile add  --name=CentOS-6.6-x86_64 --distro=CentOS-6.6-x86_64   --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.6-x86_64

(10)查看添加的profile文件

[root@node2 ~]# cobbler profile list
   CentOS-6.5-x86_64
   CentOS-6.6-x86_64

三、配置dhcp

编辑配置文件,修改内容如下:

[root@node2 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf  \\添加配置文件
[root@node2 ~]# vim /etc/dhcp/dhcpd.conf
subnet 172.16.2.0 netmask 255.255.255.0 {
  range 172.16.2.10 172.16.2.100  ;
  option routers 172.16.2.1;
  next-server 172.16.2.13;  \\定义tftp服务器的地址
  filename "pxelinux.0";    \\定义安装主机所需要获取的文件
}
[root@node2 ~]# /etc/init.d/dhcpd start  \\启动dhcp

四、利用cobbler安装操作系统

CentOS6.5的安装过程

22.png

24.png

25.png

26.png

CentOS6.6的安装过程:

33.png

24.png25.png

32.png

五、配置cobbler的web控制端:

(1)安装

[root@node2 ~]# yum -y install cobbler-web

(2)编辑配置文件/etc/cobbler/modules.conf修改内容如下:

[authentication]
module = authn_pam

(3)添加登录cobbler的web用户及密码

[root@node2 ~]# useradd  cobbler;echo "admin" |passwd --stdin cobbler

(4)编辑配置文/etc/cobbler/users.conf修改内容如下:

[admins]
admin = "cobbler" \\填写刚刚创建的cobbler用户
cobbler = ""

(5)重新启动cobbler,访问web页面,地址是:http://172.16.2.13/cobbler_web

44.png

45.png

关于web页面配置cobbler的操作请各位大侠研究吧,我就先介绍到这里。

六、知识扩展:

经常有同学在配置网络安装时遇到以下故障:

blob.png

如果你去网上搜索全都是说内存不够,其实根本就不是内存问题。

解决方法:在制作kickstart文件是没有勾选清除mbr选项导致的,重新执行kickstart文件,选择清除mbr即可,

如下图所示:

34.png

到此cobbler的配置已经完成,可以在工作中使用,如有问题可以一起解决。

cobbler官网地址:http://cobbler.github.io/

原创文章,作者:马行空,如若转载,请注明出处:http://www.178linux.com/6908

(0)
马行空马行空
上一篇 2015-08-06 22:00
下一篇 2015-08-11 14:57

相关推荐

  • rpm 程序包管理器的基本使用

    目录 安装程序包 卸载 升级 查询 校验 来源合法性和完整性验证 数据库重建 1     安装程序包 rpm -ivh /path/to/package_file -v     显示执行过程的参数。 -h   &nbsp…

    Linux干货 2016-06-22
  • Linux基础目录名称命名法则及功能规定

    Linux中有非常多的目录文件,那么这些目录文件的命令规则,和功能都有那些,今天学习了下,下面是我的学习记录,跟大家分享下。 文件命名规则 (1) 除了/之外,所有字符都合法 (2) 特殊字符如@、#、¥、&、()、-、空格等最好不要使用,当使用空格作为文件名时,执行命令会出错 (3) 避免使用”.”作为文件名的第一个字符,因为在Linux系统中以”…

    Linux干货 2016-08-15
  • Python基础语法习题

    1、~12为什么是-13?解1:12 二进制:0000 1100补码: 0000 1100按位取反 :1111 0011求这个原码,即负数求补码的逆过程:先减1,再取反 (符号位不变)-1 1111 0010取反 1111 1101 还原成十进制-13 2、10^9等于?10^-9等于?解:(1)10^910的二进制:0000 10109的二进制: 0000…

    Linux干货 2018-03-24
  • Linux之磁盘管理

    Linux之磁盘管理       linux系统中, 一切都是文件, 而这些文件都是存储在磁盘中, 因此对于磁盘的管理是非常重要的, Linux磁盘管理的好坏, 直接关系到整个系统的性能问题, 本文主要介绍了磁盘结构, 分区类型, 管理分区, 管理文件系统, 挂载设备, 管理虚拟内存这几大项的内容.    &…

    Linux干货 2016-08-29
  • Python装饰器与面向切面编程

    新年好~ 那么,很久没有更新了,其实想想也没多少可以写的,因为Python的文档似乎很全面的说……能做的差不多只有翻译和整理了,英文过关的朋友不妨直接去doc.python.org这里查看相关资料 :) 转载请注明原作者和原文地址,多谢! 今天来讨论一下装饰器。装饰器是一个很著名的设计模式,经常被用于有切面需求的场景,较为经典的有插入日志、性能测试、事务处理…

    Linux干货 2015-03-12
  • 马哥教育网络班21期-第五周课程练习

    1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@localhost ~]# grep "^[[:space:]]\{1,\}" /boot/grub/grub.conf 2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符…

    Linux干货 2016-08-08