1、Cobbler
是一个Linux
服务器安装的服务,可以通过网络启动(PXE
)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP
,DNS
等。
2、Cobbler
可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web
),还提供了API
接口,可以方便二次开发使用。
3、Cobbler
是较早前的kickstart
的升级版,优点是比较容易配置,还自带web界面比较易于管理。
4、Cobbler
内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet
。
Cobbler
的配置结构基于一组注册的对象。每个对象表示一个与另一个实体相关联的实体。当一个对象指向另一个对象时,它就继承了被指向对象的数据,并可覆盖或添加更多特定信息。
distros
): 表示一个操作系统。它承载了内核和initrd
的信息,以及内核参数等其他数据。profiles
):包含一个发行版、一个kickstart
文件以及可能的存储库,还包括更多特定的内核参数等其他数据。systems
):表示要配给的机器。它包括一个配置文件或一个镜像、IP
和MAC
地址、电源管理(地址、凭据、类型)以及更为专业的数据等信息。images
):可以替换一个保函不屑于此类别的文件的发行版对象(例如,无法分为内核和initrd
的对象)。Server端
Cobbler
服务Cobbler
错误检查,执行cobbler check
命令cobbler sync
命令TFTP
目录中DHCP
服务,提供地址分配DHCP
服务分配IP地址TFTP
传输启动文件Server
端接收安装信息Server
端发送ISO
镜像与Kickstart
文件Client端
PXE
模式启动IP
地址TFTP
服务器获取启动文件Cobbler
安装选择界面Kickstart
文件虚拟机网卡采用NAT模式或者仅主机模式,不要使用桥接模式,因为后面会搭建DHCP服务器,在同一个局域网多个DHCP服务会有冲突。
VMware的NAT模式的dhcp服务也关闭,避免干扰。
服务 | 状态 |
---|---|
selinux | disabled |
firewalld | disabled |
#安装epel源
yum install -y epel-release.noarch
#安装cobbler和dhcp 存在依赖关系其他的服务会自动安装
yum install cobbler dhcp
应用名称 | 版本 | 安装方式 | 配置文件目录 |
---|---|---|---|
Cobbler | 2.8.5 | YUM | /etc/cobbler/settings |
DHCP | 4.2.5 | YUM | /etc/cobbler/dhcpd.conf.template |
Apache | 2.4.6 | YUM | /etc/httpd/conf.d/(cobbler.conf & cobbler_web.conf) |
Xinetd | 2.3.15 | YUM | /etc/xinetd.conf |
TFTP | 5.2-22 | YUM | /etc/xinetd.d/tftp |
pykickstart | 1.99.66 | YUM |
#添加开机自启
[root@cobbler ~]# systemctl enable httpd.service cobblerd.service dhcpd.service tftp.socket
#开启服务
[root@cobbler ~]# systemctl start cobblerd.service httpd.service tftp.socket
#Cobbler相关文件
[root@cobbler ~]# rpm -ql 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日志
#tftp目录
[root@cobbler ~]# tree -L 1 /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
├── etc
├── grub
├── images
├── images2
├── ppc
├── pxelinux.cfg
└── s390x
执行cobbler check
命令检查存的问题,而后逐一按提示解决之。如果没有下面消息就再次重启cobbler
常见的问题如下所示:
[root@cobbler ~]# 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 : ksvalidator was not found, install pykickstart
8 : 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
9 : 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.
/etc/cobbler/settings
文件中的server
参数的值为提供cobbler
服务的主机相应的IP地址或主机名,如10.10.2.27;
2、修改/etc/cobbler/settings
文件中的next_server
参数的值为提供PXE服务的主机相应的IP地址,如172.16.100.16;
3、如果当前节点可以访问互联网,执行cobbler get-loaders
命令即可;否则,需要安装syslinux
程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}
等文件至/var/lib/cobbler/loaders/
目录中;
4、执行cobbler sync
把下载的文件同步到tftp的目录; 5、执行chkconfig rsync on
命令(可选);
6、执行openssl passwd -1 -salt $(openssl rand -hex 4)
生成密码,并用其替换/etc/cobbler/settings
文件中default_password_crypted
参数的值;
7、执行yum install cman fence-agents
命令安装相应的程序包即可(可选);
dhcp
的配置文件
#settings文件
manage_dhcp: 1
#dhcp.template文件
subnet 10.10.2.0 netmask 255.255.255.0 {
option routers 10.10.1.1;
option domain-name-servers 223.5.5.5;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.10.2.30 10.10.2.230;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}
/etc/cobbler/settings
文件中的manage_dhcp
为1
/etc/cobbler/dhcp.template
文件中的信息.cobbler sync
同步测试注意:开启tftp;
命令 | 说明 |
---|---|
cobbler check | 核对当前设置是否有问题 |
cobbler list | 列出所有的cobbler元素 |
cobbler report | 列出元素的详细信息 |
cobbler sync | 同步配置到数据目录,更改配置最好都执行一下 |
cobbler reposync | 同步yum仓库 |
cobbler distro | 查看导入的发行版系统信息 |
cobbler system | 查看添加的系统信息 |
cobbler profile | 查看配置信息 |
CentOS7.7
镜像:mount -t iso9660 -o loop /dev/sr1 /mnt/centos7
CentOS6.10
镜像:mount -t iso9660 -o loop /dev/sr0 /mnt/centos6
Centos6.10
:cobbler import --path=/mnt/centos6/ --name=CentOS-6.10-x86_64 --arch=x86_64
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:centos6.9,如果重复,系统会提示导入失败。
CentOS7.7
:cobbler import --path=/mnt/centos7/ --name=CentOS-7.7-x86_64 --arch=x86_64
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:centos6.9,如果重复,系统会提示导入失败。
list
[root@cobbler ~]# cobbler distro list
CentOS-6.10-x86_64
CentOS-7.7-x86_64
[root@cobbler ~]# cobbler distro report --name=CentOS-6.10-x86_64
Name : CentOS-6.10-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-6.10-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-6.10-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-6.10-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
[root@cobbler ks_mirror]# cobbler distro report --name=CentOS-7.7-x86_64
Name : CentOS-7.7-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-7.7-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-7.7-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.7-x86_64'}
Management Classes : []
OS Version : rhel7
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
profile
信息[root@cobbler ~]# cobbler profile report --name=CentOS-6.10-x86_64
Name : CentOS-6.10-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.10-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
[root@cobbler ks_mirror]# cobbler profile report --name=CentOS-7.7-x86_64
Name : CentOS-7.7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
CentOS6
:由于默认的ks文件不满足我们的安装需求,所以我们要使用自定义的ks文件,修改Kickstart文件如下:
#动态编辑指定使用新的kickstart文件
cobbler profile edit --name=CentOS-6.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.ks
#验证是否更改成功
[root@cobbler ~]# cobbler profile report --name=cobbler profile edit --name=CentOS-6.10-x86_64 | grep Kickstart
Kickstart : /var/lib/cobbler/kickstarts/centos6.ks
Kickstart Metadata : {}
CentOS7
:修改Kickstart文件:
#动态编辑指定使用新的kickstart文件
[root@cobbler ~]# cobbler profile edit --name=CentOS-7.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
#验证是否更改成功
[root@cobbler ks_mirror]# cobbler profile report --name=CentOS-7.7-x86_64 | grep Kickstart
Kickstart : /var/lib/cobbler/kickstarts/centos7.ks
Kickstart Metadata : {}
调整网卡内核参数(标准化,名称统一,关闭IPv6
[root@cobbler ~]# cobbler profile edit --name=CentOS-7.7-x86_64 --kopts='net.ifnames=0 biosdevname=0 noipv6'
[root@cobbler ~]# cobbler sync
[root@cobbler ~]# cobbler profile report
Name : CentOS-7.7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'noipv6': '~', 'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/centos7.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
Name : CentOS-6.10-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.10-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/centos6.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
web
界面有很多功能,包括上传镜像、编辑kickstart
、等等很多在命令行操作的都可以在web
界面直接操作。
在上面已经安装了cobbler-web
软件,访问地址:https://IP/cobbler_web 即可。默认账号为cobbler
,密码也为`cobbler
yum install cobbler-web -y
/etc/cobbler/users.conf #Web服务授权配置文件
/etc/cobbler/users.digest #用于web访问的用户名密码
[root@cobbler ~]# cat /etc/cobbler/users.digest
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
# 设置密码,在Cobbler组添加cobbler用户,输入2遍密码确
[root@cobbler ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password: superman
Re-type new password: superman
# 同步配置并重启httpd、cobbler
[root@cobbler ~]# cobbler sync
[root@cobbler ~]# systemctl restart httpd
[root@cobbler ~]# systemctl restart cobblerd
再次登录即使用新设置的密码登录即可。
版权所有: 原作者所有,此为原创文章禁止未经授权转载!
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。