基於pxe+cobbler的全自動化安裝centos系統

來源:互聯網
上載者:User

標籤:cobbler   linux   pxe   

前言:

    基於上篇的內容,我們就已經可以搭建一個全自動化安裝centos的服務了。不過如果我們想讓它同時支援各種系統的安裝,實現起來就比較複雜了。不同的系統,要用不同的引導啟動 檔案來安裝,且還有不同的安裝源以及kickstart檔案等等。既然是複雜得事情,肯定能通過某種工具簡化,而此次我們用到的就是傳說中的cobbler來管理各個不同的源,pxe載入的核心檔案等等。Let‘s do it!

本文:

    老規矩,先描述一下加入cobbler以後整體的工作流程,已經cobbler能實現的功能。當一個需要安裝系統的機器啟動,會先從網路中dhcp伺服器擷取ip地址,以及獲知pxe所處的tftp地址和檔案,然後載入一個小的linux系統,從某個源擷取安裝程式,根據kickstart檔案安裝作業系統,雖然dhcp這個東東也可以讓cobbler來管理,不過博主還是喜歡讓它獨立出來。預設cobbler會管理我們的tftp服務,以及http提供的源,所以,除了dhcp以外的所有流程,都可以通過cobbler管理以讓整個實現更加簡便~話不多說,開戰!

    首先得安裝所需要的程式配置基本的服務,在上篇部落格介紹到的服務我們講不再介紹,請自行查看上篇部落格,我們依然會用到,tftp,dhcp,http,syslinux程式。除了之前所需要的程式,我們還需要用到另外兩個:cobbler和rsync(這裡注意一下,cobbler是由epel源提供的喲)

yum install cobbler rsync -y

    我們得得確保我們的tftp,dhcp,http已經啟動!並能提供服務d。我們還得關閉selinux。設定/etc/selinux/config檔案

#/etc/selinux/configSELINUX=disabled

啟動cobbler服務

systemctl start cobbler    #centos7系統哦

我們還得設定一下cobbler的設定檔:/etc/cobbler/settings,下面只顯示修改過的部分

server: 192.168.6.100    #設定提供cobbler服務的主機ipnext_server: 172.16.6.100   #提供pxe服務的主機ipdefault_passwd_crypted:  $1$478cc085$Ppcqhrk7rPzGR5XqWx4iu0   #重新設定密碼

上面那個密碼我們得從新設定一下,我們可以用openssl產生密碼

openssl passwd -1 -salt $(openssl rand -hex 4)

我們還得為cobbler提供安裝系統的那個pxe相關的檔案,儲存到/var/lib/cobbler/loaders目錄下

cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/cobbler/loaders/

然後我們來配置安裝源,不過在產生源之前我們得介紹幾個重要的組建

1.是我們的distro,這相當於我們的安裝源,我們可以根據不同的系統建立不同的distro,此處推薦通過import安裝鏡像來構架distro。假如我們要安裝centos6系統,並把這個distro命名為centos-6.5-x86_64

cobbler import --name=centos-6.5-x86_64 --path=/media/cdrom  #一定要確定centos安裝盤已掛載到/media/cdrom目錄下

此過程是把安裝盤的檔案複製到cobbler對應的檔案中,以構成一個distro

2.profile,cobbler使用profile來為特定的需求類別提供所需要安裝配置,我們根據上面的distro建立一個profile

cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64

預設情況下,cobbler會產生pxe的default檔案和kickstart檔案,預設應該是最小話安裝的,如果我們想要指定自己的kickstart檔案可以這樣:

 cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos6.cfg

到此我們的cobbler就配置完了。有木有很簡單!!!!現在我們同步cobbler的資料到硬碟上。這個步驟一定不能忘!!!!!不然安裝過程會失敗!!!命令如下

systemctl restart cobblercobbler sync                            #同步資料

到此,我們就可以測試了!!!以下的可以不看~~~





如果在此過程中cobbler遇到什麼問題可以用cobbler check  查看有沒有錯誤,有不少提示是可以忽略的。以下幾條不用關注,第一條是提示selinux,我們已經設定disabled了。第二條提示boot-loaders檔案,我們已經從syslinux中複製,之後後面的也不用太關注,我們是centos7 不存在xinetd的問題,debmirror在7中也沒有,fencing也不用關注。

The following are potential configuration items that you may want to fix:1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:    https://github.com/cobbler/cobbler/wiki/Selinux2 : 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.3 : file /etc/xinetd.d/rsync does not exist4 : debmirror package is not installed, it will be required to manage debian deployments and repositories5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart cobblerd and then run ‘cobbler sync‘ to apply changes.


本文出自 “機制小風風” 部落格,請務必保留此出處http://xiaofengfeng.blog.51cto.com/8193303/1887723

基於pxe+cobbler的全自動化安裝centos系統

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.