1030
阿裏雲
技術社區[雲棲]
cobbler環境搭建+IPMI/PXE遠程裝機
Red Hat發布的網絡安裝服務器套件Cobbler(在2008年左右發布),它已將 Linux網絡安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。對於我們這些在裝機領域浸淫多年,經驗豐富,老驥伏櫪,誌在千裏的民工兄弟們來說,不啻為一個晴天霹靂,杯具的是以前我竟然不會,話不多說,直接開始試驗...
實驗環境:cobbler server 10.1.6.234 (DELL 610 ubuntu12.04)
待安裝服務器 *2 (DELL 410)
關於網絡環境,都在同一個交換機下,同一vlan中,因為要用IPMI遠程安裝,網絡環境還是要設置好的。
實驗結果:ubuntu12.04、centos6.3安裝成功,debian6、ubuntu12.10安裝失敗,下麵開始部署cobbler環境。
1 安裝cobbler
2
|
apt-get install cobbler
|
4
|
apt-get install debmirror
|
6
|
apt-get install cobbler-web
|
使用到的相關環境包tftpd-hpa、dhcp3-server會自動安裝。web界麵可以通過https://10.1.6.234/cobbler_web查看,不過目前你還無法查看,因為相關用戶還沒有設置,為cobbler用戶重置密碼:
2
|
htdigest
/etc/cobbler/ users .digest "Cobbler" cobbler
|
2 配置基本安裝環境
A 關於tftpd-hpa的配置:/etc/default/tftpd-hpa(默認無需修改,你可以根據自己的環境定製)
1
|
#
/etc/default/tftpd-hpa
|
3
|
TFTP_DIRECTORY= "/var/lib/tftpboot"
|
4
|
TFTP_ADDRESS= "0.0.0.0:69"
|
5
|
TFTP_OPTIONS= "--secure"
|
通過/etc/init.d/tftpd-hpa 腳本管理
B 關於dhcp的配置:/etc/dhcp/dhcpd.conf(需要根據你的環境進行設置,我所在的是10.1.6.x網段),不過為了使用腳本管理dhcp的運行,我們先設置/etc/default/isc-dhcp-server
/etc/default/isc-dhcp-server:因為我的cobbler
server隻啟動了eth0網卡,所以dhcp監聽在eth0接口上
1
|
#
Defaults for dhcp initscript
|
2
|
#
sourced by /etc/init.d/dhcp
|
3
|
#
installed at /etc/default/isc-dhcp-server by the maintainer scripts
|
4
|
#
This is a POSIX shell fragment
|
5
|
#
On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
|
/etc/dhcp/dhcpd.conf:
01
|
ddns-update-style
none;
|
02
|
default-lease- time 600;
|
05
|
subnet
10.1.6.0 netmask 255.255.255.0 {
|
06
|
range
10.1.6.1 10.1.6.245;
|
07
|
option
routers 10.1.6.254;
|
08
|
option
broadcast-address 10.1.6.255;
|
09
|
default-lease- time 600;
|
11
|
next-server
10.1.6.234;
|
12
|
filename "pxelinux.0" ;
|
通過/etc/init.d/isc-dhcp-server 腳本管理
C 關於cobbler的配置,cobbler安裝完成後,還是有很多目錄要使用的,主要用到的解釋如下:
/var/lib/cobbler 存儲導入的鏡像的配置信息,kickstarts目錄存放kickstarts腳本,snippets目錄存放在kickstat配置文件中可以執行的腳本,config目錄提供配置信息,還有其他目錄基本上無需配置。
/var/www/cobbler 是導入發行版的操作係統的數據目錄,ks_mirror裏麵是導入的發行版係統,images裏麵是所有發行版的kernel和initrd,用於遠程網絡啟動。
/var/log/cobbler 是日誌目錄
/etc/cobbler 是cobbler的配置文件目錄,settings是主配置文件,裏麵還有一些相關配置模版,users.conf是用戶,users.digest是用戶及密碼
別看這麼多目錄,其實安裝cobbler完成後,基本配置也是不需要我們修改的,settings配置文件是主配置文件,有很多參數可以配置,詳細的選項信息可以查看:https://cobbler.github.com/manuals/2.2.3/4/2_-_Cobbler_Settings.html
D 關於IPMI的配置,因為要遠程安裝,在DELL服務器中,IPMI這個工具還是很給力的,三台機器都需要設置IPMI,因為cobbler server有操作係統,所以可以在係統中通過ipmitool命令進行設置,而兩台客戶機因為還沒有操作係統,所以要提前設置好ipmi,兩台客戶機如下設置:
設置IPMI地址及用戶密碼,開機按照提示按crtl+E進入IPMI配置界麵

選擇LAN Parameters,設置該客戶機的IPMI地址是172.16.6.200

然後選擇LAN User Configuration,設置root密碼,然後保存退出。

為了在遠程能抓到客戶端的啟動過程,還需要設置BIOS,開機按F2進入BIOS進行設置

選擇Integrated Devices,因為隻有一塊網卡,所以設置從NIC1 啟動PXE

選擇Serial Communication,設置串口,然後保存退出。

3 初始化cobbler安裝環境
前麵說了我實驗了四個發行版,成功兩個,失敗兩個,為了快速安裝都是導入相關iso作為安裝源的,所以第一步是準備相關iso發行版,我的如下:
2
|
├──
CentOS-6.3-x86_64-bin-DVD1.iso
|
3
|
├──
debian-6.0.2.1-amd64-CD-1.iso
|
4
|
├──
ubuntu-12.04-server-amd64.iso
|
5
|
└──
ubuntu-12.10-server-amd64.iso
|
以ubuntu12.04為例進行講解,因為用這個iso可以成功安裝客戶機
A 導入iso鏡像
1
|
mount -o
loop ubuntu-12.04-server-amd64.iso /mnt
|
2
|
cobbler import --path=/mnt
--name=ubuntu12.04
|
B 查看導入的結果:cobbler list,也可以使用cobbler profile/distro list查看
很可惜ubuntu12.04默認導入的 profile/distro配置有問題,所以我們必須修改。
修改distro
1
|
cobbler
distro edit --name=ubuntu12.04-x86_64 \
|
2
|
--kernel=/var/www/cobbler/ks_mirror/ubuntu12.04/ install /netboot/ubuntu-installer/amd64/linux
\
|
3
|
--initrd=/var/www/cobbler/ks_mirror/ubuntu12.04/ install /netboot/ubuntu-installer/amd64/initrd.gz
--arch=x86_64 \
|
4
|
--breed=ubuntu
--os-version=precise
|
創建/var/lib/cobbler/kickstarts/ubuntu12.04.preseed,該文件為ubuntu12.04的preseed文件。
01
|
touch /var/lib/cobbler/kickstarts/ubuntu12.04.preseed
|
04
|
d-i
debian-installer/locale string en_US
|
05
|
d-i
debian-installer/language string en
|
06
|
d-i
debian-installer/country string US
|
07
|
d-i
console-setup/ask_detect boolean false
|
08
|
d-i
keyboard-configuration/layoutcode string us
|
09
|
d-i
localechooser/supported-locales zh_CN.UTF-8
|
11
|
###
Network configuration
|
12
|
d-i
netcfg/ enable boolean false
|
13
|
d-i
netcfg/choose_interface select auto
|
14
|
d-i
netcfg/disable_autoconfig boolean true
|
15
|
d-i
netcfg/dhcp_failed note
|
16
|
d-i
netcfg/dhcp_options select Do
not configure the network at this time
|
19
|
d-i
mirror/country string manual
|
20
|
d-i
mirror/http/ hostname string
10.1.6.234
|
21
|
d-i
mirror/http/directory string /ubuntu12.04
|
22
|
d-i
mirror/http/proxy string
|
23
|
d-i
mirror/udeb/components multiselect main, restricted
|
24
|
#d-i
mirror/http/mirror select mirrors.163.com
|
25
|
#d-i
mirror/suite string quantal
|
27
|
###
Clock and time zone setup
|
28
|
d-i
clock-setup/utc boolean true
|
29
|
d-i
clock-setup/ntp boolean true
|
30
|
d-i
clock-setup/ntp-server string 10.1.1.2
|
31
|
d-i time /zone
string Asia/Shanghai
|
34
|
d-i
partman-auto/disk string /dev/sda
|
35
|
d-i
partman-auto/method string regular
|
36
|
d-i
partman-lvm/device_remove_lvm boolean true
|
37
|
d-i
partman-md/device_remove_md boolean true
|
38
|
d-i
partman-lvm/confirm boolean true
|
39
|
#d-i
partman-auto/choose_recipe select atomic
|
40
|
d-i
partman-auto/expert_recipe string \
|
42
|
50000
50000 50000 ext4 \
|
51
|
8000
8000 8000 linux-swap \
|
55
|
10000
1000 1000000 ext4 \
|
62
|
d-i
partman/default_filesystem string ext4
|
64
|
d-i
partman-partitioning/confirm_write_new_label boolean true
|
65
|
d-i
partman/choose_partition select finish
|
66
|
d-i
partman/confirm boolean true
|
67
|
d-i
partman/confirm_nooverwrite boolean true
|
68
|
d-i
partman/mount_style select uuid
|
70
|
###
Base system installation
|
71
|
#d-i
base-installer/install-recommends boolean true
|
72
|
#d-i
base-installer/kernel/image string linux-generic
|
73
|
d-i
base-installer/kernel/image string linux-server
|
76
|
d-i passwd /root-login
boolean true
|
77
|
d-i passwd /root-password
password 123456
|
78
|
d-i passwd /root-password-again
password 123456
|
79
|
d-i
user-setup/allow-password-weak boolean true
|
80
|
d-i
user-setup/encrypt-home boolean false
|
81
|
d-i passwd / make -user
boolean false
|
84
|
tasksel
tasksel/first multiselect standard
|
85
|
d-i
pkgsel/include string openssh-server
|
86
|
d-i
pkgsel/upgrade select none
|
87
|
d-i
pkgsel/language-packs multiselect de, en, zh
|
88
|
d-i
pkgsel/update-policy select none
|
89
|
d-i
pkgsel/updatedb boolean true
|
91
|
###
Boot loader installation
|
92
|
d-i
grub-installer/only_debian boolean true
|
93
|
d-i
grub-installer/with_other_os boolean true
|
95
|
###
Finishing up the installation
|
96
|
d-i
finish- install /reboot_in_progress
note
|
preseed解釋可見:https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
修改profile
1
|
cobbler
profile edit --name=ubuntu12.04-x86_64 \
|
2
|
--kickstart=/var/lib/cobbler/kickstarts/ubuntu12.04.preseed
|
cobbler命令有很多參數可以使用:
1
|
cobbler
<distro|profile|system|repo|image|mgmtclass|package| file >
...
|
2
|
[add|edit|copy|getks*|list|remove|rename|report]
[options|--help]
|
3
|
cobbler
<aclsetup|buildiso| import |list|replicate|report|reposync| sync |validateks|version>
[options|--help]
|
常用的有:distro類似於發行版,profile類似於該發行版的一些配置,system對安裝的機器做具體配置,是根據mac地址生效的。
cobbler check 檢查配置是否正確
cobbler list 列出所有的cobbler元素
cobbler distro/profile list 單獨列出該信息
cobbler sync 同步信息 在修改完cobbler配置後,都需要同步信息
cobbler report 顯示詳細的元素信息
C 設置本地源,在ubuntu12.04.preseed配置文件中有用
2
|
ln -s
/var/www/cobbler/ks_mirror/ubuntu12.04 ubuntu12.04
|
D 修改pxelinux.cfg配置,因為使用dell的機器,如果啟動時沒有設置速率,在遠程安裝的時候,抓不到屏幕,對於410以上的機器速率是115200,2950之類是57600
/var/lib/tftpboot/pxelinux.cfg/default,在append行末添加console=ttyS1,115200
03
|
MENU
TITLE Cobbler | https://fedorahosted.org/cobbler
|
11
|
LABEL
ubuntu12.04-x86_64
|
12
|
kernel
/images/ubuntu12.04-x86_64/linux
|
13
|
MENU
LABEL ubuntu12.04-x86_64
|
14
|
append
initrd=/images/ubuntu12.04-x86_64/initrd.gz locale= locale=en_US priority=critical text auto url=https://10.1.6.234/cblr/svc/ op /ks/profile/ubuntu12.04-x86_64 hostname =ubuntu12.04-x86-64
domain= local .lan
suite=precise console=ttyS1,115200
|
E 在安裝過程中會彈出類似的xxx/binary-amd64/Packages was corrupt,這是因為在相關目錄下沒有Packages這個文件,隻要進入該目錄創建Packages文件就可以
F 開始安裝遠程客戶機,在cobbler server的eth0上綁定IPMI的網段地址。
1
|
ifconfig eth0:1
172.16.6.252 netmask 255.255.255.0
|
3
|
eth0:1
Link encap:Ethernet HWaddr 18:03:73:f0:a7:03
|
4
|
inet
addr:172.16.6.252 Bcast:172.16.6.255 Mask:255.255.255.0
|
5
|
UP
BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
6
|
Interrupt:36
Memory:d6000000-d6012800
|
7
|
#####ping到客戶端ipmi地址,發現是通的
|
然後開兩個窗口分別執行如下IPMI命令
2
|
ipmitool
-I lanplus -H 172.16.6.200 -U root -P 123456 sol activate
|
4
|
ipmitool
-I lanplus -H 172.16.6.200 -U root -P 123456 chassis bootdev pxe
|
6
|
ipmitool
-I lanplus -H 172.16.6.200 -U root -P 123456 chassis power reset
|
G 享受過程吧...

以下是我的配置文件設置的小問題,需要手動敲兩下回車:
這個我配置文件(preseed)設置的不配置網卡,不知道為什麼出現這個,後麵再研究一下配置文件

這一步不需要設置,否則安裝過程會比較慢...

兩個回車後,就可以坐等係統重啟了...

H Centos6.3安裝
步驟的設置和ubuntu12.04的安裝過程一樣,不過不需要修改distro/profile,直接import即可。
下麵是centos6.3.ks的配置文件
01
|
#platform=x86,
AMD64, or Intel EM64T
|
02
|
#
System authorization information
|
03
|
auth
--useshadow --enablemd5
|
04
|
#
System bootloader configuration
|
05
|
bootloader
--location=mbr --driveorder=sda
|
06
|
#
Partition clearing information
|
07
|
clearpart
--all --initlabel
|
08
|
#
Use text mode install
|
10
|
#
Firewall configuration
|
12
|
#
Run the Setup Agent on first boot
|
18
|
#
Use network installation
|
19
|
#url
--url=https://10.1.6.234/cblr/links/CentOS6.3-x86_64
|
21
|
#
If any cobbler repo definitions were referenced in the kickstart profile, include them here.
|
22
|
#repo
--name=source-1 --baseurl=https://10.1.6.234/cobbler/ks_mirror/CentOS6.3
|
25
|
#network
--bootproto=dhcp --device=em1 --onboot=on
|
26
|
$SNIPPET( 'network_config' )
|
27
|
#
Reboot after installation
|
31
|
#
SELinux configuration
|
33
|
#
Do not configure the X Window System
|
36
|
timezone
Asia/Shanghai
|
37
|
#
Install OS instead of upgrade
|
39
|
#
Clear the Master Boot Record
|
42
|
partition
/ --fstype= "ext4" --asprimary
--size=50000
|
45
|
$SNIPPET( 'log_ks_pre' )
|
46
|
$SNIPPET( 'kickstart_start' )
|
47
|
$SNIPPET( 'pre_install_network_config' )
|
48
|
#
Enable installation monitoring
|
49
|
$SNIPPET( 'pre_anamon' )
|
51
|
$SNIPPET( 'func_install_if_enabled' )
|
52
|
$SNIPPET( 'puppet_install_if_enabled' )
|
54
|
$SNIPPET( 'log_ks_post' )
|
55
|
#
Start yum configuration
|
57
|
#
End yum configuration
|
58
|
$SNIPPET( 'post_install_kernel_options' )
|
59
|
$SNIPPET( 'post_install_network_config' )
|
60
|
$SNIPPET( 'func_register_if_enabled' )
|
61
|
$SNIPPET( 'puppet_register_if_enabled' )
|
62
|
$SNIPPET( 'download_config_files' )
|
63
|
$SNIPPET( 'koan_environment' )
|
64
|
$SNIPPET( 'redhat_register' )
|
65
|
$SNIPPET( 'cobbler_register' )
|
66
|
#
Enable post-install boot notification
|
67
|
$SNIPPET( 'post_anamon' )
|
69
|
$SNIPPET( 'kickstart_done' )
|
這次沒有出現ubuntu12.04需要手動幹預的情況,IPMI從PXE啟動後,直接坐等客戶機係統安裝完成後重啟...
相關設置preseed/kickstarts資料:
https://www.debian.org/releases/stable/example-preseed.txt
https://help.ubuntu.com/12.10/installation-guide/example-preseed.txt
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-options.html
收集已經安裝完成係統的preseed信息:
獲取你的Kickstarts配置文件,在Red Hat係列中system-config-kickstart可以幫助你生成一個kickstart文件,或者查看/root/anaconda-ks.cfg,關於debian係統則可以apt-get
install debconf-utils然後debconf-get-selections --installer > preseed.cfg
最後更新:2017-04-03 22:15:52