一:PXE、Kickstart與Cobbler的概念:node
PXE(preboot execute environment,預啓動執行環境)是由Intel公司開發的技術,須要網卡的硬件支持,工做於C/S的網絡模式,支持客戶端經過網絡從服務器下載映像,並支持客戶端機器經過網絡啓動操做系統,在啓動過程當中,客戶端須要從服務器分配IP地址、掩碼、網關以及相關的配置文件路徑,再用TFTP(trivial file transfer protocol)協議從服務器下載一個啓動軟件包到本機內存中執行,由這個啓動軟件包完成客戶端的基本軟件設置,從而引導預先安裝在服務器中的終端操做系統,PXE能夠引導多種操做系統,如:centos、redhat、windows 7等,因此說PXE是一直引導啓動方式,用於引導PC或服務器的啓動。python
Kickstart是一種實現操做系統無人值守的安裝方式,須要先定義一個配置文件,裏面定義好root密碼、分區、安裝的包等等參數,此文件通常稱爲ks.cfg,客戶端根據ks.cfg定義的ISO下載內核vmlinux和安裝包,進行磁盤的分區與格式化,定義好的rpm包的安裝,甚至是系統的參數優化等。linux
Cobbler翻譯爲中文是補鞋匠,可是在linux方面則是一個免費的用於系統安裝部署的開源軟件,cobbler是對PXE技術的二次基於python的開發,提供了CLI(命令行)和Web的管理方式,另外還提供了API(應用程序編程接口)接口,方便二次開發使用,相比PXE,cobbler支持多系統同時引導,而PXE只能一次引導一個系統的安裝,cobbler一般與開源軟件puppet、saltstack配合使用,進行操做系統的批量安裝與部署優化,從而實現大批量linux系統的無人值守安裝與服務部署,大大提高運維的工做效率,Cobbler是一種更高級的無人值守的系統安裝方式,由於其能夠同時引導多個不一樣的操做系統的安裝與部署,可是Kickstart只能引導一個。web
1.一、Kickstart流程:編程
二:Cobbler組件:vim
一、distro:定義安裝的系統發行版,好比centos6.7是一個發行版,還能夠根據不一樣的kickstack文件安裝出不一樣業務場景的系統。windows
2.profile:定義配置文件,結合distro能夠實現安裝不一樣環境的操做系統。centos
3.system:爲指定的主機配置特有的信息,好比主機名等。安全
4.repos:定義yum源。服務器
5.images:定義在虛擬化環境中定義虛擬機的磁盤。
三:cobbler安裝與配置:
一、安裝cobbler:
[root@linux-node1 ~]# yum install cobbler cobbler-web pykickstart httpd
cobbler #cobbler服務的主程序包 cobbler-web #web管理界面 pykickstart #檢查語法是否正確 httpd #http服務器
二、啓動服務:
[root@linux-node1 ~]# systemctl start httpd [root@linux-node1 ~]# systemctl start cobblerd [root@linux-node1 ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@linux-node1 ~]# systemctl enable cobblerd Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
三、檢查配置文件:
[root@linux-node1 ~]# 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
4.錯誤修正:
1.[root@linux-node1 ~]# vim /etc/cobbler/settings
next_server: 192.168.56.11 server: 192.168.56.11
2.
yum install xinetd systemctl enable xinetd systemctl start rsyncd.service systemctl restart cobblerd.service systemctl enable rsyncd.service cobbler check
3.準備啓動文件:
cp /usr/share/syslinux/pxelinux.0 /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
4.修改默認密碼
[root@linux-node1 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)
5.安裝配置dhcp
yum install dhcp
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@linux-node1 cobbler]# cat /etc/dhcp/dhcpd.conf | grep -v "#" | grep -v "^$"
option domain-name "jack.com";
option domain-name-servers 192.168.56.11;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.56.0 netmask 255.255.255.0 {
range 192.168.56.100 192.168.56.200;
option routers 192.168.56.2;
next-server 192.168.56.11;
filename "pxelinux.0";
}
6.同步:
[root@linux-node1 ~]# cobbler sync task started: 2016-05-23_121731_sync task started (id=Sync, time=Mon May 23 12:17:31 2016) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk 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 images generating PXE configuration files generating PXE menu structure rendering TFTPD files
七、配置distro:
查看幫助:
[root@linux-node1 ~]# cobbler --help usage ===== cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|getks*|list|remove|rename|report] [options|--help] cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
[root@linux-node1 ~]# cobbler distro --help
[root@linux-node1 ~]# cobbler distro add --help
導入:
cobbler import --path=/mnt/ --name="Centos-7.2-x86_64" --kickstart=/var/lib/cobbler/kickstarts/cobbler-centos-7.2-x86_64.cfg
重啓測試:
8.web管理:cobbler-web
[root@linux-node1 ~]# vim /etc/cobbler/modules.conf
module = authn_configfile #認證,默認是虛擬用戶認證
九、生成密碼:
[root@linux-node1 ~]# htdigest -c /etc/cobbler/users.digest Cobbler tom #添加一個叫tom的用戶,放在Cobbler組
Adding password for cblradmin in realm cobbler.
New password:
Re-type new password:
[root@linux-node1 ~]#
10.使用https訪問web,如:https://192.168.56.11/cobbler_web
三:自定義Centos 7的kickstack文件:
一、須要圖形界面下安裝system-config-kickstack命令啓動圖形進行自定義安裝包,以下:
[root@localhost ~]# yum install system-config-kickstack -y
二、打開配置界面,開始自定義kickstack應答文件:
基礎配置:
二、http 跳過
三、配置引導安裝:
四、分區部分:
五、網絡設置,暫不須要
六、認證,默認便可:
七、安全設置:
八、安裝界面:
九、安裝包包選擇,能夠自定義,通常選擇最小化安裝,最後保存爲一個文件,內容以下: