PXE技术与RPL技术不同之处为RPL是静态路由,PXE是动态路由。RPL是根据网卡上的ID号加上其他记录组成的一个Frame(帧)向服务器发出请求。而服务器中已有这个ID数据,匹配成功则进行远程启动。PXE则是根据服务器端收到的工件站MAC地址,使用DHCP服务为这个MAC地址指定个IP地址。每次启动可能同一台工作站有与上次启动有不同的IP,即动态分配地址。下以客户端引导过程说明PXE的原理:
客户端开机后,PXE BootROM(自启动芯片)获得控制权之前执行自我测试,然后以广播形式发出一个请求FIND帧。如果服务器收到客户端所送出的要求,就会送回DHCP回应,包括用户端的IP地址、预设通信通道,以及开机映像文件;否则服务器会忽略这个要求。
客户端收到服务器发回的响应后则会回应一个帧,以请求传送启动所需文件,并把自己的MAC地址写到服务器端的Netnames.db文件中。将有更多的消息在客户端与服务器之间应答,用于决定启动参数。
BootROM由TFTP通信协议从服务器下载开机映像文档。
客户端使用TFTP协议接收启动文件后,将控制权转交启动块以引导操作系统,完成远程启动。
KickStart是一种无人职守安装方式。KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为ks.cfg的文件;在其后的安装过程中(不只局限于生成KickStart安装文件的机器)当出现要求填写参数的情况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装。
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、以及yum仓库、构造系统ISO镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。
Cobbler提供以下服务集成:
* PXE服务支持
* DHCP服务管理
* DNS服务管理
* 电源管理
* Kickstart服务支持
* yum仓库管理
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日志
yum install epel-release
yum install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes cman pykickstart –y
vim /etc/cobbler/settings #Cobbler主配置文件
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings
# set to 1 to enable Cobbler's DHCP management features.
# the choice of DHCP management engine is in /etc/cobbler/modules.conf
manage_dhcp: 1
# set to 1 to enable Cobbler's RSYNC management features.
manage_rsync: 1
# if using cobbler with manage_dhcp, put the IP address
# of the cobbler server here so that PXE booting guests can find it
# if you do not set this correctly, this will be manifested in TFTP open timeouts.
next_server: 192.168.56.6
# this is the address of the cobbler server -- as it is used
# by systems during the install process, it must be the address
# or hostname of the system as those systems can see the server.
# if you have a server that appears differently to different subnets
# (dual homed, etc), you need to read the --server-override section
# of the manpage for how that works.
server: 192.168.56.6
getsebool
service iptables stop
chkconfig iptables off
设置 'disable' 为 'no'
sed -i '/disable/c\\tdisable\t\t\t= no' /etc/xinetd.d/tftp
sed -i 's/\=\ yes/\=\ no/g' /etc/xinetd.d/rsync
sed -i 's@#LoadModule@LoadModule@g' /etc/httpd/conf.d/wsgi.conf
这里生成密钥和配置默认密钥,ks文件引用
openssl passwd -1 -salt 'random-phrase-here' 'wq'
$1$random-p$29HCOY0msGT.4xVuIl6Gp.
加入cobbler配置
vim /etc/cobbler/settings
grep default_password_crypted /etc/cobbler/settings#修改为如下配置
default_password_crypted: "$1$random-p$29HCOY0msGT.4xVuIl6Gp."
vim /etc/cobbler/dhcp.template
allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
subnet 192.168.56.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.56.100 192.168.56.254;
option domain-name-servers 192.168.0.1;
option routers 192.168.56.1;
option subnet-mask 255.255.255.0;
default-lease-time 1800;
max-lease-time 3600;
next-server 192.168.56.6;
filename "pxelinux.0";
}
/sbin/service httpd start
/sbin/service dhcpd start
/sbin/service xinetd start
/sbin/service cobblerd start
/sbin/chkconfig httpd on
/sbin/chkconfig dhcpd on
/sbin/chkconfig xinetd on
/sbin/chkconfig tftp on
/sbin/chkconfig cobblerd on
cobbler get-loaders
yum -y install debmirror
修改 /etc/debmirror.conf 配置文件,注释掉 @dists 和 @arches 两行
sed -i 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i 's|@arches=.*|#@arches=|' /etc/debmirror.conf
cobbler check
The following are potential configuration items that you may want to fix:无需处理
1 : reposync is not installed, need for cobbler reposync, install/upgrade yum-utils?
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.
cobbler sync
命令参考
cobbler --help
cobbler distro --help
cobbler distro add --help
Cobbler配置文件存放在/etc/cobbler下
导入的系统发行版,repos镜像和kickstart文件都放置在/var/www/cobbler
目录下。确保/var目录有足够的空间来存储这些文件。
此目录存储和Cobbler profiles、systems、distros相关的配置。
web日志存放点:
/var/log/httpd/access_log
/var/log/httpd/error_log
/var/log/httpd/ssl_access_log
/var/log/httpd/ssl_error_log
Cobbler日志:
/var/log/cobbler/cobbler.log
/var/log/cobbler/install.log
通过Cobbler日志可以获取系统的安装状态
1. 注意下载的ISO文件要核对文件的md5值,确保数据完整性
md5sum xx.iso
2.创建目录
mkdir -p /var/os/Linux/Centos/x86_64/Centos6.7/dvd
3.挂载
mount -o loop/var/iso/Linux/Centos/x86_64/xx.iso
/var/os/Linux/Centos/x86_64/Centos6.7/dvd
cobbler import --path=/xx --name=centos6.7 --arch=x86_64
cobbler list 列出配置
cobbler report 详细
cobbler profile find --distro=centos6.7-x86_64 #查看配置是否存在
cobbler profile remove --name=centos6.7-x86_64 #删除配置文件
cobbler distro remove --name=centos6.7-x86_64 #删除distro
cobbler profile find --distro=centos6.7-x86_64 #再查看配置已无
ks目录位置
/var/lib/cobbler/kickstarts/
默认的ks位置
/var/lib/cobbler/kickstarts/sample.ks
更改指定系统版本对应的ks配置文件
cp /var/lib/cobbler/kickstarts/ sample.ks centos6.7-x86_64.ks
cobbler profile add --name=centos6.7 --distro= centos6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.7-x86_64.ks
cobbler check
cobbler sync
KS示例:
#platform=x86, AMD64, or Intel EM64T
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=$tree
#Root password
rootpw root
# System authorization information
auth --useshadow--enablemd5
# Use graphical mode install
graphical
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# System timezone
timezone Asia/Shanghai
# Network information
network --bootproto=static --device=eth0 --gateway=192.168.56.1 --ip=192.168.56.99 --nameserver=192.168.56.99 --netmask=255.255.255.0 --hostname=host99 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --ondisk=sda --size=8000
part /boot --fstype="ext4" --ondisk=sda --size=200
part swap --fstype="swap" --size=1000
# Reboot after installation
reboot
# Clear the Master Boot Record
zerombr
%packages
@ X Window System
@ Desktop
@ Development tools
gcc*
%end
Cobbler web界面是一个很好的前端,非常容易管理Cobbler。可以添加和删除system、distro、profile,可以查看、编辑distros、profiles、subprofiles、systems、repos、kickstart文件。
yum -y install cobbler-web
为已存在的用户cobbler重置密码:
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
添加新用户:
htdigest /etc/cobbler/users.digest "Cobbler" newname
sed -i 's/authn_denyall/authn_configfile/g'
/etc/cobbler/modules.conf
/etc/init.d/cobblerd restart
/etc/init.d/httpd restart
浏览器访问登录页面https://192.168.xx.xx/cobbler_web
cobbler system add --name=xx --hostname=xx --mac=xx
--interface=ethx --ip-address=xx --subnet=xx --gateway=xx
--static=1 --profile=xx
yum install cman ipmitool -y 电源管理(需要硬件支持)