PXE+DHCP+TFTP+Cobbler 無人值守安裝centos 7

来源:http://www.cnblogs.com/hehehe886/archive/2017/09/03/7470438.html
-Advertisement-
Play Games

Cobbler(補鞋匠)是通過將DHCP、TFTP、DNS、HTTP等服務進行集成,創建一個中央管理節點,其可以實現的功能有配置服務,創建存儲庫,解壓縮操作系統媒介,代理或集成一個配置管理系統,控制電源管理等。 Cobbler的最終目的是實現無需進行人工干預即可安裝機器。 pxe概述 預啟動執行環境 ...


 

 Cobbler(補鞋匠)是通過將DHCP、TFTP、DNS、HTTP等服務進行集成,創建一個中央管理節點,其可以實現的功能有配置服務,創建存儲庫,解壓縮操作系統媒介,代理或集成一個配置管理系統,控制電源管理等。 Cobbler的最終目的是實現無需進行人工干預即可安裝機器。

  pxe概述
  預啟動執行環境(Preboot eXecution Environment,PXE,也被稱為預執行環境)是讓電腦通過網卡獨立地使用數據設備(如硬碟)或者安裝操作系統

    PXE Client發送廣播包請求DHCP分配IP地址DHCP
    Server回覆請求,給出IP地址以及Boot
    Server的地址PXE下載引導文件執行引導程式

總結來說,

  pxe客戶端會調用網際協議(ip)、用戶數據報協議(udp)、動態主機設定協議(DHCP)、小型文件傳輸協議(TFTP)

  pxe客戶端(client)指機器在pxe啟動過程中的角色。一個pxe客戶端可以是一臺伺服器、筆記本電腦或者其他裝有pxe啟動代碼的機器

  PXE主要是通過廣播的方式發送一個包,並請註獲取一個地址,而後交給TFTP程式下載一個引導文件。

cobbler和Kickstart批量裝機軟體

 Cobbler由python語言開發,是對PXE和Kickstart以及DHCP的封裝。融合很多特性,提供了CLI和Web的管理形式。更加方便的實行網路安裝。同時,Cobbler也提供了API介面,使用其它語言也很容易做擴展。它不緊可以安裝物理機,同時也支持kvm、xen虛擬化、Guest OS的安裝。更多的是它還能結合Puppet等集中化管理軟體,實現自動化的管理。

  Kickstart 是一種無人值守的安裝方式,它的工作原理是在安裝過程中記錄人工干預填寫的各種參數,並生成一個名為ks.cfg的文件。我們可以簡單理解為一個自動安裝應答配置管理程式。通過讀取這個配置文件,系統知道怎麼去分區,要安裝什麼包,配什麼IP,優化什麼內核參數等等 

  一句話總結:Cobbler補鞋匠是對Kickstart的封裝,簡化安裝步驟、使用流程,官方號稱補鞋匠都能學會的批量裝機。

Cobbler 工作流程

server端:

    第一步,啟動Cobbler服務
    第二步,進行Cobbler錯誤檢查,執行cobbler check命令
    第三步,進行配置同步,執行cobbler sync命令
    第四步,複製相關啟動文件文件到TFTP目錄中
    第五步,啟動DHCP服務,提供地址分配
    第六步,DHCP服務分配IP地址
    第七步,TFTP傳輸啟動文件
    第八步,Server端接收安裝信息
    第九步,Server端發送ISO鏡像與Kickstart文件

Client端:

    第一步,客戶端以PXE模式啟動
    第二步,客戶端獲取IP地址
    第三步,通過TFTP伺服器獲取啟動文件
    第四步,進入Cobbler安裝選擇界面
    第五步,客戶端確定載入信息
    第六步,根據配置信息準備安裝系統
    第七步,載入Kickstart文件
    第八步,傳輸系統安裝的其它文件
    第九步,進行安裝系統

 

正式環境準備:

  1.網路環境:host-only、nat網路,因為Cobbler需要用到自己的dhcp伺服器,所以為了防止都在同一個網路造成dhcp獲取混亂,需要切換網路!~ 

  2.類似安裝服務必要的環境準備:1,關閉iptables,selinux 2,配置靜態IP、設置主機名 並且在hosts文件下綁定 3.時間同步 4.配置本地iso鏡像里的yum倉庫,163源epel源 (安裝軟體)

cobbler server    -------    client
                   192.168.100.221/24   ------------------------------------   裝機時候由DHCP自動配置

 

一.  在cobbler server上安裝cobbler

  yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart

[root@bokeyuan ~]# yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package rsync-3.0.9-17.el7.x86_64 already installed and latest version
Package 12:dhcp-common-4.2.5-47.el7.centos.x86_64 already installed and latest version
Package 12:dhcp-libs-4.2.5-47.el7.centos.x86_64 already installed and latest version
Package pykickstart-1.99.66.10-1.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: mod_wsgi for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: PyYAML for package: cobbler-2.6.3-1.el6.noarch
---> Package cobbler-web.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: mod_ssl for package: cobbler-web-2.6.3-1.el6.noarch
--> Processing Dependency: Django for package: cobbler-web-2.6.3-1.el6.noarch
---> Package dhcp.x86_64 12:4.2.5-47.el7.centos will be installed
---> Package httpcomponents-client.noarch 0:4.2.5-5.el7_0 will be installed
--> Processing Dependency: mvn(commons-logging:commons-logging) for package: httpcomponents-client-4.2.5-5.el7_0.noarch
--> Processing Dependency: mvn(commons-codec:commons-codec) for package: httpcomponents-client-4.2.5-5.el7_0.noarch
---> Package httpcomponents-core.noarch 0:4.2.4-6.el7 will be installed
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-45.el7.centos.x86_64
---> Package httpd-devel.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: apr-util-devel for package: httpd-devel-2.4.6-45.el7.centos.x86_64
--> Processing Dependency: apr-devel for package: httpd-devel-2.4.6-45.el7.centos.x86_64
---> Package httpd-manual.noarch 0:2.4.6-45.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be installed
---> Package syslinux.x86_64 0:4.05-13.el7 will be installed
---> Package tftp.x86_64 0:5.2-13.el7 will be installed
---> Package tftp-server.x86_64 0:5.2-13.el7 will be installed
---> Package xinetd.x86_64 2:2.3.15-13.el7 will be installed
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
---> Package apache-commons-codec.noarch 0:1.8-7.el7 will be installed
---> Package apache-commons-logging.noarch 0:1.1.2-7.el7 will be installed
--> Processing Dependency: mvn(logkit:logkit) for package: apache-commons-logging-1.1.2-7.el7.noarch
--> Processing Dependency: mvn(log4j:log4j) for package: apache-commons-logging-1.1.2-7.el7.noarch
--> Processing Dependency: mvn(avalon-framework:avalon-framework-api) for package: apache-commons-logging-1.1.2-7.el7.noarch
---> Package apr-devel.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util-devel.x86_64 0:1.5.2-6.el7 will be installed
--> Processing Dependency: openldap-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: expat-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
---> Package mod_ssl.x86_64 1:2.4.6-45.el7.centos will be installed
---> Package mod_wsgi.x86_64 0:3.4-12.el7_0 will be installed
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package avalon-framework.noarch 0:4.3-10.el7 will be installed
--> Processing Dependency: xalan-j2 for package: avalon-framework-4.3-10.el7.noarch
---> Package avalon-logkit.noarch 0:2.1-14.el7 will be installed
--> Processing Dependency: tomcat-servlet-3.0-api for package: avalon-logkit-2.1-14.el7.noarch
--> Processing Dependency: jms for package: avalon-logkit-2.1-14.el7.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package expat-devel.x86_64 0:2.1.0-8.el7 will be installed
---> Package libdb-devel.x86_64 0:5.3.21-19.el7 will be installed
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package log4j.noarch 0:1.2.17-15.el7 will be installed
--> Processing Dependency: mvn(javax.mail:mail) for package: log4j-1.2.17-15.el7.noarch
---> Package openldap-devel.x86_64 0:2.4.40-13.el7 will be installed
--> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.40-13.el7.x86_64
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2 will be installed
---> Package geronimo-jms.noarch 0:1.1.1-19.el7 will be installed
---> Package javamail.noarch 0:1.4.6-8.el7 will be installed
---> Package tomcat-servlet-3.0-api.noarch 0:7.0.69-10.el7 will be installed
---> Package xalan-j2.noarch 0:2.7.1-23.el7 will be installed
--> Processing Dependency: xerces-j2 for package: xalan-j2-2.7.1-23.el7.noarch
--> Processing Dependency: osgi(org.apache.xerces) for package: xalan-j2-2.7.1-23.el7.noarch
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package xerces-j2.noarch 0:2.11.0-17.el7_0 will be installed
--> Processing Dependency: xml-commons-resolver >= 1.2 for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: xml-commons-apis >= 1.4.01 for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: osgi(org.apache.xml.resolver) for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: osgi(javax.xml) for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package xml-commons-apis.noarch 0:1.4.01-16.el7 will be installed
---> Package xml-commons-resolver.noarch 0:1.2-15.el7 will be installed
--> Finished Dependency Resolution
Error: Package: Django14-1.4.20-1.el6.noarch (cobbler)
           Requires: python-simplejson
Error: Package: cobbler-2.6.3-1.el6.noarch (cobbler)
           Requires: python-simplejson
Error: Package: Django14-1.4.20-1.el6.noarch (cobbler)
           Requires: python(abi) = 2.6
           Installed: python-2.7.5-48.el7.x86_64 (@anaconda)
               python(abi) = 2.7
               python(abi) = 2.7
Error: Package: cobbler-2.6.3-1.el6.noarch (cobbler)
           Requires: python-cheetah
 You could try using --skip-broken to work around the problem
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
ipa-client-4.4.0-12.el7.centos.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.centos.x86_64
ipa-client-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.centos.noarch
ipa-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.centos.noarch

 報錯解決:提示--skip-broken ,檢查發現自己yum源不全yum無法安裝上面三個依賴包。補全yum源解決

 

安裝完成,啟動軟體

[root@bokeyuan ~]# systemctl restart cobblerd.service
[root@bokeyuan ~]# systemctl restart httpd.service
[root@bokeyuan ~]# systemctl enable cobblerd.service  //開機自啟動
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
[root@bokeyuan ~]# systemctl enable httpd.service  //開機自啟動
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

為什麼啟動apache?血的教訓,排了很久。不先啟動apache 後續cobbler check 報python file 的錯誤!!!

二.基本配置

 

[root@bokeyuan ~]# 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
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
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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

Restart cobblerd and then run 'cobbler sync' to apply changes.

 一步步解決上述需求,部分需求可忽略。個體差異不同 每個人需求數量也不同,基本上大同小異

解決需求1、2、7
# openssl passwd -1 -salt 'werwqerwqr' '123456'        --123456為密碼(這是自動安裝客戶端系統成功後的root登錄密碼),werwqerwqr為隨機位元組干擾碼(隨便寫)
$1$werwqerw$.prcfrYFbwuvkD8XspayN.

 

# vim /etc/cobbler/settings
384 server: 192.168.100.221    --換成cobbler伺服器端的IP
272 next_server: 192.168.100.221    --同上
101 default_password_crypted: "$1$werwqerw$.prcfrYFbwuvkD8XspayN."  --把密碼字元串換成你上面產生的字元串(此密碼為客戶機安裝後的root登錄密碼)

解決需求3
# vim /etc/xinetd.d/tftp
        disable = no    --yes改為no

 

解決需求5

#systemctl restart rsyncd.service

#systemctl enable  rsyncd.service

 

解決需求8
# yum install fence-agents

OK,剩下的需求像

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.
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories

(問題4可以使用cobbler get-loaders解決,但需要有外網和外網的yum源 跳過,現在是NAT模式;問題6 是關於debian系統的,我們這裡可以忽略)

最後# systemctl restart cobblerd.service 重起下cobbler補鞋匠服務!

 

三.導入centos7.3的iso鏡像

我的環境iso鏡像掛載在/yum目錄,此拷貝步驟時間較長

# cobbler import --path=/yum/ --name=centos7.3

# cobbler distro list    --導入成功後,確認導入的鏡像名
   centos7.3-x86_64
# cobbler profile list    --導入成功後,確認預設的profile名
   centos7.3-x86_64

[root@bokeyuan ~]# cobbler import --path=/yum/ --name=centos7.3
task started: 2017-09-03_175701_import
task started (id=Media import, time=Sun Sep  3 17:57:01 2017)
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/centos7.3:
creating new distro: centos7.3-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7.3 -> /var/www/cobbler/links/centos7.3-x86_64
creating new profile: centos7.3-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/centos7.3 for centos7.3-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7.3
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7.3
looking for /var/www/cobbler/ks_mirror/centos7.3/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.3/repodata
*** TASK COMPLETE ***

 


四.修改dhcp配置
# vim /etc/cobbler/dhcp.template  --在此文件的第21行到第25行修改成你對應的網段和ip    

subnet 192.168.100.0 netmask 255.255.255.0 {
     option routers             192.168.100.221;
     option domain-name-servers 192.168.100.221;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.100.100 192.168.100.254;


--圖形的操作過程這裡省略後續還有這一步 重要

# vim /etc/cobbler/settings    --再去修改這個配置文件,改成dhcp服務由cobbler來管理
242 manage_dhcp: 1        --把0改為1

#  systemctl restart cobblerd.service   --保存後,再重啟此服務

五.使用cobbler sync同步,並啟動xinetd服務

下麵的cobbler sync 很重要,如果這步報錯一定要排出來,就經驗來說這步出錯一般是IP配置出錯,記得細心一點,個體差異不用就不詳細表述~  

# cobbler sync

[root@bokeyuan ~]# cobbler sync
task started: 2017-09-03_180107_sync
task started (id=Sync, time=Sun Sep  3 18:01:07 2017)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos7.3-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos7.3-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying files for distro: centos7.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7.3-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos7.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7.3-x86_64/initrd.img
Writing template files for centos7.3-x86_64
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos7.3-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 shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

 
# systemctl restart xinetd.service
# systemctl enable xinetd.service

 

六.新建另一個虛擬機 選擇網路安裝PXE (保證相同私有網路,並且最好2G記憶體,記憶體小的話會在安裝時報空間不夠的錯誤),進行安裝測試

    

安裝完成後,更改boot引導

 

 

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

自動安裝我們已經實現了,但如何自定義我們想安裝的profile

重點就是你需要自定義一個ks文件


自定義ks文件的方法
1,如果你很熟悉此文件,直接拷別人的模版修改或者直接使用/root/anaconda-ks.cfg來修改
2,使用一個圖形工具system-config-kickstart來幫助你配置(下麵我就是使用這種方法)


# yum install system-config-kickstart
# system-config-kickstart    

--圖形的操作過程這裡省略


給大家兩個做好的ks.cfg文件參考:

第一個文件就是用來安裝centos7.3宿主機的ks文件,內容如下:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://172.16.13.250/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=4000
part / --fstype="xfs"  --size=150000
part /data --fstype="xfs" --size=80000


%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end


第二個文件是用來宿主機安裝雙系統的ks文件

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://172.16.13.250/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --none
# Disk partitioning information
part swap --fstype="swap" --size=4000
part / --fstype="xfs" --grow --size=1


%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end



=========================================================================


# cobbler profile help    --查看幫助
# cobbler profile list    --查看有哪些profile
   centos7.3-x86_64    


# cobbler profile report --name=centos7.3-x86_64 |grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks  --這就是這個安裝方案的kickstart文件
Kickstart Metadata             : {}


我現在自定義一個ks文件,也想做成一個profile,步驟如下:
步驟一:
自定義ks文件(使用system-config-kickstart或直接找一個模版文件修改),得到如下的文件

# vim /var/lib/cobbler/kickstarts/centos7.3.ks    --複製下麵一大段信息,粘到此文件里

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://192.168.100.2/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=2000
part / --fstype="xfs" --grow --size=1


%post
rm /etc/yum.repos.d/* -rf
cat > /etc/yum.repos.d/local.repo << EOF
[base]
name=base
baseurl=file:///yum
enabled=1
gpgcheck=0
EOF
%end


%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end


步驟二:把準備好的ks文件做成一個新的profile
# cobbler profile add --name=new_centos7.3 --distro=centos7.3-x86_64  --kickstart=/var/lib/cobbler/kickstarts/centos7.3.ks

# cobbler profile list        --在原來基礎上就多了自定義的安裝方案
   centos7.3-x86_64
   new_centos7.3


步驟三:
測試
然後就可以新建一個客戶端虛擬機,使用上面的new_centos7.3安裝名字來測試了



==================================================================

對上面操作的擴展(僅供參考)
# cobbler profile edit --name=new_centos7.3 --kickstart=/var/lib/cobbler/kickstarts/xxx.ks   
# cobbler profile remove --name=new_centos7.3    



======================================================================




客戶端使用koan與伺服器的cobbler聯繫,實現自動重裝系統

客戶端需要安裝koan軟體包(epel源里就有)


# yum install koan  
# koan --server=192.168.100.2 --list=profiles       --192.168.100.2為cobbler伺服器IP,得到的結果和在cobbler伺服器上cobbler profile list命令得到的結果一樣
   centos7.3-x86_64
   new_centos7.3


# koan --replace-self --server=192.168.100.2 --profile=new_centos7.3  --指定本客戶端按照名為new_centos7.3的profile重裝系統

# reboot  --敲完上面的命令,使用reboot,就會重裝了(沒敲上面的命令那reboot就是重啟)

寫文不易 且行且珍惜

這是一個二維碼

給個機會,客官掃我

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 仿萬科底部的新聞滑動特效: ...
  • 所謂緩存,通俗點講就是把已經做過的事情結果先暫時存起來,下次再做同樣的事情,不用再重新去做,只要把之前的存的結果拿出來用即可,很明顯大大提升了效率。他的應用場景非常廣泛。如: 1、緩存ajax結果,大多數網站都會有產品推薦功能,比如按熱銷推薦,簡單低效的做法,每次點擊切換的時候,都要通過ajax去數 ...
  • 卸載mysql流程:1、查找以前是否裝有mysql。命令: 可以看到mysql的包:2、刪除mysql。刪除命令: 3、刪除老版本mysql的開發頭文件和庫。命令: 註意:卸載後/var/lib/mysql中的數據及/etc/my.cnf不會刪除,如果確定沒用後就手工刪除 ...
  • 環境:ubuntu16.04 交叉編譯器版本號:4.8.3 在編譯之前要編譯以下其依賴的軟體或庫:freetype,libpng,libxml2,libtiff,libjpeg,zlib,graphviz zlib庫 1.tar xvf zlib-1.2.11.tar.xz 2.export CC= ...
  • 用途說明 在執行Linux命令時,我們可以把輸出重定向到文件中,比如 ls >a.txt,這時我們就不能看到輸出了,如果我們既想把輸出保存到文件中,又想在屏幕上看到輸出內容,就可以使用tee命令了。tee命令讀取標準輸入,把這些內容同時輸出到標準輸出和(多個)文件中。要註意的是:在使用管道線時,前一 ...
  • 本文就linux中的壓縮工具gzip、bzip2和xz以及打包工具tar做出介紹,基本上能夠滿足工作中的需求和日常的使用。 ...
  • 當在Windows刪除文件時出現找不到該項目或者顯示該文件不在磁碟中,可以嘗試以下方法: 在要刪除文件的同級目錄下 新建一文本文檔,將下列代碼複製到文檔中,將文檔保存為尾碼名為.bat的文檔(名字隨意), DEL /F /A /Q \\?\%1 RD /S /Q \\?\%1 把你想刪除的文件或文件 ...
  • Linux系統擴容方法彙總 相信很多朋友都有過這樣的經歷,本想裝個Ubantu玩玩,沒想到玩久了反而不習慣Windows了,然而開始裝系統的時候只分配了非常小的空間,那應該怎樣擴展我們的ubantu呢?下麵我為大家總結幾種方法(僅在ubantu下測試過) 一、通過系統整體遷移 首先:進入Window ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...