cobbler多機定製安裝
阿新 • • 發佈:2020-07-30
目錄
cobbler多機定製安裝
1. cobbler服務端部署
服務端IP是192.168.32.125
#開始前確保防火牆色selinux永久是disable狀態 #確保配置好yum源,包括epel源 #安裝cobbler以及相關軟體 [root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart net-tools #啟動服務並開機自啟 [root@localhost ~]# systemctl enable --now httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@localhost ~]# systemctl enable --now cobblerd Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service. [root@localhost ~]# systemctl enable --now rsyncd Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service. #cobbler伺服器的ip,應設定為本機的ip,不能設為0.0.0.0,它不是監聽地址 [root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.32.125/' /etc/cobbler/settings #next_server選項用於DHCP / PXE,作為下載網路啟動檔案的TFTP伺服器的IP。通常與伺服器設定相同的IP。 [root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.32.125/' /etc/cobbler/settings #開啟TFTP [root@localhost ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp #下載缺失檔案 [root@localhost ~]# cobbler get-loaders task started: 2020-07-29_204856_get_loaders task started (id=Download Bootloader Content, time=Wed Jul 29 20:48:56 2020) 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@localhost ~]# openssl passwd -1 '123456' $1$gm/tIx5/$WNXe5l7iVrefATyR79hK8. #將新生成的加密密碼加入到配置檔案 [root@localhost ~]# vim /etc/cobbler/settings ...... default_password_crypted: "$1$gm/tIx5/$WNXe5l7iVrefATyR79hK8." ...... #重啟cobbler [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# ss -tanl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 5 127.0.0.1:25151 *:* LISTEN 0 5 *:873 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 [::1]:25 [::]:* 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 : 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. //以上兩個是關於debian系統的缺包錯誤,請忽略 #配置cobbler dhcp #修改cobbler配置檔案,讓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.32.0 netmask 255.255.255.0 { option routers 192.168.32.125; option domain-name-servers 192.168.32.2; //此處為系統安裝好後指定的dns地址 option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.32.100 192.168.32.254; default-lease-time 21600; max-lease-time 43200; next-server $next_server; ...... #重啟服務並同步配置,改完dhcp必須要sync同步配置 [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# cobbler sync task started: 2020-07-29_205553_sync task started (id=Sync, time=Wed Jul 29 20:55:53 2020) 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 DHCP files generating /etc/dhcp/dhcpd.conf 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: 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/* 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 *** #檢查dhcp是否正常 [root@localhost ~]# netstat -anulp|grep dhcp udp 0 0 0.0.0.0:67 0.0.0.0:* 9765/dhcpd
匯入CentOS7映象
光碟機放的是centos7的映象
[root@localhost ~]# mount /dev/sr0 /mnt/ mount: /dev/sr0 is write-protected, mounting read-only [root@localhost ~]# cobbler import --path=/mnt --name=CentOS-7 --arch=x86_64 task started: 2020-07-29_205908_import task started (id=Media import, time=Wed Jul 29 20:59:08 2020) Found a candidate signature: breed=redhat, version=rhel6 Found a candidate signature: breed=redhat, version=rhel7 Found a matching signature: breed=redhat, version=rhel7 Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7-x86_64: creating new distro: CentOS-7-x86_64 trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 -> /var/www/cobbler/links/CentOS-7-x86_64 creating new profile: CentOS-7-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-7-x86_64 for CentOS-7-x86_64 processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata *** TASK COMPLETE *** #列出所有的cobbler元素 [root@localhost ~]# cobbler list distros: CentOS-7-x86_64 profiles: CentOS-7-x86_64 systems: repos: images: mgmtclasses: packages: files: #建立kickstarts自動安裝指令碼 [root@localhost ~]# cat > /var/lib/cobbler/kickstarts/CentOS-7-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.32.125/cobbler/ks_mirror/CentOS-7-x86_64 $yum_repo_stanza reboot rootpw --iscrypted $1$uWE7AB.4$PkdHLLjN2ifJ4551EtPaj1 selinux --disabled skipx timezone Asia/Shanghai --isUtc --nontp install zerombr %packages @^minimal @core 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 EOF #檢查ks檔案語法是否有誤 [root@localhost ~]# cobbler validateks task started: 2020-07-29_210346_validateks task started (id=Kickstart Validation, time=Wed Jul 29 21:03:46 2020) ---------------------------- osversion: rhel7 checking url: http://192.168.32.125/cblr/svc/op/ks/profile/CentOS-7-x86_64 running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.32.125/cblr/svc/op/ks/profile/CentOS-7-x86_64" received on stdout: received on stderr: *** all kickstarts seem to be ok *** *** TASK COMPLETE *** #修改profile,將我們新建的ks檔案設為預設的kickstarts安裝檔案 [root@localhost ~]# cobbler profile edit --name CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks #配置網絡卡名稱為傳統網絡卡名稱eth0 [root@localhost ~]# cobbler profile edit --name CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0' #檢查當前系統cobbler配置檔案信 [root@localhost ~]# cobbler profile report Name : CentOS-7-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm #同步cobbler [root@localhost ~]# cobbler sync task started: 2020-07-29_210704_sync task started (id=Sync, time=Wed Jul 29 21:07:04 2020) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/CentOS-7-x86_64 removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86.efi removing: /var/lib/tftpboot/grub/grub-x86_64.efi removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/images/CentOS-7-x86_64 removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders 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 files for distro: CentOS-7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7-x86_64/initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: CentOS-7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7-x86_64/initrd.img Writing template files for CentOS-7-x86_64 rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp processing boot_files for distro: CentOS-7-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/* 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 *** [root@localhost ~]# umount /mnt/
再匯入rhel-8的映象
更換光碟機,再匯入
[root@localhost ~]# mount /dev/sr0 /mnt/ mount: /dev/sr0 is write-protected, mounting read-only #匯入映象 [root@localhost ~]# cobbler import --path=/mnt --name=rhel-8 --arch=x86_64 task started: 2020-07-29_211108_import task started (id=Media import, time=Wed Jul 29 21:11:08 2020) 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/rhel-8-x86_64: creating new distro: rhel-8-x86_64 trying symlink: /var/www/cobbler/ks_mirror/rhel-8-x86_64 -> /var/www/cobbler/links/rhel-8-x86_64 creating new profile: rhel-8-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/rhel-8-x86_64 for rhel-8-x86_64 processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata *** TASK COMPLETE *** #檢視映象 [root@localhost ~]# cobbler list distros: CentOS-7-x86_64 rhel-8-x86_64 profiles: CentOS-7-x86_64 rhel-8-x86_64 systems: repos: images: mgmtclasses: packages: files: #建立rhel-8的kickstarts自動安裝指令碼 cat > /var/lib/cobbler/kickstarts/rhel-8-x86_64.ks <<'EOF' #version=RHEL8 ignoredisk --only-use=sda autopart --type=lvm # Partition clearing information clearpart --none --initlabel # Use text installt text # Keyboard layouts keyboard --vckeymap=us --xlayouts='us' # System language lang en_US.UTF-8 # Network information network --bootproto=dhcp --device=eth0 --ipv6=auto --activate network --hostname=localhost.localdomain url --url=http://192.168.32.125/cobbler/ks_mirror/rhel-8-x86_64 # Root password rootpw --iscrypted $1$gm/tIx5/$WNXe5l7iVrefATyR79hK8. # Run the Setup Agent on first boot firstboot --enable # Do not configure the X Window System skipx # System services services --enabled="chronyd" # System timezone timezone Asia/Shanghai --isUtc --nontp %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 EOF #修改profile,將我們新建的ks檔案設為預設的kickstarts安裝文 [root@localhost ~]# cobbler profile edit --name rhel-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks #配置網絡卡名稱為傳統網絡卡名稱eth0 [root@localhost ~]# cobbler profile edit --name rhel-8-x86_64 --kopts='net.ifnames=0 biosdevname=0' #檢查當前系統cobbler配置檔案資訊 [root@localhost ~]# cobbler profile report Name : rhel-8-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : rhel-8-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/rhel-8-x86_64.ks Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm Name : CentOS-7-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm #同步cobbler [root@localhost ~]# cobbler sync task started: 2020-07-29_214221_sync task started (id=Sync, time=Wed Jul 29 21:42:21 2020) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/rhel-8-x86_64 removing: /var/www/cobbler/images/CentOS-7-x86_64 removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86.efi removing: /var/lib/tftpboot/grub/grub-x86_64.efi removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/images/rhel-8-x86_64 removing: /var/lib/tftpboot/images/CentOS-7-x86_64 removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders 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 files for distro: rhel-8-x86_64 trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-8-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-8-x86_64/initrd.img copying files for distro: CentOS-7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7-x86_64/initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: rhel-8-x86_64 trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-8-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-8-x86_64/initrd.img Writing template files for rhel-8-x86_64 copying files for distro: CentOS-7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7-x86_64/initrd.img Writing template files for CentOS-7-x86_64 rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp processing boot_files for distro: rhel-8-x86_64 processing boot_files for distro: CentOS-7-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/* 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 *** #重啟所有服務 #重啟所有服務 [root@localhost ~]# systemctl restart xinetd [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# systemctl restart httpd [root@localhost ~]# ss -tanl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 5 127.0.0.1:25151 *:* LISTEN 0 5 *:873 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 [::1]:25 [::]:* LISTEN 0 128 [::]:443 [::]:* LISTEN 0 5 [::]:873 [::]:* LISTEN 0 128 [::]:80 [::]:* LISTEN 0 128 [::]:22
2. 客戶端安裝
給客戶端插上電源,連線上網線,開機。選擇系統安裝
3. 定製安裝配置
定製安裝步驟:
統計伺服器mac地址
配置cobbler
安裝
CentOS7:
00:50:56:36:2E:88
rhel-8:
00:50:56:26:F3:26
給兩臺伺服器定製安裝,一臺裝CentOS7,一臺裝rhel8
在 cobbler 的web介面上配置:
登入
#/var/lib/cobbler/config/systems.d/test1.json就是web介面的配置
[root@localhost ~]# cd /var/lib/cobbler/config/systems.d/
[root@localhost systems.d]# ls
test1.json
[root@localhost systems.d]#
[root@localhost systems.d]# cat test1.json
{"comment": "", "status": "production", "kickstart": "/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks", "name_servers_search": [], "ks_meta": {}, "kernel_options_post": {}, "image": "", "redhat_management_key": "<<inherit>>", "virt_path": "<<inherit>>", "power_user": "", "kernel_options": {"biosdevname": "0", "net.ifnames": "0"}, "ctime": 1596074970.448188, "name_servers": ["114.114.114.114"], "mtime": 1596074970.448188, "enable_gpxe": false, "template_files": {}, "gateway": "192.168.32.2", "uid": "MTU5NjA3NDk3MC40NTY3OTg3MzIuNjA4NDY", "virt_auto_boot": 0, "power_type": "ipmitool", "virt_cpus": "<<inherit>>", "mgmt_parameters": "<<inherit>>", "boot_files": {}, "hostname": "client-1", "repos_enabled": false, "mgmt_classes": [], "power_pass": "", "netboot_enabled": true, "ipv6_autoconfiguration": false, "profile": "CentOS-7-x86_64", "virt_type": "xenpv", "interfaces": {"eth0": {"ipv6_address": "", "interface_type": "", "static": true, "cnames": [], "mtu": "", "management": false, "interface_master": "", "mac_address": "00:50:56:36:2E:88", "ipv6_prefix": "", "virt_bridge": "xenbr0", "netmask": "255.255.255.0", "bonding_opts": "", "ip_address": "192.168.32.150", "dhcp_tag": "", "static_routes": [], "ipv6_mtu": "", "ipv6_static_routes": [], "if_gateway": "", "dns_name": "", "bridge_opts": "", "connected_mode": false, "ipv6_secondaries": [], "ipv6_default_gateway": ""}}, "power_address": "", "proxy": "<<inherit>>", "fetchable_files": {}, "virt_file_size": "<<inherit>>", "ldap_enabled": false, "monit_enabled": false, "ipv6_default_device": "", "virt_pxe_boot": 0, "virt_disk_driver": "<<inherit>>", "owners": "<<inherit>>", "name": "test1", "virt_ram": "<<inherit>>", "power_id": "", "server": "<<inherit>>", "redhat_management_server": "<<inherit>>", "depth": 2, "ldap_type": "authconfig", "template_remote_kickstarts": 0}
#這樣可讀性太差,不方便我們修改
#我們下載jq,來格式化json檔案
[root@localhost systems.d]# yum -y install jq
[root@localhost systems.d]# cat test1.json | jq
{
"comment": "",
"status": "production",
"kickstart": "/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks",
"name_servers_search": [],
"ks_meta": {},
"kernel_options_post": {},
"image": "",
"redhat_management_key": "<<inherit>>",
"virt_path": "<<inherit>>",
"power_user": "",
"kernel_options": {
"biosdevname": "0",
"net.ifnames": "0"
},
"ctime": 1596074970.448188,
"name_servers": [
"114.114.114.114"
],
"mtime": 1596074970.448188,
"enable_gpxe": false,
"template_files": {},
"gateway": "192.168.32.2",
"uid": "MTU5NjA3NDk3MC40NTY3OTg3MzIuNjA4NDY",
"virt_auto_boot": 0,
"power_type": "ipmitool",
"virt_cpus": "<<inherit>>",
"mgmt_parameters": "<<inherit>>",
"boot_files": {},
"hostname": "client-1",
"repos_enabled": false,
"mgmt_classes": [],
"power_pass": "",
"netboot_enabled": true,
"ipv6_autoconfiguration": false,
"profile": "CentOS-7-x86_64",
"virt_type": "xenpv",
"interfaces": {
"eth0": {
"ipv6_address": "",
"interface_type": "",
"static": true,
"cnames": [],
"mtu": "",
"management": false,
"interface_master": "",
"mac_address": "00:50:56:36:2E:88",
"ipv6_prefix": "",
"virt_bridge": "xenbr0",
"netmask": "255.255.255.0",
"bonding_opts": "",
"ip_address": "192.168.32.150",
"dhcp_tag": "",
"static_routes": [],
"ipv6_mtu": "",
"ipv6_static_routes": [],
"if_gateway": "",
"dns_name": "",
"bridge_opts": "",
"connected_mode": false,
"ipv6_secondaries": [],
"ipv6_default_gateway": ""
}
},
"power_address": "",
"proxy": "<<inherit>>",
"fetchable_files": {},
"virt_file_size": "<<inherit>>",
"ldap_enabled": false,
"monit_enabled": false,
"ipv6_default_device": "",
"virt_pxe_boot": 0,
"virt_disk_driver": "<<inherit>>",
"owners": "<<inherit>>",
"name": "test1",
"virt_ram": "<<inherit>>",
"power_id": "",
"server": "<<inherit>>",
"redhat_management_server": "<<inherit>>",
"depth": 2,
"ldap_type": "authconfig",
"template_remote_kickstarts": 0
}
根據上面的配置,我們在配置檔案中修改,來新增rhel-8的配置
#生成配置檔案
[root@localhost systems.d]# cat test1.json | jq > test2.json
[root@localhost systems.d]# cat test2.json
{
"comment": "",
"status": "production",
"kickstart": "/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks",
"name_servers_search": [],
"ks_meta": {},
"kernel_options_post": {},
"image": "",
"redhat_management_key": "<<inherit>>",
"virt_path": "<<inherit>>",
"power_user": "",
"kernel_options": {
"biosdevname": "0",
"net.ifnames": "0"
},
"ctime": 1596074970.448188,
"name_servers": [
"114.114.114.114"
],
"mtime": 1596074970.448188,
"enable_gpxe": false,
"template_files": {},
"gateway": "192.168.32.2",
"uid": "MTU5NjA3NDk3MC40NTY3OTg3MzIuNjA4NDY",
"virt_auto_boot": 0,
"power_type": "ipmitool",
"virt_cpus": "<<inherit>>",
"mgmt_parameters": "<<inherit>>",
"boot_files": {},
"hostname": "client-1",
"repos_enabled": false,
"mgmt_classes": [],
"power_pass": "",
"netboot_enabled": true,
"ipv6_autoconfiguration": false,
"profile": "CentOS-7-x86_64",
"virt_type": "xenpv",
"interfaces": {
"eth0": {
"ipv6_address": "",
"interface_type": "",
"static": true,
"cnames": [],
"mtu": "",
"management": false,
"interface_master": "",
"mac_address": "00:50:56:36:2E:88",
"ipv6_prefix": "",
"virt_bridge": "xenbr0",
"netmask": "255.255.255.0",
"bonding_opts": "",
"ip_address": "192.168.32.150",
"dhcp_tag": "",
"static_routes": [],
"ipv6_mtu": "",
"ipv6_static_routes": [],
"if_gateway": "",
"dns_name": "",
"bridge_opts": "",
"connected_mode": false,
"ipv6_secondaries": [],
"ipv6_default_gateway": ""
}
},
"power_address": "",
"proxy": "<<inherit>>",
"fetchable_files": {},
"virt_file_size": "<<inherit>>",
"ldap_enabled": false,
"monit_enabled": false,
"ipv6_default_device": "",
"virt_pxe_boot": 0,
"virt_disk_driver": "<<inherit>>",
"owners": "<<inherit>>",
"name": "test1",
"virt_ram": "<<inherit>>",
"power_id": "",
"server": "<<inherit>>",
"redhat_management_server": "<<inherit>>",
"depth": 2,
"ldap_type": "authconfig",
"template_remote_kickstarts": 0
}
#修改配置檔案,只需要修改以下幾項即可
"kickstart": "/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks",
"hostname": "client-2",
"profile": "rhel-8-x86_64",
"mac_address": "00:50:56:26:F3:26",
"ip_address": "192.168.32.155",
"name": "test2",
#修改後
[root@localhost systems.d]# cat test2.json
{
"comment": "",
"status": "production",
"kickstart": "/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks",
"name_servers_search": [],
"ks_meta": {},
"kernel_options_post": {},
"image": "",
"redhat_management_key": "<<inherit>>",
"virt_path": "<<inherit>>",
"power_user": "",
"kernel_options": {
"biosdevname": "0",
"net.ifnames": "0"
},
"ctime": 1596074970.448188,
"name_servers": [
"114.114.114.114"
],
"mtime": 1596074970.448188,
"enable_gpxe": false,
"template_files": {},
"gateway": "192.168.32.2",
"uid": "MTU5NjA3NDk3MC40NTY3OTg3MzIuNjA4NDY",
"virt_auto_boot": 0,
"power_type": "ipmitool",
"virt_cpus": "<<inherit>>",
"mgmt_parameters": "<<inherit>>",
"boot_files": {},
"hostname": "client-2",
"repos_enabled": false,
"mgmt_classes": [],
"power_pass": "",
"netboot_enabled": true,
"ipv6_autoconfiguration": false,
"profile": "rhel-8-x86_64",
"virt_type": "xenpv",
"interfaces": {
"eth0": {
"ipv6_address": "",
"interface_type": "",
"static": true,
"cnames": [],
"mtu": "",
"management": false,
"interface_master": "",
"mac_address": "00:50:56:26:F3:26",
"ipv6_prefix": "",
"virt_bridge": "xenbr0",
"netmask": "255.255.255.0",
"bonding_opts": "",
"ip_address": "192.168.32.155",
"dhcp_tag": "",
"static_routes": [],
"ipv6_mtu": "",
"ipv6_static_routes": [],
"if_gateway": "",
"dns_name": "",
"bridge_opts": "",
"connected_mode": false,
"ipv6_secondaries": [],
"ipv6_default_gateway": ""
}
},
"power_address": "",
"proxy": "<<inherit>>",
"fetchable_files": {},
"virt_file_size": "<<inherit>>",
"ldap_enabled": false,
"monit_enabled": false,
"ipv6_default_device": "",
"virt_pxe_boot": 0,
"virt_disk_driver": "<<inherit>>",
"owners": "<<inherit>>",
"name": "test2",
"virt_ram": "<<inherit>>",
"power_id": "",
"server": "<<inherit>>",
"redhat_management_server": "<<inherit>>",
"depth": 2,
"ldap_type": "authconfig",
"template_remote_kickstarts": 0
}
重啟服務
[root@localhost systems.d]# systemctl restart cobblerd
[root@localhost systems.d]# systemctl restart httpd
[root@localhost systems.d]# systemctl restart xinetd
配置已經有了
4. 安裝
兩臺機器開機自動安裝各自的系統
client1開機
正在裝包
登入,檢視系統版本資訊
client2開機
裝包
配置核心