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