您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“怎么使用Cobbler快速安裝系統”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“怎么使用Cobbler快速安裝系統”這篇文章吧。
Cobbler 可以用來快速建立 Linux 網絡安裝環境,它已將 Linux 網絡安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。
CentOS Linux release 7.6.1810 VMware Workstation Pro 14
查看默認的 ks 文件
[root@Jaking ~]# cobbler reportdistros: ========== Name : CentOS-7.6-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.6-x86_64'} Management Classes : [] OS Version : rhel6 Owners : ['admin'] Red Hat Management Key : Red Hat Management Server : Template Files : {} profiles: ========== Name : CentOS-7.6-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7.6-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks Kickstart Metadata : {} Management Classes : [] Management Parameters : Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : Red Hat Management Server : Repos : [] Server Override : 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
注: distros 是發行版本,即光盤鏡像信息。 profiles 指的是 ks 應答文件。 systems 是指通 Cobbler 安裝好的物理機名稱。
[root@Jaking ~]# cd /var/lib/cobbler/kickstarts/[root@Jaking kickstarts]# lsdefault.ks legacy.ks sample_esx4.ks sample.ks esxi4-ks.cfg pxerescue.ks sample_esxi4.ks sample_old.seed esxi5-ks.cfg sample_autoyast.xml sample_esxi5.ks sample.seed install_profiles sample_end.ks sample_esxi6.ks sample.seed.28
可以看到有很多默認的配置文件。
上傳 CentOS7.ks 到 Cobbler 服務器上。CentOS7.ks 這個配置文件里面安裝了開發工具相關軟件包。
[root@Jaking kickstarts]# rz[root@Jaking kickstarts]# lsCentOS7.ks install_profiles sample_end.ks sample_esxi6.ks sample.seed.28 default.ks legacy.ks sample_esx4.ks sample.ks esxi4-ks.cfg pxerescue.ks sample_esxi4.ks sample_old.seed esxi5-ks.cfg sample_autoyast.xml sample_esxi5.ks sample.seed [root@Jaking kickstarts]# cat CentOS7.ks# Cobbler for Kickstart Configurator for CentOS 7 by clsninstall url --url=$treetext lang en_US.UTF-8 keyboard us zerombr bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"#Network information$SNIPPET('network_config')#network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7timezone --utc Asia/Shanghai authconfig --enableshadow --passalgo=sha512 rootpw --iscrypted $default_password_cryptedclearpart --all --initlabel part /boot --fstype xfs --size 1024 part swap --size 1024 part / --fstype xfs --size 1 --grow firstboot --disableselinux --disabled firewall --disabled logging --level=info reboot %pre$SNIPPET('log_ks_pre')$SNIPPET('kickstart_start')$SNIPPET('pre_install_network_config')# Enable installation monitoring$SNIPPET('pre_anamon') %end %packages @additional-devel @development @platform-devel bash-completion chrony dos2unix kexec-tools lrzsz sysstat tree vim wget git net-tools %end %post systemctl disable postfix.service %end [root@Jaking kickstarts]# cobbler profile list #查看當前啟動項,使用的配置文件 CentOS-7.6-x86_64
修改 name 是 CentOS-7.6-x86_64 的 kickstart 文件為 CentOS7.ks
[root@Jaking kickstarts]# cobbler profile edit --name CentOS-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.ks[root@Jaking kickstarts]# cobbler report | grep KickstartKickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.6-x86_64'} Kickstart : /var/lib/cobbler/kickstarts/CentOS7.ks Kickstart Metadata : {}
通過給內核傳參數,修改網卡名稱為 eth0
[root@Jaking kickstarts]# cobbler profile edit --name CentOS-7.6-x86_64 --kopts='net.ifnames=0 biosdevname=0'
配置文件內容如下:
[root@Jaking kickstarts]# vim CentOS7.ks #查看配置文件中的,默認就可以,不需要修改# Cobbler for Kickstart Configurator for CentOS 7 by clsnInstall #安裝系統url --url=$tree #url 地址為 Cobbler 內置變量text #文本方式安裝,修改為圖形界面則為 Graphicallang en_US.UTF-8 #語言keyboard us #鍵盤zerombr #該參數用于清除引導信息,需要讓其生效可以在參數后添加 yes 即可。可選項,一般不用。bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"#指定引導裝載程序怎樣被安裝.對于安裝和升級,這個選項都是必需的.#Network information$SNIPPET('network_config') #該參數表示使用下方%pre 中的腳本來配置網絡,相關腳本存放于/var/lib/cobbler/snippets#如果不需要腳本配置可啟用以下配置#network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6--hostname=CentOS7 timezone --utc Asia/Shanghai #時區authconfig --enableshadow --passalgo=sha512 #加密 shadowrootpw --iscrypted $default_password_crypted #設置 root 密碼clearpart --all --initlabel #--all 初除所有分區,后者將磁盤標簽初始化為缺省值設置。part /boot --fstype xfs --size 1024 #boot分區大小part swap --size 1024 #swap分區大小part / --fstype xfs --size 1 --grow #根分區大小firstboot --disable #決定是否在系統第一次引導時啟動"設置代理”,禁用。selinux --disabled #在系統里設置 SELinux 狀態firewall --disabled #在系統貍設置而防火墻狀態logging --level=info #這個命令控制安裝過程中anaconda的錯誤日志,它對安裝好的系統沒有影響。reboot #安裝后重啟%pre #pre 中定了前面使用的具體腳本名稱。$SNIPPET('log_ks_pre')$SNIPPET('kickstart_start')$SNIPPET('pre_install_network_config')# Enable installation monitoring$SNIPPET('pre_anamon') %end %packages #自定義安裝內容,這里可以可以自行生成 ks 文件然后把對應的配置復制到這里。當前配置為最小化安裝,以及安裝系統常用工具。@additional-devel @development @platform-devel bash-completion chrony dos2unix kexec-tools lrzsz sysstat tree vim wget git net-tools %end %post #安裝后執行操作,可以執行腳本也可以直接執行命令。systemctl disable postfix.service %end
定制 Cobbler 引導菜單(名稱、超時時間、默認啟動菜單)
[root@Jaking kickstarts]# vim /etc/cobbler/pxe/pxedefault.templateDEFAULT menu PROMPT 0 MENU TITLE Jaking #菜單名稱TIMEOUT 100 #超時時間TOTALTIMEOUT 6000 ONTIMEOUT $pxe_timeout_profileLABEL local MENU LABEL (local) MENU DEFAULT LOCALBOOT -1 $pxe_menu_items #該變量是我自定義的引導菜單,復制到 LABEL local 配置項上方,否則默認啟動還是 local。MENU end
同步 Cobbler 配置
[root@Jaking kickstarts]# systemctl restart cobblerd[root@Jaking kickstarts]# cobbler synctask started: 2020-01-04_050537_sync task started (id=Sync, time=Sat Jan 4 05:05:37 2020) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/CentOS-7.6-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.6-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.6-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7.6-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7.6-x86_64/initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: CentOS-7.6-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7.6-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7.6-x86_64/initrd.img Writing template files for CentOS-7.6-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.6-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 ***
新建虛擬機進行測試。
注意:內存要足夠大,網絡模式要和 Cobbler 服務端的網絡模式一致。
創建過程省略,直接來到開機啟動界面:
可以看到,需要安裝 1262 個包,不再是原來的最小化安裝了。
安裝成功后,默認啟動命令行模式 輸入 root 123456 登錄系統:
設置默認啟動模式為圖形化模式 graphical.target
[root@localhost ~]# systemctl get-defaultmulti-user.target[root@localhost ~]# systemctl set-default graphical.targetRemoved symlink /etc/systemd/system/default.target.Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.[root@localhost ~]# systemctl get-default graphical.target[root@localhost ~]# reboot
不能正常啟動圖形化模式
安裝圖形化軟件
[root@localhost ~]# yum install -y xorg* gnome* glx*
切換到圖形化模式
[root@localhost ~]# init 5
以上是“怎么使用Cobbler快速安裝系統”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。