由于在centos8上面现在还没有cobbler包,所以部署就在centos7上面进行部署
DHCP服务器: centos7 192.168.32.7
TFTP服务器: centos7 192.168.32.7
HTTP服务器: centos7 192.168.32.7
COBBLER服务器 centos7 192.168.32.7
关闭防火墙和selinux
查看防火墙和selinux状态
[root@centos7 ~]#firewall-cmd --state
not running
[root@centos7 ~]#getenforce
Disabled
安装需要的安装包 epel源和cobbler ,DHCP
[root@centos7 ~]#yum install epel-release
[root@centos7 ~]#yum install cobbler dhcp -y
[root@centos7 ~]#rpm -ql cobbler 查看包信息
重启服务,设置为开机启动
在这里DHCP是起不来的,因为还没有配置对应的DHCP配置文件。其他服务都起来了
可以通过查看端口是否打开,确定服务是否起来
69 tftp
80 http
67 没有 对应dhcp
25151 对应 cobbler端口
现在可以执行cobbler的 cobbler check 命令
[root@centos7 ~]#cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting
features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all
machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other
than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
#centos6 自动化安装的时候需要配置选项
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to
download them, or, 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. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : enable and start rsyncd.service with systemctl
# debian 系列 ,这里不用配置
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
# debian 系列 ,这里不用配置
7 : The default password used by the sample templates for newly installed machines (default_password_crypted
in /etc/cobbler/settings) is still set to 'cobbler' and should be changed,
try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
8 : fencing tools were not found, and are required to use the (optional) power management features.
install cman or fence-agents to use them
#这项已经快淘汰,不用配置
在这里只需要修改配置文件1 2 4 7
针对问题1 ,修改/etc/cobbler/settings文件中的server选项
表示cobbler服务器的地址
针对问题2,修改/etc/cobbler/settings文件中的next_server选项
针对的是DHCP的地址,这里我们指向centos7
针对问题3,是centos6上面的内容启动http的服务。这里我们http服务(69端口)已经启动
针对问题4,根据提示,直接执行 cobbler get-loaders 就ok 会自动去外网下载相关内容
下载好之后并不在同一个目录里面,所以我们还需要运行一下同步命令 cobbler sync
[root@centos7 ~]#cobbler get-loaders
task started: 2019-11-14_173407_get_loaders
task started (id=Download Bootloader Content, time=Thu Nov 14 17:34:07 2019)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
[root@centos7 ~]#cobbler sync
task started: 2019-11-14_173516_sync
task started (id=Sync, time=Thu Nov 14 17:35:16 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
针对问题4和5 可以直接跳过
针对问题六是是否修改口令问题
不改则默认是cobbler
这里利用centos8 生成一个-512的口令
[root@centos7 ~]#vim /etc/cobbler/settings
这里我们配置为自动获取
[root@centos7 ~]#vim /etc/cobbler/settings
[root@centos7 ~]#vim /etc/cobbler/dhcp.template
这里需要重启服务,然后同步。可以看到dhcp配置文件的大小变成了1580,说明已经同步生成了配置文件
[root@centos7 ~]#systemctl restart cobblerd
[root@centos7 ~]#cobbler sync
[root@centos7 ~]#ll /etc/dhcp/dhcpd.conf
-rw-r--r-- 1 root root 1580 Nov 14 17:48 /etc/dhcp/dhcpd.conf
[root@centos7 ~]#systemctl start dhcpd
开启dhcp服务
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 3G 0 part [SWAP]
sr0 11:0 1 10G 0 rom
[root@centos7 ~]#echo '- - -' > /sys/class/scsi_host/host
host0/ host1/ host2/
[root@centos7 ~]#echo '- - -' > /sys/class/scsi_host/host0/scan
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 3G 0 part [SWAP]
sr0 11:0 1 10G 0 rom
sr1 11:1 1 6.7G 0 rom
挂载光盘
[root@centos7 ~]#mount /dev/sr1 /mnt/
mount: /dev/sr1 is write-protected, mounting read-only
现在需要导入光盘成为cobbler的yum源(就是复制的过程)
[root@centos7 ~]#cobbler import --name=CentOS_8.0_KAI --path=/mnt/ --arch=x86_64
#--name 起个系统的名字 --path 指定光盘路径 --arch 指定安装系统的架构
task started: 2019-11-14_180256_import
task started (id=Media import, time=Thu Nov 14 18:02:56 2019)
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64:
creating new distro: CentOS_8.0_KAI-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64 -> /var/www/cobbler/links/CentOS_8.0_KAI-x86_64
creating new profile: CentOS_8.0_KAI-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64 for CentOS_8.0_KAI-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/AppStream
looking for /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/BaseOS
looking for /var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS_8.0_KAI-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
复制的过程是在/var/www/cobbler/目录中,可以看到目录的大小不断的变大,说明在正常复制
复制过来之后,菜单就已经自动生成
之后就可以找一个新的centos8进行安装。这里我们用网卡启动
这样的centos8是用系统默认的应答文件安装,可以看到上面安装后默认是安装逻辑卷的形式分区。
这里我们自己配置自己的应答文件。
[root@centos7 ~]#ls /var/lib/cobbler/kickstarts/
default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample.ks sample.seed.28
esxi4-ks.cfg legacy.ks sample_end.ks sample_esxi5.ks sample_old.seed
esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed
系统默认应答文件放置路径是在 ls /var/lib/cobbler/kickstarts/
[root@centos7 ~]#vim /var/lib/cobbler/kickstarts/ks8.cfg
#version=RHEL8
ignoredisk --only-use=sda
zerombr
text
reboot
# Partition clearing information
clearpart --all --initlabel
selinux --disabled
firewall --disabled
# Use graphical install
#repo --name="Appstream" --baseurl=http://192.168.39.8/centos/8/isos/x86_64/AppStream
url --url=$tree
#repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
# Use CDROM installation media
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
#version=RHEL8
ignoredisk --only-use=sda
zerombr
text
reboot
# Partition clearing information
clearpart --all --initlabel
selinux --disabled
firewall --disabled
# Use graphical install
#repo --name="Appstream" --baseurl=http://192.168.39.8/centos/8/isos/x86_64/AppStream
url --url=$tree #改为变量的形式
#repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
# Use CDROM installation media
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens160 --ipv6=auto --activate
network --hostname=centos8.magedu.com
# Root password
rootpw --iscrypted $6$nOPs5JTMlP4mhQeW$R/o62B6SXAh3RR.zrZ3U0X4xYX9/u5nSLrR/vqCB6kdO2XFfMk2a4yAgrHJQpXK/e4jzRb0jiLBv2nFMXaBjB/
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --name=wang --password=$6$oUfb/02CWfLb5l8f$sgEZeR7c7DpqfpmFDH6huSmDbW1XQNR4qKl2EPns.gOXqlnAIgv9pTogtFVaDtEpMOC.SWXKYqxfVtd9MCwxb1 --iscrypted --gecos="wang"
# Disk partitioning information
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024
%packages
@^minimal-environment
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
[root@centos7 ~]#cobbler distro list 查看操作系统
CentOS_6.10_KAI-x86_64
CentOS_8.0_KAI-x86_64
[root@centos7 ~]#cobbler profile add --name=centos-8.0_kai --distro=CentOS_8.0_KAI-x86_64 --kickstar=/var/lib/cobbler/kickstarts/ks8.cfg 添加操作系统对应的应答文件生成不同的操作系统
[root@centos7 ~]#cobbler profile list
CentOS_6.10_KAI-x86_64
CentOS_8.0_KAI-x86_64
centos-8.0_kai
[root@centos7 ~]#cobbler profile remove --name=CentOS_8.0_KAI-x86_64 删除系统自带的操作系统
[root@centos7 ~]#cobbler profile list
CentOS_6.10_KAI-x86_64
centos-8.0_kai 自己应答文件生成的系统
需要挂载一个centos6的光盘,由于centos8已经复制完成,直接换一个centos6的光盘就可以了
[root@centos7 cobbler]#mount /dev/sr1 /mnt
[root@centos7 cobbler]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 3G 0 part [SWAP]
sr0 11:0 1 10G 0 rom
sr1 11:1 1 3.7G 0 rom /mnt
进行导入 系统默认会提供最小化安装的应答文件 sz
[root@centos7 ~]#ls /var/lib/cobbler/kickstarts/
default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample.ks sample.seed.28
esxi4-ks.cfg legacy.ks sample_end.ks sample_esxi5.ks sample_old.seed
esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed
[root@centos7 ~]#cobbler import --name=CentOS_6.10_KAI --path=/mnt/ --arch=x86_64
task started: 2019-11-14_200156_import
task started (id=Media import, time=Thu Nov 14 20:01:56 2019)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64:
creating new distro: CentOS_6.10_KAI-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64 -> /var/www/cobbler/links/CentOS_6.10_KAI-x86_64
creating new profile: CentOS_6.10_KAI-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64 for CentOS_6.10_KAI-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS_6.10_KAI-x86_64/repodata
*** TASK COMPLETE ***
[root@centos7 ~]#cobbler distro list
CentOS_6.10_KAI-x86_64
CentOS_7.7_mini-x86_64
CentOS_8.0_KAI-x86_64
[root@centos7 ~]#cobbler profile list
CentOS7.7_kmini
CentOS_6.10_KAI-x86_64
centos-8.0_kai
[root@centos7 ~]#cobbler profile add --name=CentOS6.10_kaimini --distro=CentOS_6.10_KAI-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks6.cfg
[root@centos7 ~]#cobbler profile list
CentOS6.10_kaimini
CentOS7.7_kmini
centos-8.0_kai
需要挂载一个centos7的光盘,本身就是在centos7上做的实验,本身的光盘就可以
[root@centos7 ~]#mount /dev/sr0 /media
[root@centos7 ~]#cobbler import --name= centos7 --path=/media/ --arch=x86_64
[root@centos7 ~]#cobbler profile list
CentOS6.10_kaimini
centos-8.0_kai
centos7
[root@centos7 ~]#cobbler distro list
CentOS_6.10_KAI-x86_64
CentOS_8.0_KAI-x86_64
centos7-x86_64
[root@centos7 ~]#cobbler profile add --name=centos7 --distro=centos7-x86_64 --kickstar=/var/lib/cobbler/kickstarts/ks7.cfg