cobbler

本文详细介绍了Cobbler的配置和使用过程,包括服务集成、配置文件详解、命令操作、服务端部署、客户端安装及定制化安装。Cobbler集成了PXE、DHCP、DNS、电源管理等服务,支持自动化Linux网络安装,简化系统部署流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Cobbler简介:Cobbler 可以用来快速建立 Linux 网络安装环境,

cobbler集成的服务

  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

cobbler配置文件详解
cobbler配置文件目录在/etc/cobbler

配置文件作用
/etc/cobbler/settingscobbler 主配置文件
/etc/cobbler/iso/iso模板配置文件
/etc/cobbler/pxepxe模板配置文件
/etc/cobbler/power电源配置文件
/etc/cobbler/user.confweb服务授权配置文件
/etc/cobbler/users.digestweb访问的用户名密码配置文件
/etc/cobbler/dhcp.templatedhcp服务器的的配置模板
/etc/cobbler/dnsmasq.templatedns服务器的配置模板
/etc/cobbler/tftpd.templatetftp服务的配置模板
/etc/cobbler/modules.conf模块的配置文件

cobbler数据目录

目录作用
/var/lib/cobbler/config/用于存放distros,system,profiles等信息配置文件
/var/lib/cobbler/triggers/用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/默认存放kickstart文件
/var/lib/cobbler/loaders/存放各种引导程序以及镜像目录
/var/www/cobbler/ks_mirror/导入的发行版系统的所有数据
/var/www/cobbler/images/导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/yum仓库存储目录

cobbler日志文件

日志文件路径说明
/var/log/cobbler/installing客户端安装日志
/var/log/cobbler/cobbler.logcobbler日志

cobbler命令详解

cobbler check       //核对当前设置是否有问题
cobbler list        //列出所有的cobbler元素
cobbler report      //列出元素的详细信息
cobbler sync        //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync    //同步yum仓库
cobbler distro      //查看导入的发行版系统信息
cobbler system      //查看添加的系统信息
cobbler profile     //查看配置信息

cobbler服务端部署

//配置yum源
[root@cobbler ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@cobbler ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]#  yum -y install epel-release


//安装cobbler以及相关的软件
[root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler  xinetd cobbler-web pykickstart


//启动服务并设置开机自启
[root@localhost ~]# systemctl enable --now httpd cobblerd 
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
//修改server的ip地址为本机ip
[root@localhost ~]# vim /etc/cobbler/settings 
server: 192.168.236.141

//设置tftp的ip地址为本机ip
[root@localhost ~]# vim /etc/cobbler/settings 
next_server: 192.168.236.141
//开启tftp
[root@localhost ~]# vim /etc/xinetd.d/tftp 
 disable  = no



关闭防火墙和seliunx
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config

//下载缺失文件
[root@localhost ~]# cobbler get-loaders




[root@localhost ~]# openssl passwd -1 -salt "$RANDOM" '123123'
$1$18320$vqTHcVGAViUy092JSxxfc/



//启动rsync并设置开机自启
[root@localhost ~]# systemctl start rsyncd
[root@localhost ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

//将新生成的加密密码加入到配置文件
[root@localhost ~]# vim /etc/cobbler/settings 
default_password_crypted: "$1$25656$oih3qq3LAdw9vMy/8eLkW0"

//重启cobble
[root@localhost ~]# systemctl  restart cobblerd

//通过cobbler check 核对当前设置是否有问题
[root@localhost ~]# 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.
//以上两个是关于debian系统的错误,请忽略
//配置cobbler dhcp
//修改cobbler配置文件,让cobbler控制dhcp
[root@localhost ~]# vim /etc/cobbler/settings
manage_dhcp: 1

//配置dhcp
[root@localhost ~]# vim /etc/cobbler/dhcp.templat
subnet 192.168.236.0 netmask 255.255.255.0 {
     option routers             192.168.236.141;  //此处为系统安装好后指定的dns地址
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.236.10 192.168.236.25;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;


//重启服务并同步配置,改完dhcp必须要sync同步配置
[root@localhost ~]# systemctl  restart cobblerd
[root@localhost ~]# cobbler sync



//检查dhcp是否正常
[root@localhost ~]# ss -antulp|grep 67
udp    UNCONN     0      0         *:67                    *:*                   users:(("dhcpd",pid=1811,fd=7))

//导入redhat7镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cobbler profile edit --name centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7-x86_64.ks

//说明:
    --path      //镜像路径
    --name      //为安装源定义一个名字
    --arch      //指定安装源平台

//查看cobbler镜像列表
[root@localhost ~]# cobbler list
distros:
   centos-7-x86_64

profiles:
   centos-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
//创建kickstarts自动安装脚本
[root@localhost ~]# cat > /var/lib/cobbler/kickstarts/centos-7-x86_64.ks <<'EOF'
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.236.141/cobbler/ks_mirror/centos-7-x86_64
$yum_repo_stanza
reboot

rootpw --iscrypted $6$2WTFvfNvAMgCUPuC$MJgWGzhakgxrRObcEbAwSe8vkz0s//xyiTllGwxRsHHruQhcskO69u2LVTU9u0eemHXH2pzcGawyAJ54R2E/x0

selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr

%packages
@^minimal
@core
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
EOF

//检查ks文件语法是否有误
[root@localhost ~]# cobbler validateks
//查看当前cobbler有哪些配置文件
[root@localhost ~]# cobbler profile list
   centos-7-x86_64




//修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@localhost ~]#  cobbler profile edit --name centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7-x86_64.ks


//配置网卡名称为传统网卡名称eth0
[root@localhost ~]# cobbler profile edit --name centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'



//检查当前系统cobbler配置文件信息
[root@localhost ~]# cobbler profile report
Name                           : centos-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-7-x86_64     //仓库名字
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'}    //网卡设为传统命名
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos-7-x86_64.ks   //使用的kicksta
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



//同步cobbler
[root@localhost ~]# cobbler sync



//为避免发生未知问题,先把服务端所有服务重启
[root@localhost ~]# systemctl restart xinetd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart httpd

客户端安装
新建虚拟机从pxe启动,若出现以下界面则表示成功:
在这里插入图片描述

定制安装

定制安装步骤:
统计服务器mac地址
配置cobbler
安装
统计mac地址此处就不赘述了,直接最重要的配置
在 cobbler 的web界面上配置:

https://192.168.236.141/cobbler_web
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
同步配置并重启相关服务:

[root@localhost ~]# cobbler sync
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart xinetd

最后开机自动会安装系统

[root@localhost ~]# cd /var/lib/cobbler/config/packages.d/
//脚本
[root@localhost systems.d]# cat vm5.json
#!/bin/bash
cat> /var/lib/cobbler/config/systems.d/vm8.json <<EOF
{
"comment":"",
"status":"production",
"kickstart":"/var/lib/cobbler/kickstarts/centos-7-x86_64.ks",
"name_servers_search":[
],
"ks_meta":{
},
"kernel_options_post":{
"biosdevname":"0",
"net.ifnames":"0"
},
"image":"",
"redhat_management_key":"<<inherit>>",
"virt_path":"<<inherit>>",
"power_user":"",
"kernel_options":{
},
"ctime":1606202655.916096,
"name_servers":[
"114.114.114.114"
],
"mtime":1606203514.751194,
"enable_gpxe":false,
"template_files":{
},
"gateway":"192.168.236.2",
"uid":"MTYwNjIwMjY1NS45MzQwODY5NS4yNjg2NA",
"virt_auto_boot":0,
"power_type":"ipmitool",
"virt_cpus":"<<inherit>>",
"mgmt_parameters":"<<inherit>>",
"boot_files":{
},
"hostname":"node9.example.com",
"repos_enabled":false,
"mgmt_classes":[
],
"power_pass":"",
"netboot_enabled":true,
"ipv6_autoconfiguration":false,
"profile":"centos-7-x86_64",
"virt_type":"xenpv",
"interfaces":{
"eth0":{
"ipv6_address":"",
"interface_type":"",
"static":true,
"cnames":[
],
"bridge_opts":"",
"management":false,
"interface_master":"",
"mac_address":"00:50:56:2F:52:DC",
"ipv6_prefix":"",
"virt_bridge":"xenbr0",
"netmask":"255.255.255.0",
"bonding_opts":"",
"ip_address":"192.168.236.252",
"dhcp_tag":"",
"ipv6_mtu":"",
"static_routes":[
],
"ipv6_static_routes":[
],
"if_gateway":"",
"dns_name":"",
"mtu":"",
"connected_mode":false,
"ipv6_secondaries":[
],
"ipv6_default_gateway":""
}
},
"power_address":"",
"proxy":"<<inherit>>",
"fetchable_files":{
},
"virt_file_size":"<<inherit>>",
"ldap_enabled":false,
"monit_enabled":false,
"ipv6_default_device":"",
"virt_pxe_boot":0,
"virt_disk_driver":"<<inherit>>",
"owners":"<<inherit>>",
"name":"vm8",
"virt_ram":"<<inherit>>",
"power_id":"",
"server":"<<inherit>>",
"redhat_management_server":"<<inherit>>",
"depth":2,
"ldap_type":"authconfig",
"template_remote_kickstarts":0
}
 
{
"comment":"",
"status":"production",
"kickstart":"/var/lib/cobbler/kickstarts/centos-7-x86_64.ks",
"name_servers_search":{
},
"ks_meta":{
},
"kernel_options_post":{
"biosdevname":"0",
"net.ifnames":"0"
},
"image":"",
"redhat_management_key":"<<inherit>>",
"virt_path":"<<inherit>>",
"power_user":"",
"kernel_options":{
},
"ctime":1606202655.916096,
"name_servers":[
"114.114.114.114"
],
"mtime":1606203514.751194,
"enable_gpxe":false,
"template_files":{
},
"gateway":"192.168.236.2",
"uid":"MTYwNjIwMjY1NS45MzQwODY5NS4yNjg2NA",
"virt_auto_boot":0,
"power_type":"ipmitool",
"virt_cpus":"<<inherit>>",
"mgmt_parameters":"<<inherit>>",
"boot_files":{
},
"hostname":"node9.example.com",
"repos_enabled":false,
"mgmt_classes":{
},
"power_pass":"",
"netboot_enabled":true,
"ipv6_autoconfiguration":false,
"profile":"centos-7-x86_64",
"virt_type":"xenpv",
"interfaces":{
"eth0":{
"ipv6_address":"",
"interface_type":"",
"static":true,
"cnames":{
},
"bridge_opts":"",
"management":false,
"interface_master":"",
"mac_address":"00:50:56:2F:52:DC",
"ipv6_prefix":"",
"virt_bridge":"xenbr0",
"netmask":"255.255.255.0",
"bonding_opts":"",
"ip_address":"192.168.236.252",
"dhcp_tag":"",
"ipv6_mtu":"",
"static_routes":{
},
"ipv6_static_routes":{
},
"if_gateway":"",
"dns_name":"",
"mtu":"",
"connected_mode":false,
"ipv6_secondaries":{
},
"ipv6_default_gateway":""
}
},
"power_address":"",
"proxy":"<<inherit>>",
"fetchable_files":{
},
"virt_file_size":"<<inherit>>",
"ldap_enabled":false,
"monit_enabled":false,
"ipv6_default_device":"",
"virt_pxe_boot":0,
"virt_disk_driver":"<<inherit>>",
"owners":"<<inherit>>",
"name":"vm8",
"virt_ram":"<<inherit>>",
"power_id":"",
"server":"<<inherit>>",
"redhat_management_server":"<<inherit>>",
"depth":2,
"ldap_type":"authconfig",
"template_remote_kickstarts":0
}
EOF

//执行脚本
[root@localhost scripts]# bash create_cobbler_system.sh 
[root@localhost systems.d]# systemctl restart cobblerd
[root@localhost systems.d]# cobbler sync

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值