[root@localhost ~]# openssl passwd -1
Password:
Verifying - Password:
1 1 1VbNNoYL9$UtmeEV9aGp3VCtdWH.7f21 //加密后的密码
//将新生成的加密密码加入到配置文件
[root@localhost ~]# vim /etc/cobbler/settings.yaml
…
default_password_crypted: “ 1 1 1VbNNoYL9$UtmeEV9aGp3VCtdWH.7f21”
…
//修改cobbler配置文件,让cobbler控制dhcp
[root@localhost ~]# sed -i ‘s/^manage_dhcp: false/manage_dhcp: true/g’ /etc/cobbler/settings.yaml #修改此处的值为true,表示让cobbler控制dhcp
[root@localhost ~]# sed -i ‘/^manage_dhcp/s/0/1/g’ /etc/cobbler/settings
[root@localhost ~]# sed -n ‘/^manage_dhcp/p’ /etc/cobbler/settings
manage_dhcp: 1
//配置dhcp
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.129.0 netmask 255.255.255.0 { #本地主机网段
option routers 192.168.129.135; #本机IP
option domain-name-servers 192.168.129.2; #DNS地址
option subnet-mask 255.255.255.0; #子网掩码
range dynamic-bootp 192.168.129.10 192.168.129.20; #dhcp服务器分配的IP地址范围
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class “pxeclients” {
…
//重启cobbler
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 5 0.0.0.0:873 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:443 :
LISTEN 0 5 [::]:873 [::]😗
LISTEN 0 128 *:80 :
LISTEN 0 128 [::]:22 [::]😗
//通过cobbler check 核对当前设置是否有问题
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
1: reposync is not installed, install yum-utils or dnf-plugins-core
2: yumdownloader is not installed, install yum-utils or dnf-plugins-core
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.
#以上3、4是关于debian系统的错误,请忽略
解决方法:
1、yum install fence-agents
2、yum -y install yum-utils
3、执行cobbler get-loaders命令
4、wget -P /etc/yum.repos.d/ https://copr.fedoraproject.org/coprs/jkastner/dnf-plugins-core/repo/epel-7/jkastner-dnf-plugins-core-epel-7.repo && yum install dnf-plugins-core
//再次查看
[root@localhost ~]# 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.
#1、2忽略
//最后一个问题
[root@php kickstarts]# yum -y install debmirror
[root@php kickstarts]# sed -i ‘s/@dists=“sid”;/#@dists=“sid”;/’ /etc/debmirror.conf
[root@php kickstarts]# sed -i ‘s/@arches=“i386”;/#@arches=“i386”;/’ /etc/debmirror.conf
//检查就没有问题了
[root@php kickstarts]# cobbler check
No configuration problems found. All systems go.
//重启服务并同步配置,改完dhcp必须要sync同步配置
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync
task started: 2021-10-13_032729_sync
task started (id=Sync, time=Wed Oct 13 22:45:29 2021)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/redhat-8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
removing: /var/lib/tftpboot/images/redhat-8-x86_64
copying bootloaders
running: [‘rsync’, ‘-rpt’, ‘–copy-links’, ‘–exclude=.cobbler_postun_cleanup’, ‘/var/lib/cobbler/loaders/’, ‘/var/lib/tftpboot’]
received on stdout:
received on stderr:
running: [‘rsync’, ‘-rpt’, ‘–copy-links’, ‘–exclude=README.grubconfig’, ‘/var/lib/cobbler/grub_config/’, ‘/var/lib/tftpboot’]
received on stdout:
received on stderr:
copying distros to tftpboot
copying files for distro: redhat-8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/redhat-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/redhat-8-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: redhat-8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/redhat-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/redhat-8-x86_64/initrd.img
Writing template files for redhat-8-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
processing boot_files for distro: redhat-8-x86_64
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: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***
//检查dhcp是否正常
[root@localhost ~]# ss -anulp| grep dhcp
UNCONN 0 0 *:67 : users:((“dhcpd”,pid=108719,fd=7))
UNCONN 0 0 0.0.0.0:40348 0.0.0.0:* users:((“dhcpd”,pid=146845,fd=20))
UNCONN 0 0 [::]:52014 [::]😗 users:((“dhcpd”,pid=146845,fd=21))
//导入安装镜像
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /mnt: /dev/sr0 already mounted on /mnt/cdrom.
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 9.0M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/rhel-root 36G 1.9G 34G 6% /
/dev/nvme0n1p1 1014M 179M 836M 18% /boot
tmpfs 376M 0 376M 0% /run/user/0
/dev/sr0 7.9G 7.9G 0 100% /mnt
[root@localhost ~]# cobbler import --name=redhat-8.2 --arch=x86_64 --path=/mnt
task started: 2021-10-12_125827_import
task started (id=Media import, time=Wed Oct 13 23:8:27 2021)
running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
shell triggers finished successfully
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/distro_mirror/redhat-8.2-x86_64:
creating new distro: redhat-8.2-x86_64
trying symlink: /var/www/cobbler/distro_mirror/redhat-8.2-x86_64 -> /var/www/cobbler/links/redhat-8.2-x86_64
creating new profile: redhat-8.2-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/distro_mirror/redhat-8.2-x86_64 for redhat-8.2-x86_64
processing repo at : /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream/repodata/comps.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS/repodata/comps.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
#参数说明
–path //镜像路径
–name //为安装源定义一个名字
–arch //指定安装源平台
#安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7-x86_64,如果重复,系统会提示导入失败
//查看cobbler镜像列表
[root@localhost ~]# cobbler list
distros:
redhat-8.2-x86_64
profiles:
redhat-8.2-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
//创建kickstarts自动安装脚本
[root@localhost ~]# cat > /var/lib/cobbler/kickstarts/redhat-8.2-x86_64.ks<<‘EOF’
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype=“ext4” --size=500
part swap --fstype=“swap” --size=4096
part / --fstype=“ext4” --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.129.135/cobbler/ks_mirror/redhat-8.2-x86_64/ #本机ip
$yum_repo_stanza
reboot
rootpw --iscrypted 6 6 6dsDSjBlVZrhKDfMG$XO2VJHSWQRVzkTCy0FUHeFUSX5YwtAdQ4rw5haeo2JpjzW6bvzG2OfZa2pB283ckYLmT5VYnn5BnWyJc6sLPE/ #修改为自己的密码
selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr
%packages