cobbler

本文详细介绍了如何使用Cobbler进行服务器部署,包括安装、配置、添加镜像、设置网络、创建和管理profile以及自定义仓库。步骤涵盖了从安装Cobbler到配置Kickstart文件,自动安装系统和同步仓库的全过程。

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

安装

yum install cobbler cobbler-web pykickstart httpd dhcp tftp xinetd -y

启动httpd和cobbler

systemctl start cobblerd.service
systemctl start httpd.service 

启用动态配置

sed -ri '/allow_dynamic_settings:/c \allow_dynamic_settings: 1' /etc/cobbler/settings
systemctl restart cobblerd.service
cobbler check

设置cobbler地址

cobbler setting edit --name=server --value=10.0.0.61

设置tftp地址

cobbler setting edit --name=next_server --value=10.0.0.61

xinetd管理tftp

sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
systemctl enable xinetd
systemctl start xinetd
systemctl enable rsyncd.service
systemctl start rsyncd.service
cobbler get-loaders

生成密码

openssl passwd -1 -salt 'cobbler' 'Bgx123.com'
$1$cobbler$RTWR1S/XXjsj9af1IZGi/.

设置root密码

cobbler setting edit --name=default_password_crypted --value='$1$cobbler$RTWR1S/XXjsj9af1IZGi/.'

可选

yum -y install cman fence-agents
yum -y install debmirror

可选

sed -ri '/@dists=/c#@dists="sid";' /etc/debmirror.conf
sed -ri '/@arches=/c#@arches="i386";' /etc/debmirror.conf

设置cobbler管理dhcp

cobbler setting edit --name=manage_dhcp --value=1

vim /etc/cobbler/dhcp.template

...
subnet 10.0.0.0 netmask 255.255.255.0 {
     option routers             10.0.0.254;
     option domain-name-servers 10.0.0.254;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.0.0.100 10.0.0.200;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
...
cobbler check
systemctl restart xinetd
systemctl restart cobblerd.service
cobbler sync

组件的继承关系:distro -----> profile -----> system 即配置后一个,均需要指定前一个组件名

发行版(distro)

导入镜像(创建发行版)

mount /dev/cdrom /mnt/
cobbler import --path=/mnt/ --name=centos7u5 --arch=x86_64

查看发行版

cobbler distro list
centos7u5-x86_64
cobbler distro report --name=centos7u5-x86_64

profile

添加profile

cobbler profile add \
--name=centos7u5-web \
--distro=centos7u5-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/centos7.cfg \
--kopts='net.ifnames=0 biosdevname=0'

修改profile

cobbler profile edit \
--name=centos7u5-web \
--kopts='net.ifnames=0 biosdevname=0'

查看profile

cobbler profile list
centos7u5-x86_64
cobbler profile report --name=centos7u5-x86_64

删除profile

cobbler profile remove --name="centos7u5-x86_64"

ks文件

/var/lib/cobbler/kickstarts/centos7.cfg

#CentOS7
#Kickstart Configurator by xuliangwei
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr --append="net.ifnames=0 biosdevname=0"
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --size 1024 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

#Package install information
%packages
@base
@core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
tree
nmap
screen
wget
%end

%post


systemctl disable postfix.service

# Firewalld
systemctl disable firewalld.service
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config

# SSH Config
sed -ri '/#UseDNS/cUseDNS no' /etc/ssh/sshd_config
systemctl restart sshd

%end

vim /var/lib/cobbler/kickstarts/centos6.cfg

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
#Partition information
part /boot --fstype ext4 --size 1024 --ondisk sda
part swap --size=1500
part / --fstype ext4 --size 1 --grow --ondisk sda

# Use text mode install
text
# Firewall configuration
firewall --disable
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
#network --bootproto=dhcp   --device=em1
# Reboot after installation
reboot
 
#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone   Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
  
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
  
%post

%end
yum install system-config-kickstart

profile组件将kickstart文件和distros文件关联起来,构建自动化的整体配置信息,提供系统的初始化安装信息

cobbler profile add \
--name=centos7u5-web \
--distro=centos7u5-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
cobbler profile add --name=centos6u9-db \
--distro=centos6u9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.cfg

system

添加system

cobbler system add --name=httpd-node1 \
--mac=00:50:56:30:6A:10 \
--profile=centos7u5-web \
--ip-address=10.0.0.150 \
--subnet=255.255.255.0 \
--gateway=10.0.0.254 \
--interface=eth0 \
--static=1 \
--hostname=httpd-node1 \
--name-servers="10.0.0.254"

重装系统

客户端安装koan

yum install -y koan

查看

koan --server=10.0.0.61 --list=profiles

重装系统执行

koan --replace-self --server=10.0.0.61 --profile=centos7u5-web

重启之后重装系统


cobbler自定义仓库(添加repo)

cobbler repo add --name="zabbix35-centos7" --mirror=https://mirrors.aliyun.com/zabbix/zabbix/3.5/rhel/7/x86_64/

同步

cobbler reposync
echo "00 3 * * * /usr/bin/cobbler reposync --tries=3 --no-fail" >> /var/spool/cron/root

编辑profile指定repo

cobbler profile edit --name="centos7u5-web" --repos="zabbix35-centos7"

/var/lib/cobbler/kickstarts/centos7.cfg

#%post之后添加
...
%post
$yum_config_stanza
...

客户端安装后repo文件

cobbler-config.repo

[core-0]
name=core-0
baseurl=http://10.0.0.61/cobbler/ks_mirror/centos7u5-x86_64
enabled=1
gpgcheck=0
priority=1
[zabbix35-centos7]
name=zabbix35-centos7
baseurl=http://10.0.0.61/cobbler/repo_mirror/zabbix35-centos7
enabled=1
priority=99
gpgcheck=0

cobbler自定义安装

00:50:56:30:6A:10

system组件来配置网络接口

cobbler system add --name=httpd-node1 \
--mac=00:50:56:30:6A:10 \
--profile=centos7u5-web \
--ip-address=10.0.0.150 \
--subnet=255.255.255.0 \
--gateway=10.0.0.254 \
--interface=eth0 \
--static=1 \
--hostname=httpd-node1 \
--name-servers="10.0.0.254"
cobbler profile edit --name=centos7u5-web --kopts='net.ifnames=0 biosdevname=0'

#总结

mount /dev/cdrom /mnt/

导入镜像

cobbler import --path=/mnt/ --name=centos7u5 --arch=x86_64
 cobbler distro list
   centos7u5-x86_64
cobbler profile add \
--name=centos7u5-web \
--distro=centos7u5-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/centos7.cfg \
--kopts='net.ifnames=0 biosdevname=0'

修改

cobbler profile edit \
--name=centos7u5-web \
--kopts='net.ifnames=0 biosdevname=0'
cobbler profile list
   centos7u5-web
cobbler system add --name=httpd-node1 \
--mac=00:50:56:30:6A:10 \
--profile=centos7u5-web \
--ip-address=10.0.0.150 \
--subnet=255.255.255.0 \
--gateway=10.0.0.254 \
--interface=eth0 \
--static=1 \
--hostname=httpd-node1 \
--name-servers="10.0.0.254"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuxingge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值