cobbler服务部署

cobbler服务部署

一、关闭防火墙和selinux
[root@stw2 ~]# systemctl stop firewalld.service 
[root@stw2 ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@stw2 ~]# setenforce 0
[root@stw2 ~]# vim /etc/selinux/config 
[root@stw2 ~]# reboot
二、配置网络源和epel-release
[root@stw2 ~]# cd /etc/yum.repos.d/
[root@stw2 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@stw2 yum.repos.d]# rm -rf *
[root@stw2 yum.repos.d]# ls
[root@stw2 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2025-08-20 16:20:34--  https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 171.43.166.208, 171.43.166.202, 171.43.166.205
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|171.43.166.208|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[======================================================>] 2,523       --.-K/s   in 0s      

2025-08-20 16:20:35 (180 MB/s) -/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

[root@stw2 yum.repos.d]# yum -y install epel-release
三、安装cobbler以及相关的软件
[root@stw2 ~]# yum -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync rsync-daemon
四、启动服务并设置开机自启
[root@stw2 ~]# systemctl restart httpd;systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@stw2 ~]# systemctl restart rsyncd;systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@stw2 ~]# systemctl restart tftp;systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@stw2 ~]# systemctl restart cobblerd;systemctl enable cobblerd
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
五、修改server

修改server的ip地址为本机ip(server)

设置tftp的ip地址为本机ip(next_server)

[root@stw2 ~]# cd /etc/cobbler/
[root@stw2 cobbler]# ls
auth.conf         genders.template        named.template  secondary.template  zone.template
cheetah_macros    import_rsync_whitelist  power           settings            zone_templates
cobbler_bash      iso                     pxe             tftpd.template
completions       ldap                    reporting       users.conf
dhcp.template     modules.conf            rsync.exclude   users.digest
dnsmasq.template  mongodb.conf            rsync.template  version
[root@stw2 cobbler]# vim settings 

在这里插入图片描述

在这里插入图片描述

六、生成加密的密码,并将新生成的加密密码替换到配置文件当中
[root@stw2 cobbler]# openssl passwd -1 -salt "$RANDOM" 'redhat'
$1$30749$9hSe7Jqq0HiJsO7iePvIy0
[root@stw2 cobbler]# vim settings 

在这里插入图片描述

七、将cobbler的dhcp功能打开

在这里插入图片描述

重启cobbler,并通过cobbler check 核对当前设置是否有问题
[root@stw2 cobbler]# systemctl restart cobblerd
[root@stw2 cobbler]# cobbler check
The following are potential configuration items that you may want to fix:

1 : change 'disable' to 'no' in /etc/xinetd.d/tftp
2 : Some network boot-loaders are missing from /var/lib/cobbler/loaders.  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.
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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
[root@stw2 cobbler]# vim /etc/xinetd.d/tftp 
[root@stw2 cobbler]# systemctl restart tftp
[root@stw2 cobbler]# cobbler check
The following are potential configuration items that you may want to fix:

1 : Some network boot-loaders are missing from /var/lib/cobbler/loaders.  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.
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : 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.

在这里插入图片描述

解决问题2
[root@stw2 ~]# yum -y install syslinux*
[root@stw2 ~]# cd /usr/share/syslinux/
[root@stw2 syslinux]# ls
altmbr.bin     dmitest.c32   host.c32        isolinux-debug.bin  menu.c32      syslinux64.exe
altmbr_c.bin   dosutil       ifcpu64.c32     kbdmap.c32          pcitest.c32   syslinux.com
altmbr_f.bin   elf.c32       ifcpu.c32       linux.c32           pmload.c32    syslinux.exe
cat.c32        ethersel.c32  ifplop.c32      ls.c32              poweroff.com  ver.com
chain.c32      gfxboot.c32   int18.com       lua.c32             pwd.c32       vesainfo.c32
cmd.c32        gptmbr.bin    isohdpfx.bin    mboot.c32           pxechain.com  vesamenu.c32
com32          gptmbr_c.bin  isohdpfx_c.bin  mbr.bin             pxelinux.0    vpdtest.c32
config.c32     gptmbr_f.bin  isohdpfx_f.bin  mbr_c.bin           reboot.c32    whichsys.c32
cpuid.c32      gpxecmd.c32   isohdppx.bin    mbr_f.bin           rosh.c32      zzjson.c32
cpuidtest.c32  gpxelinux.0   isohdppx_c.bin  memdisk             sanboot.c32
diag           gpxelinuxk.0  isohdppx_f.bin  memdump.com         sdi.c32
disk.c32       hdt.c32       isolinux.bin    meminfo.c32         sysdump.c32
[root@stw2 syslinux]# ls pxelinux.0 
pxelinux.0
[root@stw2 syslinux]# ls menu.c32 
menu.c32
[root@stw2 syslinux]# cd /var/lib/cobbler/loaders/
[root@stw2 loaders]# ls
[root@stw2 loaders]# cd -
/usr/share/syslinux
[root@stw2 syslinux]# cp pxelinux.0 /var/lib/cobbler/loaders/
[root@stw2 syslinux]# cp menu.c32 /var/lib/cobbler/loaders/
[root@stw2 syslinux]# cd -
/var/lib/cobbler/loaders
[root@stw2 loaders]# ls
menu.c32  pxelinux.0
解决问题3
[root@stw2 ~]# yum -y install yum-utils

再次检查还是会显示问题,但不用管,是正常的

八、配置DHCP模板文件,并同步cobbler配置
[root@stw2 ~]# vim /etc/cobbler/dhcp.template 
[root@stw2 ~]# systemctl restart httpd cobblerd
[root@stw2 ~]# cobbler sync
......
*** TASK COMPLETE ***

在这里插入图片描述

九、挂载镜像、并导入镜像
[root@stw2 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@stw2 ~]# cobbler import --path=/mnt --name=CenOS-7 arch=x86_64
task started: 2025-08-20_182221_import
task started (id=Media import, time=Wed Aug 20 18:22:21 2025)
......
*** TASK COMPLETE ***
十、查看
[root@stw2 ~]# cobbler list
distros:
   CenOS-7-x86_64

profiles:
   CenOS-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
[root@stw2 ~]# cobbler distro report --name CenOS-7-x86_64
Name                           : CenOS-7-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/CenOS-7/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/CenOS-7/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/CenOS-7-x86_64'}
Management Classes             : []
OS Version                     : rhel6
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}
十一、新建一台虚拟机用于测试

在这里插入图片描述

在这里插入图片描述

不用导入镜像直接开机

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值