cobbler是實現自動化安裝操做系統的工具。它解決了PXE安裝時的弊端(只能實現單一操做系統的安裝)。實際上,cobbler是對PXE二次封裝可實現多版本,多環境操做系統安裝的高級抽象工具。linux
實際上,cobbler是對PXE的二次封裝。cobbler能夠自動的實現PXE配置中的某些手動過程。PXE的工做原理大體以下:web
關於PXE具體配置,可參考http://guoting.blog.51cto.com/8886857/1533029centos
說明:bash
目標主機:172.16.10.9app
操做系統:CentOS 6.5dom
## 一、安裝cobbler
# 說明,cobbler 的 rpm 安裝包,是由epel源提供
yum install cobbler -y
二、安裝並啓動httpd
yum install httpd -y
service httpd start
三、啓動cobblerd服務
service cobblerd start
四、配置cobbler
## 使用cobbler chenck 命令,能夠檢查cobbler配置文件是否配置正確
## 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 : 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.
4 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : debmirror package is not installed, it will be required to manage debian \
deployments and repositories
6 : ksvalidator was not found, install pykickstart
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.
## 解決辦法:
一、修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP\
地址或主機名,如172.16.10.9;
二、修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的\
IP地址,如172.16.10.9;
三、若是當前節點能夠訪問互聯網,執行「cobbler get-loaders」命令便可;不然,須要\
安裝syslinux程序包,然後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至\
/var/lib/cobbler/loaders/目錄中;
四、執行「chkconfig rsync on」命令便可;
五、註釋/etc/debmirror.conf文件中的「@dists="sid";」一行;
六、註釋/etc/debmirror.conf文件中的「@arches="i386";」一行;
七、執行「openssl passwd -1 -salt $(openssl rand -hex 4)」生成密碼,並用其替換\
/etc/cobbler/settings文件中default_password_crypted參數的值;
八、執行「yum install cman fence-agents」命令安裝相應的程序包便可;
## 說明 5,6,8 步驟不是必需的。
接着重啓cobblerd,然後執行「cobbler sync」同步新的配置至cobbler。
下面須要配置dhcp,tftp服務。說明:cobbler的運行依賴於dhcp、tftp、rsync及dns服務。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler自帶的tftp功能提供;rsync由rsync程序包提供;dns可由bind提供,也可由dnsmasq提供。 ide
cobbler可自行管理這些服務中的部分甚至是所有,但須要配置/etc/cobbler/settings文件中的「manage_dhcp」、「manage_tftpd」、「manage_rsync」和「manage_dns」分別進行定義。另外,因爲每種服務都有着不一樣的實現方式,如若須要進行自定義,須要經過修改/etc/cobbler/modules.conf配置文件中各服務的模塊參數的值來實現。 工具
下面採用了獨立管理的方式,即不經過cobbler來管理這些服務。(經常使用方式)ui
yum install dhcp -y
# 編輯 /etc/dhcp/dhcpd.conf 配置文件,內容以下:
option domain-name "example.com";
option domain-name-servers 172.16.0.1;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.10.14 172.16.10.99;
option routers 172.16.0.1;
next-server 172.16.10.9;
filename "pxelinux.0";
}
####################################
service dhcpd start
yum install rsync tftp-server -y
chkconfig rsync on ## 固然這一步在前面cobbler check時,已經完成,非必需的
chkconfig rsync on
service xinted start
配置 cobbler 時,須要用到cobbler命令,對cobbler命令簡單說明:(經常使用)
cobbler命令的子命令:
import:從光盤中導入 Install Tree。會自動定義到Repository。
reposync: 從互聯網中同步的Install Tree。
buildiso:主要用於安裝的機器不支持網卡引導,此時就須要製做ISO鏡像完成安裝。
distro:定義Distribution
sync:完成配置文件的同步
profile:定義Profile
check: 檢查cobbler的配置文件
其中每一個子命令都有 [add|edit|copy|getks*|list|remove|rename|report] 等子命令。\
具體使用可以使用幫助信息。例如: cobbler import add --help查看幫助。
###################################################################################################
使cobbler變得可用的第一步爲定義distro,其能夠經過爲其指定外部的安裝引導內核及ramdisk\
文件的方式實現。
而若是已經有完整的系統安裝樹(如CentOS6的安裝鏡像)則推薦使用import直接導入的方式進行。
cobbler使用profile來爲特定的需求類別提供所須要安裝配置,即在distro的基礎上經過提供\
kickstart文件來生成一個特定的系統安裝配置。
distro的profile能夠出如今PXE的引導菜單中做爲安裝的選擇之一。
##################################################################################################
## 固然 kickstart 文件事先完成。具體可參考http://guoting.blog.51cto.com/8886857/1533029
cobbler import --name=centos-6.5-x86_64 --path=/media/cdrom
cobbler profile add --name=centos6.5 --distro=centos-6.5-x86_64 \
--kickstart=/root/centos-6.5-x86_64.cfg
cobbler sync
## 詳細安裝過程可參照官網:http://www.cobblerd.org/manuals/quickstart/
此時,配置就完成了,能夠實現自動化安裝了。this
此時就能夠實現自動化了。
上面的操做也能夠經過web接口來設置,具體步驟以下:
###### 配置cobbler_web的認證功能
###安裝軟件
yum install cobbler_web
## cobbler_web支持多種認證方式,如authn_configfile、authn_ldap或authn_pam等,\
默認爲authn_denyall,即拒絕全部用戶登陸。
### 這裏 使用authn_pam模塊認證cobbler_web用戶
## 首先修改 /etc/cobbler/modules中[authentication]段的module參數的值爲authn_pam。
## 接着添加系統用戶,用戶名和密碼按需設定便可,例以下面的命令所示。
useradd cobbler
echo 'cblrpass' | passwd --stdin cobbler
# 然後將cblradmin用戶添加至cobbler_web的admin組中。修改/etc/cobbler/users.conf文件,
將cblradmin用戶名添加爲admin參數的值便可,以下所示。
[admins]
admin = "cobbler"
##最後重啓cobblerd服務,經過http://YOUR_COBBLERD_IP/cobbler_web訪問便可。
下面是配置界面:
具體配置過程,這裏再也不演示。