Cobbler 是 RedHat 支持的一个开源项目,用来部署和安装系统。所以对 Redhat 系列 OS 支持是比较好的。 Cobbler 不仅仅是一个 pxe 服务器,他还可以管理 dns(bind),dhcp。一般数据中心里戒者生产环境,是不允许 dhcp, 但是 pxe,必须需要 dhcp,所以我们需要根据 mac 地址来分配 IP,这样 dhcp 就不会影响到网络。 Cobbler 的优点:自动管理各个服务器间的配置,更强大的管理功能。而且它还有 Web 管理界面,可以通过点一点鼠标就可以安装一台主机。Kickstart 的模板文件可以配置多个。 Cobbler 简介 网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。 很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域经营多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。 环境: Cobbler 运行流程 Server 端: Client 端: 搭建 Cobbler 无人值守安装服务器 1 环境初始化 Cobbler 服务端:CentOS Linux release 7.6.1810 #关闭 selinux 和防火墙 [root@Jaking ~]# systemctl stop firewalld.service && systemctl disable firewalld.service && iptables -F && setenforce 0 #永久关闭 selinux 执行下面命令 [root@Jaking ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 2 安装配置 Cobbler [root@Jaking ~]# yum install -y epel-release [root@Jaking ~]# yum install -y cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd [root@Jaking ~]# vim /etc/yum.repos.d/CentOS-Base.repo cobbler #Cobbler 程序包 cobbler-web #Cobbler 的 Web 服务包 pykickstart #Cobbler 检查 kickstart 语法错误 httpd #Apache Web 服务 [root@Jaking ~]# ls /etc/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/cobbler # 日志目录 /var/log/cobbler/install.log # 客户端系统安装日志 /var/log/cobbler/cobbler.log # Cobbler 日志 [root@Jaking ~]# systemctl start cobblerd httpd [root@Jaking ~]# 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 Restart cobblerd and then run 'cobbler sync' to apply changes. 以上问题我们需要逐步解决。 问题 1:修改 server 地址为 192.168.1.7 [root@Jaking ~]# vim /etc/cobbler/settings [root@Jaking ~]# vim /etc/cobbler/settings 改:278 next_server: 127.0.1 为:278 next_server: 192.168.1.7 [root@Jaking ~]# vim /etc/xinetd.d/tftp [root@Jaking ~]# cobbler get-loaders task started: 2020-01-04_031204_get_loaders task started (id=Download Bootloader Content, time=Sat Jan 4 03:12:04 2020) downloading https://cobbler./loaders/README to /var/lib/cobbler/loaders/README downloading https://cobbler./loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading https://cobbler./loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading https://cobbler./loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading https://cobbler./loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading https://cobbler./loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading https://cobbler./loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading https://cobbler./loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading https://cobbler./loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading https://cobbler./loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE *** [root@Jaking ~]# systemctl start rsyncd && systemctl enable rsyncd debmirror package is not installed, it will be required to manage debian deployments and repositories # debmirror 包尚未安装,需要它来管理 debian 部署和存储库 [root@Jaking ~]# openssl passwd -1 -salt 'root' '123456' fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them 修改完以上配置就可以检查 DHCP 配置了,由于 Cobbler 自动管理 DHCP 服务,我们只需要修改 Cobbler 中的模板配置文件即可。 [root@Jaking ~]# vim /etc/cobbler/dhcp.template 注:配置默认为 192.168.1.0 网段,具体要看你的装机 vlan 划分,现在是实验环境所以保持配不变。 修改 Cobbler 管理 dhcp 服务 [root@Jaking ~]# vim /etc/cobbler/settings 改:242 manage_dhcp: 0 为:242 manage_dhcp: 1 [root@Jaking ~]# systemctl restart cobblerd 注意观察 DHCP 服务是否启动。 重新检查,剩下 2 个可以忽略的问题。 [root@Jaking ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories 2 : 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@Jaking ~]# mount /dev/sr0 /mnt [root@Jaking ~]# cobbler import --path=/mnt/ --name=CentOS-7.6 --arch=x86_64 task started: 2020-01-04_033346_import task started (id=Media import, time=Sat Jan 4 03:33:46 2020) 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-7.6-x86_64: creating new distro: CentOS-7.6-x86_64 trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64 -> /var/www/cobbler/links/CentOS-7.6-x86_64 creating new profile: CentOS-7.6-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-7.6-x86_64 for CentOS-7.6-x86_64 processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64 looking for /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/repodata *** TASK COMPLETE *** [root@Jaking ~]# cobbler list [root@Jaking ~]# systemctl restart cobblerd [root@Jaking ~]# cobbler sync 至此,搭建 Cobbler 无人值守安装服务器完成! 本文原创地址:https://www./cobbler-installation-server.html编辑:传棋,审核员:逄增宝 |
|
来自: 西北望msm66g9f > 《编程》