一:PXE、Kickstart与Cobbler的概念:node
PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的技术,须要网卡的硬件支持,工做于C/S的网络模式,支持客户端经过网络从服务器下载映像,并支持客户端机器经过网络启动操做系统,在启动过程当中,客户端须要从服务器分配IP地址、掩码、网关以及相关的配置文件路径,再用TFTP(trivial file transfer protocol)协议从服务器下载一个启动软件包到本机内存中执行,由这个启动软件包完成客户端的基本软件设置,从而引导预先安装在服务器中的终端操做系统,PXE能够引导多种操做系统,如:centos、redhat、windows 7等,因此说PXE是一直引导启动方式,用于引导PC或服务器的启动。python
Kickstart是一种实现操做系统无人值守的安装方式,须要先定义一个配置文件,里面定义好root密码、分区、安装的包等等参数,此文件通常称为ks.cfg,客户端根据ks.cfg定义的ISO下载内核vmlinux和安装包,进行磁盘的分区与格式化,定义好的rpm包的安装,甚至是系统的参数优化等。linux
Cobbler翻译为中文是补鞋匠,可是在linux方面则是一个免费的用于系统安装部署的开源软件,cobbler是对PXE技术的二次基于python的开发,提供了CLI(命令行)和Web的管理方式,另外还提供了API(应用程序编程接口)接口,方便二次开发使用,相比PXE,cobbler支持多系统同时引导,而PXE只能一次引导一个系统的安装,cobbler一般与开源软件puppet、saltstack配合使用,进行操做系统的批量安装与部署优化,从而实现大批量linux系统的无人值守安装与服务部署,大大提高运维的工做效率,Cobbler是一种更高级的无人值守的系统安装方式,由于其能够同时引导多个不一样的操做系统的安装与部署,可是Kickstart只能引导一个。web
1.一、Kickstart流程:编程
二:Cobbler组件:vim
一、distro:定义安装的系统发行版,好比centos6.7是一个发行版,还能够根据不一样的kickstack文件安装出不一样业务场景的系统。windows
2.profile:定义配置文件,结合distro能够实现安装不一样环境的操做系统。centos
3.system:为指定的主机配置特有的信息,好比主机名等。安全
4.repos:定义yum源。服务器
5.images:定义在虚拟化环境中定义虚拟机的磁盘。
三:cobbler安装与配置:
一、安装cobbler:
[root@linux-node1 ~]# yum install cobbler cobbler-web pykickstart httpd
cobbler #cobbler服务的主程序包 cobbler-web #web管理界面 pykickstart #检查语法是否正确 httpd #http服务器
二、启动服务:
[root@linux-node1 ~]# systemctl start httpd [root@linux-node1 ~]# systemctl start cobblerd [root@linux-node1 ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@linux-node1 ~]# systemctl enable cobblerd Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
三、检查配置文件:
[root@linux-node1 ~]# 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 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. 5 : enable and start rsyncd.service with systemctl 6 : debmirror package is not installed, it will be required to manage debian deployments and repositories 7 : 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 8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
4.错误修正:
1.[root@linux-node1 ~]# vim /etc/cobbler/settings
next_server: 192.168.56.11 server: 192.168.56.11
2.
yum install xinetd systemctl enable xinetd systemctl start rsyncd.service systemctl restart cobblerd.service systemctl enable rsyncd.service cobbler check
3.准备启动文件:
cp /usr/share/syslinux/pxelinux.0 /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
4.修改默认密码
[root@linux-node1 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)
5.安装配置dhcp
yum install dhcp
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@linux-node1 cobbler]# cat /etc/dhcp/dhcpd.conf | grep -v "#" | grep -v "^$"
option domain-name "jack.com";
option domain-name-servers 192.168.56.11;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.56.0 netmask 255.255.255.0 {
range 192.168.56.100 192.168.56.200;
option routers 192.168.56.2;
next-server 192.168.56.11;
filename "pxelinux.0";
}
6.同步:
[root@linux-node1 ~]# cobbler sync task started: 2016-05-23_121731_sync task started (id=Sync, time=Mon May 23 12:17:31 2016) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering TFTPD files
七、配置distro:
查看帮助:
[root@linux-node1 ~]# cobbler --help usage ===== cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|getks*|list|remove|rename|report] [options|--help] cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
[root@linux-node1 ~]# cobbler distro --help
[root@linux-node1 ~]# cobbler distro add --help
导入:
cobbler import --path=/mnt/ --name="Centos-7.2-x86_64" --kickstart=/var/lib/cobbler/kickstarts/cobbler-centos-7.2-x86_64.cfg
重启测试:
8.web管理:cobbler-web
[root@linux-node1 ~]# vim /etc/cobbler/modules.conf
module = authn_configfile #认证,默认是虚拟用户认证
九、生成密码:
[root@linux-node1 ~]# htdigest -c /etc/cobbler/users.digest Cobbler tom #添加一个叫tom的用户,放在Cobbler组
Adding password for cblradmin in realm cobbler.
New password:
Re-type new password:
[root@linux-node1 ~]#
10.使用https访问web,如:https://192.168.56.11/cobbler_web
三:自定义Centos 7的kickstack文件:
一、须要图形界面下安装system-config-kickstack命令启动图形进行自定义安装包,以下:
[root@localhost ~]# yum install system-config-kickstack -y
二、打开配置界面,开始自定义kickstack应答文件:
基础配置:
二、http 跳过
三、配置引导安装:
四、分区部分:
五、网络设置,暂不须要
六、认证,默认便可:
七、安全设置:
八、安装界面:
九、安装包包选择,能够自定义,通常选择最小化安装,最后保存为一个文件,内容以下: