# cobbler是基于pxe(dhcpclient,tdtp-client)网卡-现代网卡都是pxe的 跟着cobbler check即可
根绝cobbbler check提示,做完一个之后,先重启紧接着就cobbler sync # 准备
防火墙和selinux关闭
dhcp服务器设置为静态ip
虚拟机:勾选不分配ip并基于nat模式
1.安装相关包并启动服务
# 安装cobbler自动把依赖包httpd,tftp,syslinux-nonlinux装好
[root@centos7 ~]#yum install cobbler dhcp
[root@centos7 ~]#systemctl enable --now cobblerd httpd tftp dhcpd
# dhcp起不起来,因为没有配置
2.修改cobbler配置文件
[root@centos7 ~]#vim /etc/cobbler/settings
default_password_crypted: "$1$gEc7ilpP$pg5iSOj/mlxTxEslhRvyp/"
# 这个密码通过open-ssl passwd -1 可以生成md5加密的
next_server:< tftp服务器的 IP 地址>
server:<cobbler服务器的 IP 地址>
manage_dhcp:1 #设置为1,表示通过cobbler生成dhcpd.conf配置文件
pxe_just_once: 1 避免客户机pxe处于第一位导致循环重启
[root@centos7 ~]#systemctl restart cobblerd
[root@centos7 ~]#cobbler sync
3.准备启动相关文件
[root@centos7 ~]#cobbler get-loaders
[root@centos7 ~]#ls /var/lib/cobbler/loaders
[root@centos7 ~]#cobbler sync
# cobbler sync相当于同步功能
[root@centos7 ~]#tree /var/lib/tftpboot/
4.配置dhcp服务
#修改dhcp的模版文件下面的行,用来生成dhcp的配置文件
[root@centos7 ~]#vim /etc/cobbler/dhcp.template
subnet 192.168.100.0 netmask 255.255.255.0 {
option routers 192.168.100.1;
option domain-name-servers 180.76.76.76,223.6.6.6;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.100.1 192.168.100.200;
[root@centos7 ~]#cobbler sync
[root@centos7 ~]#systemctl start dhcpd
# 上面的做完了,前期准备就可以了,剩下的就是根据菜单准备对应资源了,应答文件以及内核和虚拟文件系统
5.修改菜单标题信息
[root@centos7 ~]#vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | qq 3555409634
[root@centos7 ~]#cobbler sync
[root@centos7 ~]#cat /var/lib/tftpboot/pxelinux.cfg/default
6.导入centos系统镜像,生成对应的虚拟文件系统和内核,以及作为网络源
[root@centos7 ~]#mount /dev/sr1 /mnt
# 注意arch前面有两个--
[root@centos7 ~]#cobbler import --name=centos-8.1-x86_64 --path=/misc/cd --arch=x86_64
[root@centos7 ~]#du -sh /var/www/cobbler/ks_mirror/*
[root@centos7 ~]#cobbler distro list
[root@centos7 ~]#cobbler profile list
默认的是生成最小化安装的应答文件
7.准备kickstart应答文件,并关联
[root@centos7 ~]#vim /var/lib/cobbler/kickstarts/ks8.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$JIlSYIZK$FVaVwy7R5OOumizjIjgH8/
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url=$tree #注意此行必须指定
# System bootloader configuration
bootloader --append="net.ifnames=0" --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=1024
part / --fstype="xfs" --size=10000
part swap --fstype="swap" --size=2000
%post
# [user]
useradd wangjian
echo 199712 | passwd --stdin wangjian
# [yum]
mkdir /etc/yum.repos.d/bakeup
mv /etc/yum.repos.d/*.repo /etc/yum/repos.d/backup
echo '
[AppStream]
name=centos-8-AppStream
baseurl=https://mirrors.aliyun.com/centos/8.1.1911/AppStream/x86_64/os/
gpgcheck=0
[base]
name=centos-8-Base
baseurl=https://mirrors.aliyun.com/centos/8.1.1911/BaseOS/x86_64/os/
gpgcheck=0
[epel]
name=CentOS-$releasever-epel
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0
[extras]
name=CentOS-8-extra
baseurl=https://mirrors.aliyun.com/centos/8.1.1911/extras/x86_64/os/
gpgcheck=0
' > /etc/yum.repos.d/al_8.repo
yum clean all
yum makecache
# [keygen]
%end
%packages
gcc
make
gcc-c++
glibc
glibc-devel
pcre
pcre-devel
openssl
openssl-devel
systemd-devel
zlib-devel
vim
lrzsz
tree
lsof
tcpdump
wget
net-tools
iotop
bc
bzip2
zip
unzip
nfs-utils
man-pages
bash-completion
%end
#将kickstart文件,关联指定的YUM源和生成菜单列表
[root@centos7 ~]#cobbler profile add --name=CentOS-8.1_test --distro=CentOS-8.1-
x86_64 --kickstart= /var/lib/cobbler/kickstarts/centos8.cfg
8.删除默认的菜单列表
#删除默认的菜单列表
[root@centos7 ~]#cobbler profile remove --name=CentOS8.0-x86_64
###补充:ks{6,7}.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$JIlSYIZK$FVaVwy7R5OOumizjIjgH8/
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url=$tree
# System bootloader configuration
bootloader --append="net.ifnames=0" --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="ext4" --size=1024
part / --fstype="ext4" --size=10000
part swap --fstype="swap" --size=2000
%post
# [user]
useradd wangjian
echo 199712 | passwd --stdin wangjian
# [yum]
mkdir /etc/yum.repos.d/bakeup
mv /etc/yum.repos.d/*.repo /etc/yum/repos.d/backup
echo '
[base]
name=centos-6-Base
baseurl=https://mirrors.aliyun.com/centos/6.10/os/x86_64/
gpgcheck=0
[epel]
name=CentOS-6-epel
baseurl=https://mirrors.aliyun.com/epel/6/x86_64/
gpgcheck=0
[update]
name=CentOS-6-update
baseurl=https://mirrors.aliyun.com/centos/6.10/updates/x86_64/
gpgcheck=0
[extras]
name=CentOS-6-extra
baseurl=https://mirrors.aliyun.com/centos/6.10/extras/x86_64/
gpgcheck=0
'>/etc/yum.repos.d/al_6.repo
yum clean all
yum makecache
# [keygen]
%end
%packages
%end
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$JIlSYIZK$FVaVwy7R5OOumizjIjgH8/
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url=$tree
# System bootloader configuration
bootloader --append="net.ifnames=0" --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=1024
part / --fstype="xfs" --size=10000
part swap --fstype="swap" --size=2000
%post
# [user]
useradd wangjian
echo 199712 | passwd --stdin wangjian
# [yum]
mkdir /etc/yum.repos.d/bakeup
mv /etc/yum.repos.d/*.repo /etc/yum/repos.d/backup
echo '
[AppStream]
name=centos-8-AppStream
baseurl=https://mirrors.aliyun.com/centos/8.1.1911/AppStream/x86_64/os/
gpgcheck=0
[base]
name=centos-8-Base
baseurl=https://mirrors.aliyun.com/centos/8.1.1911/BaseOS/x86_64/os/
gpgcheck=0
[epel]
name=CentOS-$releasever-epel
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0
[extras]
name=CentOS-8-extra
baseurl=https://mirrors.aliyun.com/centos/8.1.1911/extras/x86_64/os/
gpgcheck=0
' > /etc/yum.repos.d/al_8.repo
yum clean all
yum makecache
# [keygen]
%end
%packages
gcc
make
gcc-c++
glibc
glibc-devel
pcre
pcre-devel
openssl
openssl-devel
systemd-devel
zlib-devel
vim
lrzsz
tree
lsof
tcpdump
wget
net-tools
iotop
bc
bzip2
zip
unzip
nfs-utils
man-pages
bash-completion
%end