前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Cobbler 快速入门指南

Cobbler 快速入门指南

作者头像
KangVcar
发布2018-07-06 15:19:43
7450
发布2018-07-06 15:19:43
举报
文章被收录于专栏:kangvcarkangvcar

Cobbler 快速入门指南


由于Cobbler涉及各种各样的技术,Cobbler可能是一个稍微复杂的系统,但它在安装后几乎不需要任何配置就支持大量功能。在开始使用Cobbler之前,您应该具备PXE相关知识以及所选发行版的自动化安装方法。

本快速入门指南将重点介绍红帽kickstart流程,该流程非常成熟并经过了充分测试。未来我们将为其他发行版(如Ubuntu和SuSE)添加快速入门指南。下面的步骤将集中在Fedora上,但它们应该适用于任何基于Red Hat的发行版,例如RHEL,CentOS或Scientific Linux。有关您的特定操作系统版本的安装和先决条件的详细信息,请参阅安装补丁程序部分。

最后,本指南将只关注CLI应用程序。欲了解更多关于Cobbler Web界面的细节,请点击这里:Cobbler Web用户界面

Disable SELinux(optional)


在开始使用Cobbler之前,最好禁用SELinux或将其设置为“permissive”模式,特别是您不熟悉SELinux故障排除或修改SELinux策略时。

如果您想在运行cobblerd的系统上继续使用SELinux,请务必阅读本手册中的SELinux With Cobbler部分。

Installing Cobbler


安装只需通过yum完成:(需要安装epel源yum -y install epel-release

1

$ yum install cobbler

这将提供基本配置所有要求的文件。

Changing Settings


在启动cobblerd服务之前,您应该修改一些配置。

Cobbler/Cobbler的配置存储在/etc/cobbler/settings。此文件是YAML格式的数据文件,因此在编辑此文件时务必小心,因为格式不正确的文件将阻止Cobbler/Cobbler运行。

Default Encrypted Password

此设置用于为新系统指定root用户的密码。

1

default_password_crypted: "$1$bfI7WLZz$PxXetL97LkScqJFxnW7KS1"

您应该通过运行以下命令并将输出插入到上面的字符串中进行修改(请确保保存引号):

1

$ openssl passwd -1

Server and Next_Server

server选项设置将用于指定cobbler服务器的IP地址。不要使用0.0.0.0,因为它不是监听地址。这应该设置为cobbler服务器的可用IP,以便与例如HTTP和TFTP之类的协议联系cobbler服务器。

12

# default, localhostserver: 127.0.0.1

next_server选项用于指定DHCP/PXE下载网络引导文件的TFTP服务器的IP。通常,这将与服务器设置的IP相同。

12

# default, localhostnext_server: 127.0.0.1

DHCP Management and DHCP Server Template

为了进行PXE引导,您需要一个DHCP服务器来分发地址,并将引导系统指向TFTP服务器,以便在其中下载网络引导文件。Cobbler可以通过manage_dhcp设置管理DHCP服务器:

12

# default, don't managemanage_dhcp: 0

将该设置更改为1,以便cobbler将根据cobbler附带的dhcp.template生成dhcpd.conf文件。根据您的网络设置对该模板进行修改:

1

$ vi /etc/cobbler/dhcp.template

对于大多数用途,您只需要修改该块:

123456789

subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option domain-name-servers 192.168.1.210,192.168.1.211; option subnet-mask 255.255.255.0; filename "/pxelinux.0"; default-lease-time 2.8.0; max-lease-time 43200; next-server $next_server;}

无论如何,请确保不要修改next-server $next_server; 行,因为$next_server的值将从/etc/cobbler/settings文件读取。这个文件是一个cheetah模板,所以一定不要修改这行后面的任何内容:

1

#for dhcp_tag in $dhcp_tags.keys():

彻底检查dhcpd.conf配置语法超出了本文档的范围,但有关更多信息,请参阅手册页以获取更多详细信息:

1

$ man dhcpd.conf

Files and Directory Notes


Cobbler多处使用了/var目录。该/var/www/cobbler/ks_mirror目录是存放所有发行版和repo文件的地方,因此,您将需要为每个导入的发行版准备5-10GB的可用空间。

如果您已将Cobbler安装到包含分区的可用空间非常小的系统上/var,请阅读手册中的“ 重新分配安装”部分,以了解如何正确地重新安装。

Starting and Enabling the Cobbler Service


在启动cobblerd服务之前,请确保httpd服务已经安装并启动:

123

$ yum install -y httpd$ systemctl restart httpd$ systemctl enable httpd

一旦你更新了以上设置,你就可以启动cobblerd服务了。Fedora现在使用systemctl来管理服务,但您仍然可以使用常规的init脚本:

123456789

$ systemctl start cobblerd.service$ systemctl enable cobblerd.service$ systemctl status cobblerd.serviceor$ service cobblerd start$ chkconfig cobblerd on$ service cobblerd status

如果一切顺利,你应该看到status command的输出如下所示:

123456

cobblerd.service - Cobbler Helper Daemon Loaded: loaded (/lib/systemd/system/cobblerd.service; enabled) Active: active (running) since Sun, 17 Jun 2012 13:01:28 -0500; 1min 44s ago Main PID: 1234 (cobblerd) CGroup: name=systemd:/system/cobblerd.service └ 1234 /usr/bin/python /usr/bin/cobblerd -F

Checking for Problems and Your First Sync


既然cobblerd服务已经启动并正在运行,那么是时候检查配置问题了。Cobbler的检查配置命令cobbler check会提出一些建议,但重要的是要记住,这些主要只是建议,可能不是基本功能的关键,请根据情况来进行解决所提出的问题。

12345678910

$ cobbler checkThe following are potential configuration items that you may want to fix:........Restart cobblerd and then run 'cobbler sync' to apply changes.

请您在更改配置后务必按照其建议重新启动Cobblerd服务,以便更改生效。

一旦你解决了cobbler check提出的所有问题,现在是第一次同步的时候了。

123456789101112131415161718192021222324252627

$ cobbler synctask started: 2012-06-24_224243_synctask started (id=Sync, time=Sun Jun 24 22:42:43 2012)running pre-sync triggers...rendering DHCP filesgenerating /etc/dhcp/dhcpd.confrendering TFTPD filesgenerating /etc/xinetd.d/tftpcleaning link cachesrunning: find /var/lib/tftpboot/images/.link_cache -maxdepth 1 -type f -links 1 -exec rm -f '{}' ';'received on stdout:received on stderr:running post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/running python trigger cobbler.modules.sync_post_restart_servicesrunning: dhcpd -t -qreceived on stdout:received on stderr:running: service dhcpd restartreceived on stdout:received on stderr: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_trackrunning shell triggers from /var/lib/cobbler/triggers/change/ TASK COMPLETE

假设一切顺利,没有错误报告,您就可以继续下一步了。

Importing Your First Distribution


Cobbler通过cobbler import命令自动添加发行版和配置文件。此命令可以(通常)自动检测您导入的分类类型和版本,并为您创建(一个或多个)具有正确设置的配置文件。

Download an ISO Image

为了导入发行版,您需要为您的发行版提供DVD ISO。注:您必须使用完整的DVD,而不是“Live CD”ISO。在这个例子中,我们将使用Fedora 28 x86_64 ISO,可以在这里下载

一旦下载这个文件,请将它挂载在某个目录下:

1

$ mount -t iso9660 -o loop,ro /path/to/isos/Fedora-Server-dvd-x86_64-28-1.1.iso /mnt

Run the Import

您现在已准备好导入的发行版。名称和路径参数是导入的唯一且必需选项:

1

$ cobbler import --name=fedora28 --arch=x86_64 --path=/mnt

--arch选项不需要指定,因为它通常会被自动检测。在这个例子中,我们这样做是为了防止找到多个体系结构(Fedora在完整的DVD上运行i386包,默认情况下,cobbler将创建x86_64和i386发行版)。

Listing Objects

如果在导入期间未报告错误,则可以查看有关在导入过程中创建的发行版和配置文件的详细信息。

1234

$ cobbler distro list$ cobbler profile list

导入命令通常会创建至少一个发行版/配置文件对,其名称与上面显示的名称相同。在某些情况下(例如,当找到基于xen的内核时),将创建多个发行/配置文件对。

Object Details

这个报告命令显示了Cobbler Object的细节:

123456789101112131415161718

$ cobbler distro report --name=fedora28-x86_64Name : fedora28-x86_64Architecture : x86_64TFTP Boot Files : {}Breed : redhatComment :Fetchable Files : {}Initrd : /var/www/cobbler/ks_mirror/fedora28-x86_64/images/pxeboot/initrd.imgKernel : /var/www/cobbler/ks_mirror/fedora28-x86_64/images/pxeboot/vmlinuzKernel Options : {}Kernel Options (Post Install) : {}Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/fedora28-x86_64'}Management Classes : []OS Version : fedora28Owners : ['admin']Red Hat Management Key : <<inherit>>Red Hat Management Server : <<inherit>>Template Files : {}

正如你在上面看到的那样,Kickstart Metadata字段(内部为--ksmeta)用于各种变量,并且包含关键的tree变量。这些在kickstart模板中用于指定可以找到安装文件的URL。

其他要注意的是:有些字段被设置为<< inherit >>。这意味着他们将使用默认设置(在settings文件中找到),或者(对于配置文件,子配置文件和系统)将使用父对象中配置的设置。

Creating a kickstart file (Options)


你已经成功导入了发行版,发行版镜像的内容会自动复制到/var/www/cobbler/ks_mirror目录下,现在你可以选择提供一个定制的ks文件(在CentOS安装完成后提供一个文件/root/anaconda-ks.cfg),你可以将/root/anaconda-ks.cfg复制到/var/lib/cobbler/kickstarts目录下;你也可以不用提供ks文件,因为cobbler默认提供了很多ks文件在/var/lib/cobbler/kickstarts目录下(默认使用sample_end.ks)。

如果你决定提供定制的ks文件,那么如下命令进行指定ks文件,系统将会更具你指定ks文件进行部署:

1

$ cobbler profile edit --name=fedora28-x86_64 --kickstart=/var/lib/cobbler/kickstarts/anaconda-ks.cfg

每次对cobbler做出修改后,你都应该执行命令cobbler sync。 至此,你已经可以开始批量部署操作系统了。 启动client并确保和cobbler server端在同一网络内即可开始自动部署。

Creating a System (Options)


现在您已拥有发行版和配置文件,您可以创建一个系统。配置文件可用于PXE启动,但Cobbler的大部分功能都围绕着system object。您可以提供更多的系统信息来给Cobbler使用。

首先,我们将根据导入期间创建的配置文件创建一个system object。创建system时,名称和配置文件是唯一且必需的两个字段:

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647

$ cobbler system add --name=test --profile=fedora28-x86_64$ cobbler system listtest$ cobbler system report --name=testName : testTFTP Boot Files : {}Comment :Enable gPXE? : 0Fetchable Files : {}Gateway :Hostname :Image :IPv6 Autoconfiguration : FalseIPv6 Default Device :Kernel Options : {}Kernel Options (Post Install) : {}Kickstart : <<inherit>>Kickstart Metadata : {}LDAP Enabled : FalseLDAP Management Type : authconfigManagement Classes : []Management Parameters : <<inherit>>Monit Enabled : FalseName Servers : []Name Servers Search Path : []Netboot Enabled : TrueOwners : ['admin']Power Management Address :Power Management ID :Power Management Password :Power Management Type : ipmitoolPower Management Username :Profile : fedora28-x86_64Proxy : <<inherit>>Red Hat Management Key : <<inherit>>Red Hat Management Server : <<inherit>>Repos Enabled : FalseServer Override : <<inherit>>Status : productionTemplate Files : {}Virt Auto Boot : <<inherit>>Virt CPUs : <<inherit>>Virt Disk Driver Type : <<inherit>>Virt File Size(GB) : <<inherit>>Virt Path : <<inherit>>Virt RAM (MB) : <<inherit>>Virt Type : <<inherit>>

创建system的主要原因是网络配置。使用配置文件时,仅限于DHCP接口,但通过system可以指定更多的网络配置选项。

所以现在我们将在192.168.1/24网络中设置一个简单的接口:

1

$ cobbler system edit --name=test --interface=eth0 --mac=00:11:22:AA:BB:CC --ip-address=192.168.1.100 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com

默认网关没有按每个NIC指定,因此只需单独添加(与主机名一同添加):

1

$ cobbler system edit --name=test --gateway=192.168.1.1 --hostname=test.mydomain.com

--hostname字段对应于本地系统名称,由hostname命令返回。--dns-name(可以根据NIC设置)应该对应于与该接口的IP绑定的DNS A记录。两者都不是必需的,但指定两者都是一个好习惯。某些高级功能(如配置管理)依赖于--dns-name字段进行系统记录查找。

无论何时编辑system object,cobbler都会执行所谓的”lite sync”,它会重新生成关键文件,如TFTP根目录中的PXE引导文件。有一件事情不会执行服务管理操作,例如重新生成dhcpd.conf重新启动DHCP服务。在添加带有静态接口的系统后,执行完整的“cobbler sync”是一个好主意,以确保dhcpd.conf文件被正确的静态租约重写并且服务被重启。

官方链接


本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-06-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Cobbler 快速入门指南
    • Disable SELinux(optional)
      • Installing Cobbler
        • Changing Settings
          • Default Encrypted Password
          • Server and Next_Server
          • DHCP Management and DHCP Server Template
        • Files and Directory Notes
          • Starting and Enabling the Cobbler Service
            • Checking for Problems and Your First Sync
              • Importing Your First Distribution
                • Download an ISO Image
                • Run the Import
                • Listing Objects
                • Object Details
              • Creating a kickstart file (Options)
                • Creating a System (Options)
                  • 官方链接
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档