cobbler 是基于 python 语言开发的 pxe 二次封装的网络安装服务;能够多系统选自自动化安装配置。能够经过 Web 图形化界面配置,其安装包为 cobbler,在 epel 源上,配置过程当中某些过程可能须要依赖互联网环境。node
使用 Cobbler,无需进行人工干预便可安装机器。Cobbler 设置一个 PXE 引导环境(它还可使用 yaboot 支持 PowerPC),并控制原装相关的全部方面,好比网络引导服务(DHCP 和 TFTP)与存储库镜像。当但愿安装一台新机器时,Cobbler 能够:
1)使用一个之前定义的模板来配置 DHCP 服务(若是启用了管理 DHCP)
2)讲一个存储库(yum 或 rsync)创建镜像或解压缩一个媒介,以注册一个新操做系统
3)在 DHCP 配置文件中为须要安装的机器建立一个条目,并使用指定的参数(IP 和 MAC)
4)在 TFTP 服务目录下建立适当的 PXE 文件
5)从新启动 DHCP 服务来反应新的更改
6)从新启动机器以开始安装(若是电源管理已启动python
Cobbler 支持众多的发行版:Redhat、Fedora、CentOS、Debian、Ubuntu 和 SUSE。当添加一个操做系统(一般经过使用 ISO 文件)时,Cobbler 知道如何解压缩合适的文件并调整网络服务,以正确引导机器。
Cobbler 可使用 kickstart 模板。基于 Redhat 或 Fedora 的系统使用 kickstart 文件来自动化安装流程,经过使用模板,就会拥有基本 kickstart 模板,而后定义如何针对一种配置文件或机器配置而替换其中的变量。例如,一个模板可能包含两个变量 $domain 和 $machine_name。在 Cobbler 配置中,一个配置文件指定 domain=mydomain.com,而且每台使用该配置文件的机器在 machine_name 变量中指定其名称。该配置文件的全部机器都是用相同的 kickstart 安装且针对 domain=mydomain.com 进行配置,但每台机器拥有其本身的机器名称。仍然可使用 kickstart 模板在不一样的域中安装其余机器并使用不一样的机器名称。
为了协助管理系统,Cobbler 可经过 fence_scripts 链接到各个电源管理环境。Cobbler 支持 apc_snmp、bladecenter、bullpap、drac、ether_wake、ilo、integrity、ipmilan、ipmitool、Ipar、rsa、virsh 和 wti。要从新安装一台机器,可运行 reboot system foo 命令,并且 Cobbler 会使用必要的和信息来为您运行恰当的 fence scripts(好比机器插槽数)。
除了这些特性,还可使用一个配置管理系统(CMS)。有两种选择:该工具内的一个内部系统,或者现成的外部 CMS,好比 Chef 或 Puppet。借助内部系统,你能够指定文件模板,这些模板会依据配置参数进行处理(与 kickstart 模板的处理方式同样),而后复制到你指定的位置。若是必须自动将配置文件部署到特定机器,那么此功能颇有用。
使用 koan 客户端,Cobbler 可从客户端配置虚拟机并从新安装系统。linux
PXE 服务支持
DHCP 服务管理
DNS 服务管理(可选bind,dnsmasq)
电源管理
Kickstart 服务支持
yum 仓库管理
TFTP (PXE 启动时须要)
Apache(提供 kickstart 的安装源,并提供定制化的 kickstart 配置)
同时,它和 apache 作了深度整合nginx
由于 cobbler 基于 pxe 二次封装的,因此了解 PXE 工做流程也重要,图以下:web
从上图能够看出:apache
Cobbler 的配置结构基于一组注册的对象。没个对象表示一个与另外一个实体相关联的实体(该对象指向另外一个对象,或者另外一个对象指向该对象)。当一个对象指向另外一个对象时,它就集成了被指向对象的数据,并可覆盖或添加更多特定信息。
如下对象类型的定义为:
发行版:表示一个操做系统。它承载了内核和 initrd 的信息,以及内核参数等其余数据;
配置文件:包含一个发行版、一个 kickstart 文件以及可能的存储库,还包含更多特定的内核参数等其余数据;
系统:表示要配给的机器。它把汗一个配置文件或一个镜像,还包含 IP 和 MAC;地址、电源管理(地址、凭据、类型)以及更为专业的数据等信息;
存储库:保存一个 yum 或 rsync 存储库的镜像信息;
镜像:可替换一个包含不属于此类别的文件的发行版对象(例如,没法分为内核和 initrd 的对象);
基于注册的对象以及各个对象之间的关联,Cobbler 知道如何更改文件系统以反应具体配置。由于系统配置的内部是抽象的,因此能够仅关注想要执行的操做。centos
必要服务
1)cobbler (cobbler 的核心)
2)httpd (提供 cobbler 的 web 界面)
3)dhcpd (为自动安装系统分配 IP 地址)
4)epel-release(为之提供yum源)
5)rsync (cobbler 须要同步信息)
6)cobbler-web (cobbler 的一个 web 插件)
7)xinetd (为 rsync 和 tftp 的守护进程)
8)tftp (传送安装的一些文件的 相似ftp)bash
systemctl stop firewalld systemctl disable firewalld sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
epel
基础镜像源wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
cobbler 和 apache 有深度配合因此安装 apache,不要安装 nginx 不然生成不了相关配置服务器
yum install -y httpd dhcpd tftp python-ctypes cobbler cobbler-web pykickstart fence-agents xinetd rsync
systemctl start httpd xinetd cobblerd.service systemctl enable httpd xinetd cobblerd.service
cobbler 的帮助命令为 cobbler –help网络
cobbler check
解决方法:
server
配置成具体的服务器 ip 地址next_server
也修改成具体的 ip 地址disable
从 yes 改成 nocobbler get-loaders
网络引导加载程序systemctl start rsyncd、systemctl enable rsyncd
须要安装系统登陆名
须要安装系统登陆密码
生成字段写入/etc/cobbler/settings 中default_password_crypted
字段systemctl restart cobblerd
cobbler sync
cd /etc/cobbler cp dhcp.template dhcp.template.org sed -i '/^subnet/s/192.168.1.0/172.16.80.0/' dhcp.template sed -i '/routers/s/192.168.1.5/172.16.80.254/' dhcp.temlpate sed -i '/domain-name-servers/s/192.168.1.1/172.16.18.245/' dhcp.template sed -i '/dynamic-bootps/s/192.168.1.100 192.168.1.254/172.16.80.100 172.16.80.200/' dhcp.template
把里面的信息修改成和本身同一个局域网的
sed -i '/manage_dhcp:/s/0/1/' /etc/cobbler/settings systemctl restart cobblerd sleep 2 cobbler sync
cat /etc/dhcp/dhcpd.conf
上传 iso 镜像文件到服务器,并挂载到目录
mkdir /mnt/iso mount -o loop -t iso9660 CentOS-7-x86_64-Minimal-1810.iso /mnt/iso
用 cobbler 导入系统
cobbler import --path=/mnt/iso --name=CentOS-7.6-x86_64 --arch=x86_64 cobbler profile list cobbler profile report
上面在导入系统的过程当中 cobbler 帮咱们本身生成了相关的配置,关联 dhcp,pxe安装菜单
生成 Kickstart 文件,能够看一下里面有哪些东西
cd /var/lib/cobbler/kickstarts/ less sample_end.ks mv sample_end.ks sample_end.ks.bak
生成的 Kickstart
文件能够根据本身的须要进行修改,前提是要熟悉原生的 Kickstart
语法, 能够参考
kickstart使用详细指南
CentOS-7.6-x86_64.ks
[root@k8s-node2 ~]# cat /var/lib/cobbler/kickstarts/CentOS-7.6-x86_64.ks # This kickstart file should only be used with EL > 5 and/or Fedora > 7. # For older versions please use the sample.ks kickstart file. #platform=x86, AMD64, or Intel EM64T # System authorization information auth --useshadow --enablemd5 # System bootloader configuration bootloader --location=mbr # Partition clearing information clearpart --all --initlabel # Use text mode install text # Firewall configuration firewall --disabled # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard us # System language lang en_US # Use network installation url --url=$tree # If any cobbler repo definitions were referenced in the kickstart profile, include them here. $yum_repo_stanza # Network information # $SNIPPET('network_config') network --bootproto=dhcp --device=enp1s0 --onboot=on #配置网卡默认自动开启DHCP功能,配置网卡名称为enp1s0 # Reboot after installation reboot #Root password rootpw --iscrypted $1$root$AKl5mABzn4OHUp7t27Sp1/ # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # System timezone timezone Asia/Shanghai #设置时区为中国上海时区 # Install OS instead of upgrade install # Clear the Master Boot Record zerombr clearpart --all --initlabel part /boot --fstype="xfs" --size=2048 #boot分区给2G大小 part swap --fstype="swap" --size=16384 #swap分区给内存大小的2倍 part / --fstype="xfs" --size=122880 #/分区给120G大小 part /var --fstype="xfs" --size=1765376 #var分区给剩下磁盘大小 # Allow anaconda to partition the system as needed # autopart %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end %packages $SNIPPET('func_install_if_enabled') %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
cobbler profile edit --name=CentOS-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.6-x86_64.ks systemctl restart cobblerd sleep 2 cobbler sync
查看cobbler生成配置
cobbler profile report