用virtualbox安装虚拟机,用做cobbler服务器。
root@cobbler:~# apt-cache search cobbler
cobbler - Install server
cobbler-common - Cobbler Install server - common files
cobbler-enlist - Cobbler enlistment tool
cobbler-web - Cobbler Install server - web interface
koan - kickstart-over-a-network (koan)
python-cobbler - Install server - python libraries.
python-koan - kickstart-over-a-network (koan) - python libraries
root@cobbler:~# apt-get install cobbler
。。。
root@cobbler:~# which cobbler
/usr/bin/cobbler
root@cobbler:~# ls /etc/cobbler/
auth.conf cobbler-ubuntu-import.conf iso pxe tftpd.template zone_templates
cheetah_macros cobbler_web.conf ldap reporting ubuntu-server.preseed
cobbler_bash completions modules.conf rsync.exclude users.conf
cobbler.conf dhcp.template mongodb.conf rsync.template users.digest
cobblerd dnsmasq.template named.template secondary.template version
cobblerd_rotate import_rsync_whitelist power settings zone.template
root@cobbler:~# ps -ef | grep cobbler
root 4552 1 0 16:03 ? 00:00:01 /usr/bin/python /usr/bin/cobblerd --no-daemonize
安装完成后,cobbler和apache的服务都会启动。
root@cobbler:~# curl -I 10.10.30.5/cobbler/
HTTP/1.1 200 OK
Date: Thu, 23 Feb 2017 08:10:33 GMT
Server: Apache/2.4.7 (Ubuntu)
Content-Type: text/html;charset=UTF-8
运行cobbler check检查配置
root@cobbler:/etc/cobbler# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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.
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
Restart cobblerd and then run 'cobbler sync' to apply changes.
根据上面的提示修复错误。
其中:
debmirror是用来建立Debinan系统镜像源的工具,
createrepo是用来建立RedHat系列镜像源的工具。
# apt-get install debmirror
安装完成后,配置一下debmirror。生成/etc/debmirror.conf配置文件
root@cobbler:~# ls /etc/deb*
/etc/debconf.conf /etc/debian_version
root@cobbler:~# cp /usr/share/doc/debmirror/examples/debmirror.conf /etc/
root@cobbler:~# vi /etc/debmirror.conf
修改/etc/debmirror.conf配置文件,注释掉@dists和@arches两行
@dists="precise";
@sections="main,main/debian-installer,universe,restricted,multiverse";
@arches="i386";
如果不注释掉上面说的两行,使用cobbler check时,会提示:
root@cobbler:~# cobbler check
The following are potential configuration items that you may want to fix:
1 : some network boot-loaders are missing from /var/lib/cobbler/loaders...
2 : comment out 'dists' on /etc/debmirror.conf for proper debian support
3 : comment out 'arches' on /etc/debmirror.conf for proper debian support
Restart cobblerd and then run 'cobbler sync' to apply changes.
使修改生效:
root@cobbler:~# service cobbler restart
cobbler stop/waiting
cobbler start/running, process 6227
root@cobbler:~# ps -ef | grep cobbler
root 6227 1 1 17:19 ? 00:00:00 /usr/bin/python /usr/bin/cobblerd --no-daemonize
root@cobbler:~# cobbler sync
...
*** TASK COMPLETE ***
再检查:
root@cobbler:~# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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.
Restart cobblerd and then run 'cobbler sync' to apply changes.
Cobbler目录说明:
1、Cobbler配置文件目录:/etc/cobbler
/etc/cobbler/settings #cobbler主配置文件
/etc/cobbler/dhcp.template #DHCP服务的配置模板
/etc/cobbler/tftpd.template #tftp服务的配置模板
/etc/cobbler/rsync.template #rsync服务的配置模板
/etc/cobbler/iso #iso模板配置文件
/etc/cobbler/pxe #pxe模板文件
/etc/cobbler/power #电源的配置文件
/etc/cobbler/users.conf #Web服务授权配置文件
/etc/cobbler/users.digest #用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template #DNS服务的配置模板
/etc/cobbler/modules.conf #Cobbler模块配置文件
2、Cobbler数据目录:/var/lib/cobbler
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/triggers #Cobbler命令
/var/lib/cobbler/kickstarts #默认存放kickstart文件
/var/lib/cobbler/loaders #存放的各种引导程序
3、系统安装镜像目录:/var/www/cobbler
/var/www/cobbler/ks_mirror #导入的系统镜像列表
/var/www/cobbler/images #导入的系统镜像启动文件
/var/www/cobbler/repo_mirror #yum源存储目录
4、日志目录:/var/log/cobbler
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志
命令:
cobbler profile report --name CentOS-5.10-x86_64 #查看profile设置
cobbler distro report --name CentOS-5.10-x86_64 #查看安装镜像文件信息
cobbler profile remove --name=CentOS-5.10-x86_64 #移除profile
cobbler profile add --name=CentOS-5.10-x86_64 --distro=CentOS-5.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-5.10-x86_64.ks #添加
cobbler profile edit --name=CentOS-5.10-x86_64 --distro=CentOS-5.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-5.10-x86_64.ks #编辑
命令:cobbler profile add|edit|remove --name=安装引导名 --distro=系统镜像名 --kickstart=kickstart自动安装文件路径
--name:自定义的安装引导名,注意不能重复
--distro:系统安装镜像名,用cobbler distro list可以查看
--kickstart:与系统镜像文件相关联的kickstart自动安装文件
#查看Cobbler列表
cobbler list
cobbler report
cobbler profile report
cobbler distro list
The main settings file for cobbler is /etc/cobbler/settings. Cobbler also supports Dynamic Settings, so it is no longer required to manually edit this file if this feature is enabled. This file is YAML-formatted, and with dynamic settings enabled augeas is used to modify its contents.
Whether dynamic settings are enabled or not, if you directly edit this file you must restart cobblerd. When modified with the dynamic settings CLI command or the web GUI, changes take affect immediately and do not require a restart.
apt-get install vsftpd
apt-get install tftpd-hpa
apt-get install dnsmasq
cobbler本身具备管理dnsmasq和tftpd-hpa的功能。所以我们只需要配置cobbler就可以了。
修改配置文件 /etc/cobbler/settings
需修改和修改后的值如下:
manage_dhcp: 1
manage_dns: 1
manage_tftpd: 1
restart_dhcp: 1
restart_dns: 1
pxe_just_once: 1
next_server:
server:
选项 next_server 用在 DHCP 配置文件中,向机器告知提供引导文件的服务器地址。
选项 server 在机器安装期间用于引用 Cobbler 服务器地址。
选项 pxe_just_once 预防将机器中的安装循环配置为始终从网络引导。激活此选项时,机器告诉 Cobbler 安装已完成。Cobbler 将系统对象的 netboot 标志更改为 false,这会强制机器从本地磁盘引导
修改配置文件/etc/cobbler/modules.conf,修改后
# egrep -v '^#|^[ \t]*$' /etc/cobbler/modules.conf
[authentication]
module = authn_configfile
[authorization]
module = authz_allowall
[dns]
module = manage_dnsmasq # uses dnsmasq
[dhcp]
module = manage_dnsmasq # uses dnsmasq
[tftpd]
module = manage_in_tftpd # defaut, uses the system's tftp server, in this example, use tftpd-hpa
由于我们配置了cobbler接管DHCP、DNS和tFTP服务,所以我们不需要单独修改dnsmasq和tftpd-hpa的配置文件,只需要修改Cobbler中DHCP、DNS和tFTP相应的配置模板即可。
Cobbler会自动帮助我们做同步工作。
修改/etc/cobbler/dnsmasq.template
For most uses, you’ll only need to modify this block:
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.210,192.168.1.211;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.254;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
同步配置到dnsmasq
# cobbler sync
之后,查看dnsmasq配置文件,已经修改:
root@cobbler:~# cat /etc/dnsmasq.conf
# Cobbler generated configuration file for dnsmasq
# Fri Feb 24 03:14:08 2017
# resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts
dhcp-range=192.168.1.5,192.168.1.200
dhcp-option=3,10.10.30.8
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0
dhcp-boot=net:ia64,/var/lib/cobbler/elilo-3.6-ia64.efi
修改配置文件/etc/cobbler/tftpd.template
默认不用修改
netstat -tunlp
root@cobbler:~# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address tate PID/Program name
tcp 0 0 0.0.0.0:53 0.0.0.0:* ISTEN 8751/dnsmasq
tcp 0 0 0.0.0.0:21 0.0.0.0:* ISTEN 7149/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* ISTEN 968/sshd
tcp 0 0 127.0.0.1:25151 0.0.0.0:* ISTEN 8692/python
tcp6 0 0 :::53 :::* ISTEN 8751/dnsmasq
tcp6 0 0 :::22 :::* ISTEN 968/sshd
tcp6 0 0 :::80 :::* ISTEN 6736/apache2
udp 0 0 0.0.0.0:59879 0.0.0.0:* 681/dhclient
udp 0 0 0.0.0.0:53 0.0.0.0:* 8751/dnsmasq
udp 0 0 0.0.0.0:45622 0.0.0.0:* 683/dhclient
udp 0 0 0.0.0.0:67 0.0.0.0:* 8751/dnsmasq
udp 0 0 0.0.0.0:68 0.0.0.0:* 681/dhclient
udp 0 0 0.0.0.0:68 0.0.0.0:* 683/dhclient
udp6 0 0 :::46865 :::* 681/dhclient
udp6 0 0 :::59879 :::* 683/dhclient
udp6 0 0 :::53 :::* 8751/dnsmasq
udp6 0 0 :::69 :::* 4335/in.tftpd
服务说明:
80 Aapche服务
53 dnsmasqt程序的dns服务
67 dnsmasq程序的DHCP服务
69 tftp-hpa程序的tftp服务
25151 Apache2 的cobbler-web站点支持
生成默认模板下客户端系统安装完成之后root账号登录密码
root@cobbler:~# openssl passwd -1 -salt 'cobbler' '123456'
$1$cobler$XJnisBweZJlhL651HxAM00
root@cobbler:~# vim /etc/cobbler/settings
default_password_crypted: "$1$cobler$XJnisBweZJlhL651HxAM00"
客户机使用pxe网络安装成功后的登录用户名和密码:root/123456
root@cobbler:~# service cobbler restart
cobbler stop/waiting
cobbler start/running, process 8692
root@cobbler:~# cobbler sync
root@cobbler:~# ls /mnt
root@cobbler:~# mount -o loop /dev/cdrom /mnt
root@cobbler:~# ls /mnt
boot dists doc EFI install isolinux md5sum.txt pics pool preseed README.diskdefines ubuntu
root@cobbler:~#
root@cobbler:~# cobbler list
distros:
profiles:
systems:
repos:
images:
mgmtclasses:
packages:
files:
root@cobbler:~# cobbler distro list
root@cobbler:~# cobbler import --name=ubuntu14045 --arch=x86_64 --path=/mnt
task started: 2017-02-24_103721_import
...
*** TASK COMPLETE ***
root@cobbler:~#
root@cobbler:~# cobbler distro list
ubuntu14045-x86_64
root@cobbler:~# cobbler list
distros:
ubuntu14045-x86_64
profiles:
ubuntu14045-x86_64
systems:
repos:
ubuntu14045-x86_64
images:
mgmtclasses:
packages:
files:
root@cobbler:~# cobbler profile list
ubuntu14045-x86_64
root@cobbler:~# cobbler profile report
Name : ubuntu14045-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : ubuntu14045-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.seed
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <>
Red Hat Management Server : <>
Repos : []
Server Override : <>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : virbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
从cobbler profile report命令的输出中,可以看到默认使用到的kickstart文件信息:
Kickstart: /var/lib/cobbler/kickstarts/sample.seed
ubuntu自动安装可以使用preseeding或kickstart。详细使用可以分别参考官方安装文档。
用virutalbox新建一个VM,设置为网络启动。
启动vm,正常的话, 会进入界面:
默认情况下VirtualBox下载安装后是不支持PXE启动的,启动的时候是会报下面错误:
“FATAL:No bootable medium found!System halted.”
这是因为缺少pxe扩展包所导致,通过下面这个地址下载扩展包,windows环境中可以通过双机形式安装。
下载地址:https://www.virtualbox.org/wiki/Downloads
选择下载对应VirtualBox的拓展包安装即可,最后,在全局设定——>拓展中可以看到成功安装的拓展包。
最后,在设置——系统中更改启动顺序,优先使用网路启动,如果你的网络环境支持PXE启动,就可以使用网络安装了。
PXE-E53:No boot filename received客户端收到了至少一个有效的DHCP/BOOTP应答,但没有启动文件名可下载。
PXE-E53: NO boot filename received
PXE-MOF: Exiting Intel Boot Agent
No Boot Device Found.
查看dnsmasq.conf配置文件,发现配置的IP范围与cobbler服务器不在同一个网段。
dhcp-range=10.10.30.100,10.10.30.199
修改后,重启dnsmasq:
root@cobbler:~# service dnsmasq restart
* Restarting DNS forwarder and DHCP server dnsmasq
From PXE error codes
• PXE-E53: No boot filename received. The client received at least one valid DHCP/BOOTP offer, but does not have a boot filename to download. There are several possible causes:
1) The DHCP Server and the PXE Server were located on the same server, but one of them was moved to a different server. This would result in an incorrect PXE Server configuration.
To resolve this issue, reinstall the PXE Server component of the Altiris Deployment Solution.
2) The DHCP relay agent, either a Proxy DHCP Server or a switch configured with helper addresses, is not configured correctly. For example, if DHCP and PXE are on separate servers, the DHCP relay agent needs to have both addresses in its configuration.
To resolve this issue, correct the DHCP relay agent configuration.
3) If the Microsoft DHCP service is installed on the PXE server, but is disabled or unconfigured, Altiris PXE Setup configures PXE to work with the local DHCP service (even if the DHCP service is disabled). This causes the PXE server to not respond to PXE clients that get a DHCP address from DHCP services running elsewhere on the network.
To resolve this issue, remove Microsoft DHCP services from the PXE server and reinstall the PXE Server component of the Altiris Deployment Solution.
转向:http://www.linuxidc.com/Linux/2014-03/98986.htm
官方文档 和 http://blog.csdn.net/gcogle/article/details/52767135
Refer to the Red Hat documentation (http://docs.redhat.com/docs/enUS/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/ch-kickstart2.html) for detailed instructions.
Cobbler中默认的kickstart文件目录为,/var/lib/cobbler/kickstarts/,默认的Ks文件为 /var/lib/cobbler/kickstarts/sample.ks。
root@cobbler:/etc/cobbler# ls /var/lib/cobbler/kickstarts/
default.ks legacy.ks sample_end.ks sample_esxi5.ks sample.seed
esxi4-ks.cfg pxerescue.ks sample_esx4.ks sample.ks ubuntu-server-arm.seed
esxi5-ks.cfg sample_autoyast.xml sample_esxi4.ks sample_old.seed ubuntu-server.preseed
通常手动安装时,安装程序根据在安装过程中的选择创建一个简单的kickstart文件 /root/anaconda-ks.cfg,在它的基础上做修改即可。
修改配置文件,语法:
# cobbler profile edit --name <cobbler profile list 中显示的名称> --kickstart="/var/lib/cobbler/kickstarts/<新编辑好的ks文件名称>"
查看已修改的配置文件,语法:
# cobbler profile getks --name
使用sample.ks文件进行关联
root@cobbler:~# cobbler profile edit --name=ubuntu14045-x86_64 --kickstart=/var/lib/cobbler/kickstarts/sample.ks
root@cobbler:~# cobbler profile report
Name : ubuntu14045-x86_64
...
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata : {}
修改完成后要重启cobbler,再cobbler sync。
我们可以通过在kickstart中引用如下语句来设置你的用户密码:
rootpw --iscrypted $1$6.5.pvtY$78zocSFzXqL6o2RiKy7Ow0
用户密码的加密可以通过如下命令来生成:
# echo "Your password" | openssl passwd -1 -stdin
$1$YybbL2kO$Z35pIGEghtr7AQwUaH7GN1
也可以在kickstart文件中直接引用cobbler变量 $default_password_crypted,如下:
# Root password
rootpw --iscrypted $default_password_crypted
配置default_password_crypted默认值:
可以通过 配置 /etc/cobbler/settings 中 default_password_crypted为新值。如下:
default_password_crypted: "$1$YybbL2kO$Z35pIGEghtr7AQwUaH7GN1"
默认安装程序不会修改CentOS的下载源配置文件。我们可以通过配置 /etc/cobbler/setting 中的 yum_post_install_mirror参数为1。
然后在kickstart文件中%post部分添加如下的行:
# Start yum configuration
$yum_config_stanza
# End yum configuration
以添加mirror.163.com的源为例,在kickstart文件中%post部分添加如下的行:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS6-Base-163.repo
增加其它第三方的方法也类似
这样cobbler源就会自动添加到新安装好的操作系统中,文件路径和文件名为 /etc/yum.repos.d/cobbler-config.repo。
# sudo apt-get install cobbler-web
#配置web界面用户文件,生成密码
root@cobbler:/etc/cobbler# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password:
Re-type new password:
root@cobbler:/etc/cobbler# cat users.conf
[admins]
admin = ""
cobbler = ""
root@cobbler:/etc/cobbler# vi /etc/cobbler/pxe/pxedefault.template
root@cobbler:/etc/cobbler# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
root@cobbler:/etc/cobbler# service cobbler restart
cobbler stop/waiting
cobbler start/running, process 1909
root@cobbler:/etc/cobbler# cobbler sync
PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动。协议分为client和server两端:
PXE client在网卡的ROM中,当计算机引导时,BIOS把PXE client调入内存执行,并显示出命令菜单,经用户选择后,PXE client将放置在远端的操作系统通过网络下载到本地运行。
PXE server在cobbler服务器上。
PXE协议的成功运行需要解决以下两个问题:
既然是通过网络传输,那么计算机在启动时,它的IP地址由谁来配置;
通过什么协议下载Linux内核和根文件系统
对于第一个问题,可以通过DHCP Server解决,由DHCP server来给PXE client分配一个IP地址,DHCP Server是用来给DHCP Client动态分配IP地址的协议,不过由于这里是给PXE Client分配IP地址,所以在配置DHCP Server时,需要增加相应的PXE特有配置。
至于第二个问题,在PXE client所在的ROM中,已经存在了TFTP Client。PXE Client使用TFTP Client,通过TFTP协议到TFTP Server上下载所需的文件。
这样,PXE协议运行的条件就具备了。
客户端引导过程说明PXE的原理。
(1)客户端开机后,PXE BootROM(自启动芯片)获得控制权之前执行自我测试,然后以广播形式发出一个请求FIND帧。
(2)如果服务器收到客户端所送出的要求,就会送回DHCP回应,包括用户端的IP地址、预设通信通道,以及开机映像文件;否则服务器会忽略这个要求。
(3)客户端收到服务器发回的响应后则会回应一个帧,以请求传送启动所需文件,并把自己的MAC地址写到服务器端的Netnames.db文件中。
(4)将有更多的消息在客户端与服务器之间应答,用于决定启动参数。BootROM由TFTP通信协议从服务器下载开机映像文档。客户端使用TFTP协议接收启动文件后,将控制权转交启动块以引导操作系统,完成远程启动。
参考: https://my.oschina.net/guol/blog/114563
关于tftpd-hpa的配置:/etc/default/tftpd-hpa(默认无需修改,你可以根据自己的环境定制)
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
通过/etc/init.d/tftpd-hpa 脚本管理
1 官方:http://cobbler.github.io/manuals/2.8.0/
2 官方入门:http://cobbler.github.io/manuals/quickstart/
3 http://www.tuicool.com/articles/Z7BnamU
4 cobbler环境搭建+IPMI/PXE远程装机:https://my.oschina.net/guol/blog/114563
5 安装实例:http://www.osyunwei.com/archives/7606.html