cobbler 自動化安裝系統

    網絡安裝服務器套件 Cobbler(補鞋匠)從前,我們一直在做裝機民工這份很有前途的職業。自打若干年前 Red Hat 推出了 Kickstart,此後我們頓覺身價倍增。不再需要刻了光盤一臺一臺地安裝 Linux,只要搞定 PXE、DHCP、TFTP,還有那滿屏眼花繚亂不知所云的 Kickstart 腳本,我們就可以像哈里波特一樣,輕點魔棒,瞬間安裝上百臺服務器。這一堆花裏胡哨的東西可不是一般人都能整明白的,沒有大專以上學歷,通不過英語四級, 根本別想玩轉。總而言之,這是一份多麼有前途,多麼有技術含量的工作啊。很不幸,Red Hat 最新(Cobbler項目最初在2008年左右發佈)發佈了網絡安裝服務器套件 Cobbler(補鞋匠),它已將 Linux 網絡安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。對於我們這些在裝機領域浸淫多年,經驗豐富,老驥伏櫪,志在千里的民工兄弟們來說,不啻爲一個晴天霹靂。

下面演示cobbler的安裝

[root@cobbler ~]# yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd -y

重新啓動apache

[root@cobbler ~]#/etc/init.d/httpd restart

啓動cobbler

[root@cobbler ~]# /etc/init.d/cobblerd start
[root@cobbler ~]# /etc/init.d/cobblerd restart

檢查安裝條件

[root@cobbler ~]#cobbler check
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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
6 : file /etc/xinetd.d/rsync does not exist
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

以上問題基本上需要解決了才能安裝

vi /etc/cobbler/settings

server: 10.89.1.15     (修改爲你這檯安裝cobbler的機器)

next_server: 10.89.1.15 (修改爲你這檯安裝cobbler的機器)

manage_dhcp: 1          (“0”修改爲“1”)

default_password_crypted: "$1$oldboy$fXF8f078vI9J/q9XyXA8e/"

注意:以上密碼是使用下面的命令生成的

[root@cobbler ~]# openssl passwd -1 -salt 'oldboy' 'oldboy'
$1$oldboy$fXF8f078vI9J/q9XyXA8e/
[root@cobbler ~]#cobbler get-loaders

vim /etc/xinetd.d/rsync

disable                 = no


vim /etc/xinetd.d/tftp

disable                 = no

重新啓動一下服務

[root@cobbler ~]# /etc/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]

[root@cobbler ~]# /etc/init.d/cobblerd restart
Stopping cobbler daemon:                                   [  OK  ]
Starting cobbler daemon:                                   [  OK  ]
[root@cobbler ~]# vim /etc/cobbler/dhcp.template

  此處修改爲你的cobbler服務器所在的網段信息

 subnet 10.89.1.0 netmask 255.255.255.0 {

     option routers             10.89.1.254;   (網關地址)

     option domain-name-servers 10.7.10.1;      (DNS地址)

     option subnet-mask         255.255.255.0;   (子網掩碼)

     range dynamic-bootp        10.89.1.100 10.89.1.119;(DHCP自動給機器分配的ip範圍)

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

[root@cobbler ~]#cobbler check

1.service dhcpd is not running

解決辦法

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

#/etc/init.d/cobblerd restart

#cobbler sync

2.file /etc/xinetd.d/rsync does not exist 

這個問題可以不用管,最後在檢查一下安裝環境

[root@cobbler kickstarts]# cobbler check
The following are potential configuration items that you may want to fix:

1 : file /etc/xinetd.d/rsync does not exist
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

出現上面的信息就可以安裝了

以下以安裝一臺虛擬機爲例

本機先掛載鏡像包

[root@cobbler ~]#mount /dev/cdrom /mnt

導入鏡像包

[root@cobbler ~]#cobbler import --path=/mnt/ --name=CentOS-7.3-x86_64 --arch=x86_64

導入後鏡像包位於

[root@cobbler ~]# cd /var/www/cobbler/ks_mirror/
[root@cobbler ks_mirror]# ll
total 8
drwxr-xr-x 8 root root 4096 Dec  5 21:20 CentOS-7.3-x86_64
drwxr-xr-x 2 root root 4096 Apr  5 15:20 config配置

KS文件放置位置

[root@cobbler ks_mirror]# cd /var/lib/cobbler/kickstarts/

上傳KS配置文件 CentOS-7.3-x86_64.cfg   (**文件中的登錄用戶名:root 密碼:oldboy**)

 #cat CentOS-7.3-x86_64.cfg
#Kickstart Configurator by Alvin
#platform =x86, AMD64, or Inter EM64T
#System language
lang en_US
#System keyboard
keyboard us
#System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#rootpw --iscrypted $1$ops-node$7hqdpgEmIE7Z0RbtQkxW20
#Use text mode install
text
#Install OS instead of upgrade
install 
#User NFS installation Media
url --url=$tree
#url --url=http://192.168.8.22/CentOS-7.1-x86_64
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part /swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization information
auth --useshadow --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
#Enable installation monitoring
$SNIPPET('pre_anamon')
%end

#Package install information
%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
openssl-devel
zlib-devel
OpenIPMI-tools
nmap
screen
%end

%post
systemctl disable postfix.service
%end
[root@cobbler kickstarts]# cobbler profile edit --name=CentOS-7.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.3-x86_64.cfg 
[root@cobbler kickstarts]# cobbler profile edit --name=CentOS-7.3-x86_64 --kopts='net.ifnames=0 biosdevname=0'

[root@cobbler ~]# cobbler sync

設置待安裝機器的ip,網關,dns 等信息

[root@cobbler ~]# cobbler system add --name=alvin --mac=00:50:56:32:4E:C7 --profile=CentOS-7.3-x86_64 --ip-address=10.89.1.113 --subnet=255.255.255.0 --gateway=10.89.1.254 --interface=eth0 --static=1 --hostname=kk.com --name-servers="8.8.8.8"

注意:網卡地址mac是待安裝機器

下面開始安裝客戶端電腦

  1. 待安裝的機器開機

  2. 進入bios設置待安裝的電腦從網卡啓動

  3. 開始自動安裝

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章