Cobbler服务安装部署

1.安装epel源

yum -y install epel-release

2.安装cobbler环境所需的包

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

3.启动相关服务

systemctl start xinetd
systemctl start httpd
systemctl start cobblerd
systemctl enable xinetd
systemctl enable httpd
systemctl enable cobblerd

4.cobbler check检查和配置

cobbler check

(1)需要设置cobbler服务器IP地址

vim /etc/cobbler/settings
server: 172.25.25.12

(2)next-server地址

vim /etc/cobbler/settings
next_server: 172.25.25.12

(3)修改tftp配置,启用tftp

vim /etc/xinetd.d/tftp
disable no 

(4)下载一些boot-loaders

cobbler get-loaders

(5)启动rsyncd服务并设置开机启动

systemctl start rsync
systenctl enable rsync

(6)提示如果是deb系统需要安装debmirror,这里我们是centos,可以不做
(7)修改模板里的密码
第7步提示说默认模板里密码是cobbler,这样装出来的系统默认root密码就都是cobbler了,你需要自定义一个不一样的密码。通过openssl生成一个加密的密码
这里设置密码为123456 ,并用cobbler字符填充到加密后的字符串里
-1:用MD5基于BSD的密钥算法。
-salt string:用指定的字符串填充。当从终端读取一个密钥时,则填充它。
如下

openssl passwd -1 -salt 'cobbler' '123456'
$1$cobbler$sqDDOBeLKJVmxTCZr52/11

复制加密后的字符串到cobbler配置文件中替换原来的

vim /etc/cobbler/settings
default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"

5.重启cobblerd服务,看到配置已经完成了。下面1和2不用管

systemctl restart cobblerd
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.

6.配置cobbler管理dhcp
接下来设置dhcp,最好让cobler管理dhcp

vim /etc/cobbler/settings

这里改成1,这样cobbler才能管理dhcp配置文件

manage_dhcp: 1

修改dhcp模板文件,修改它之后,会自动生成dhcp的配置文件

vim /etc/cobbler/dhcp.template 

$next_server这里不用修改,它会调用cobbler配置文件中之前设置的next_server的地址
执行cobbler sync的时候,它会自动生成dhcp的配置,并自动帮你重启dhcp

systemctl restart cobblerd
cobbler sync

查看dhcp的配置文件,已经变化了

7.导入镜像到cobbler中

mount /dev/cdrom /mnt

导入镜像到cobbler中
先查看下cobbler默认存储系统的目录,现在是没有系统镜像的状态

ll /var/www/cobbler/ks_mirror/ 

从哪里导入,名称是什么,架构是什么

cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64

8.kickstart文件介绍

#Kickstart Configurator for cobbler by Jason Zhao
#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
#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 16384 --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=em1 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end

%post
systemctl disable postfix.service
%end

下面挑一些重点说明下

这个就是在cobbler里面设置的密码,就是那个openssl生成的密码,它会引用
#Root password
rootpw --iscrypted $default_password_crypted

url=$tree 它是cobbler内部的变量
#Use NFS installation Media
url --url=$tree

bootloader安装在mbr上
#System bootloader configuration
bootloader --location=mbr

磁盘分区信息
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
下面是一些要求安装的系统包
%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end

Cobbler 常用命令

cobbler check #检查cobbler配置
cobbler sync #同步配置到dhcp/pxe和数据目录
cobbler list #列出所有的cobbler元素
cobbler import #导入安装的系统镜像
cobbler report #列出各元素的详细信息
cobbler distro #查看导入的发行版系统信息
cobbler profile #查看配置信息
cobbler system #查看添加的系统信息
cobbler reposync #同步yum仓库到本地

查看当前配置信息

cobbler profile
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report

默认的ks文件位置,需要改成自己实际文件位置

Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks

把centos7的ks文件上传到下面目录下

/var/lib/cobbler/kickstarts/

更改centos7的ks文件位置

cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg

更改centos7的内核参数,让安装后网卡显示eth0
centos7 你想让网卡变成eth0 ,需要加内核参数
这里ks安装也需要加内核参数
通过看到有一行,关于设置内核参数的

cobbler profile report --name=CentOS-7-x86_64

这一行的是关于内核参数的配置

Kernel Options : {}

添加内核参数和查看

cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler profile report --name=CentOS-7-x86_64

同步更改后的配置信息

可以看到它删除了/var/www下面的一些文件,然后重新生成

cobbler sync

如果你修改文件不执行sync,修改是不生效的

附:使用koan重装系统
koan是kickstart-over-a-network的缩写,它是cobbler的客户端帮助程序,koan允许你通过网络提供虚拟机,也允许你重装已经存在的客户端。当运行时,koan会从远端的cobbler server获取安装信息,然后根据获取的安装信息进行安装。
1、在客户端安装koan

yum -y install epel-release
yum install -y koan

2、执行安装命令

koan --server=192.168.1.100 --list=profiles
centos-7-x86_64

3、在指定要重装的系统上执行要重装的哪个系统

koan --replace-self --server=192.168.1.100 --profile=centos-7-x86_64

4、然后重启就会自动安装新系统了

posted @   wanghongwei-dev  阅读(210)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
点击右上角即可分享
微信分享提示