cobbler是實作自動化安裝作業系統的工具。它解決了PXE安裝時的弊端(隻能實作單一作業系統的安裝)。實際上,cobbler是對PXE二次封裝可實作多版本,多環境作業系統安裝的進階抽象工具。
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678403OKNJ.png" target="_blank"></a>
實際上,cobbler是對PXE的二次封裝。cobbler可以自動的實作PXE配置中的某些手動過程。PXE的工作原理大緻如下:
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678408RqHE.png" target="_blank"></a>
說明:
目标主機:172.16.10.9
作業系統:CentOS 6.5
1
<code><span style=</code><code>"font-size:16px;"</code><code>></code><code>## 1、安裝cobbler<br># 說明,cobbler 的 rpm 安裝包,是由epel源提供<br>yum install cobbler -y<br><br>2、安裝并啟動httpd<br>yum install httpd -y<br>service httpd start<br><br>3、啟動cobblerd服務<br>service cobblerd start<br><br>4、配置cobbler<br>## 使用cobbler chenck 指令,可以檢查cobbler配置檔案是否配置正确<br>## cobbler check 首次會出現以下提示:<br>The following are potential configuration items that you may want to fix:<br><br>1 : The 'server' field in /etc/cobbler/settings must be set to something other than \<br> localhost, or kickstarting features will not work. This should be a resolvable\<br> hostname or IP for the boot server as reachable by all machines that will use it.<br>2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must\<br> be set to something other than 127.0.0.1, and should match the IP of the boot \<br> server on the PXE network.<br>3 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run \<br> 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64\<br> netbooting, you may ensure that you have installed a *recent* version of the \<br> syslinux package installed and can ignore this message entirely. Files in \<br> this directory, should you want to support all architectures, should include\<br> pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' \<br> command is the easiest way to resolve these requirements.<br>4 : change 'disable' to 'no' in /etc/xinetd.d/rsync<br>5 : debmirror package is not installed, it will be required to manage debian \<br> deployments and repositories<br>6 : ksvalidator was not found, install pykickstart<br>7 : The default password used by the sample templates for newly installed machines \<br> (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and \<br> should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' '\<br> your-password-here'" to generate new one<br>8 : fencing tools were not found, and are required to use the (optional) power \<br> management features. install cman or fence-agents to use them<br><br>Restart cobblerd and then run 'cobbler sync' to apply changes.<br><br>## 解決辦法:<br>1、修改/etc/cobbler/settings檔案中的server參數的值為提供cobbler服務的主機相應的IP\<br> 位址或主機名,如172.16.10.9;<br>2、修改/etc/cobbler/settings檔案中的next_server參數的值為提供PXE服務的主機相應的\<br> IP位址,如172.16.10.9;<br>3、如果目前節點可以通路網際網路,執行“cobbler get-loaders”指令即可;否則,需要\<br> 安裝syslinux程式包,而後複制/usr/share/syslinux/{pxelinux.0,memu.c32}等檔案至\<br> /var/lib/cobbler/loaders/目錄中;<br>4、執行“chkconfig rsync on”指令即可;<br>5、注釋/etc/debmirror.conf檔案中的“@dists="sid";”一行;<br>6、注釋/etc/debmirror.conf檔案中的“@arches="i386";”一行;<br>7、執行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密碼,并用其替換\<br> /etc/cobbler/settings檔案中default_password_crypted參數的值;<br>8、執行“yum install cman fence-agents”指令安裝相應的程式包即可;<br>## 說明 5,6,8 步驟不是必需的。<br><br>接着重新開機cobblerd,而後執行“cobbler sync”同步新的配置至cobbler。<br></span></code>
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678437Ffcz.png" target="_blank"></a>
下面需要配置dhcp,tftp服務。說明:cobbler的運作依賴于dhcp、tftp、rsync及dns服務。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程式包提供,也可由cobbler自帶的tftp功能提供;rsync由rsync程式包提供;dns可由bind提供,也可由dnsmasq提供。
cobbler可自行管理這些服務中的部分甚至是全部,但需要配置/etc/cobbler/settings檔案中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分别進行定義。另外,由于每種服務都有着不同的實作方式,如若需要進行自定義,需要通過修改/etc/cobbler/modules.conf配置檔案中各服務的子產品參數的值來實作。
下面采用了獨立管理的方式,即不通過cobbler來管理這些服務。(常用方式)
<code><span style=</code><code>"font-size:16px;"</code><code>>yum </code><code>install</code> <code>dhcp -y<br></code><code># 編輯 /etc/dhcp/dhcpd.conf 配置檔案,内容如下: <br>option domain-name "example.com";<br>option domain-name-servers 172.16.0.1;<br>default-lease-time 600;<br>max-lease-time 7200;<br>log-facility local7;<br>subnet 172.16.0.0 netmask 255.255.0.0 {<br> range 172.16.10.14 172.16.10.99;<br> option routers 172.16.0.1;<br> next-server 172.16.10.9;<br> filename "pxelinux.0";<br>}<br>####################################<br>service dhcpd start<br></span></code>
<code><span style=</code><code>"font-size:16px;"</code><code>>yum </code><code>install</code> <code>rsync</code> <code>tftp-server -y<br>chkconfig </code><code>rsync</code> <code>on </code><code>## 當然這一步在前面cobbler check時,已經完成,非必需的<br>chkconfig rsync on<br>service xinted start<br></span></code>
<code><span style=</code><code>"font-size:16px;"</code><code>>配置 cobbler 時,需要用到cobbler指令,對cobbler指令簡單說明:(常用)<br>cobbler指令的子指令:<br> </code><code>import</code><code>:從CD光牒中導入 Install Tree。會自動定義到Repository。<br> reposync: 從網際網路中同步的Install Tree。<br> buildiso:主要用于安裝的機器不支援網卡引導,此時就需要制作ISO鏡像完成安裝。<br> distro:定義Distribution<br> </code><code>sync</code><code>:完成配置檔案的同步<br> profile:定義Profile<br> check: 檢查cobbler的配置檔案<br>其中每個子指令都有 [add|edit|copy|getks*|list|remove|rename|report] 等子指令。\<br> 具體使用可使用幫助資訊。例如: cobbler </code><code>import</code> <code>add --help檢視幫助。<br></code><code>###################################################################################################<br>使cobbler變得可用的第一步為定義distro,其可以通過為其指定外部的安裝引導核心及ramdisk\<br> 檔案的方式實作。<br>而如果已經有完整的系統安裝樹(如CentOS6的安裝鏡像)則推薦使用import直接導入的方式進行。 <br><br>cobbler使用profile來為特定的需求類别提供所需要安裝配置,即在distro的基礎上通過提供\<br> kickstart檔案來生成一個特定的系統安裝配置。<br>distro的profile可以出現在PXE的引導菜單中作為安裝的選擇之一。 <br>##################################################################################################<br><br>## 當然 kickstart 檔案事先完成。具體可參考http://guoting.blog.51cto.com/8886857/1533029<br>cobbler import --name=centos-6.5-x86_64 --path=/media/cdrom <br>cobbler profile add --name=centos6.5 --distro=centos-6.5-x86_64 \<br> --kickstart=/root/centos-6.5-x86_64.cfg <br><br>cobbler sync<br>## 詳細安裝過程可參照官網:http://www.cobblerd.org/manuals/quickstart/<br></span></code>
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_14126784420Pnl.png" target="_blank"></a>
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678452jpKw.png" target="_blank"></a>
此時,配置就完成了,可以實作自動化安裝了。
此時就可以實作自動化了。
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678553AJ2e.png" target="_blank"></a>
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678558w5Uq.png" target="_blank"></a>
上面的操作也可以通過web接口來設定,具體步驟如下:
<code><span style=</code><code>"font-size:16px;"</code><code>></code><code>###### 配置cobbler_web的認證功能<br><br>###安裝軟體<br>yum install cobbler_web <br><br>## cobbler_web支援多種認證方式,如authn_configfile、authn_ldap或authn_pam等,\<br> 預設為authn_denyall,即拒絕所有使用者登入。<br><br>### 這裡 使用authn_pam子產品認證cobbler_web使用者<br><br>## 首先修改 /etc/cobbler/modules中[authentication]段的module參數的值為authn_pam。<br>## 接着添加系統使用者,使用者名和密碼按需設定即可,例如下面的指令所示。<br>useradd cobbler<br>echo 'cblrpass' | passwd --stdin cobbler<br><br># 而後将cblradmin使用者添加至cobbler_web的admin組中。修改/etc/cobbler/users.conf檔案,<br> 将cblradmin使用者名添加為admin參數的值即可,如下所示。<br>[admins]<br>admin = "cobbler"<br><br>##最後重新開機cobblerd服務,通過http://YOUR_COBBLERD_IP/cobbler_web通路即可。<br></span></code>
下面是配置界面:
<a href="http://guoting.blog.51cto.com/attachment/201410/7/8886857_1412678569OtMu.png" target="_blank"></a>
具體配置過程,這裡不再示範。
<a href="http://down.51cto.com/data/2364926" target="_blank">附件:http://down.51cto.com/data/2364926</a>
本文轉自 羊木狼 51CTO部落格,原文連結:http://blog.51cto.com/guoting/1561035,如需轉載請自行聯系原作者