一、准备工作
[root@cobbler ~]# iptables -nL Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination [root@cobbler ~]# getenforce Disabled [root@cobbler ~]# crontab -l 0 * * * * /usr/sbin/ntpdate 210.72.145.44 64.147.116.229 time.nist.gov
Cobbler服务器相关信息:
IP地址:192.168.49.210
虚拟网络类型:NAT网络(VMware网络)
服务:DHCP、TFTP、rsync、xinetd、Apache、Cobbler
二、部署Cobbler
1) 安装epel源
rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
安装相关依赖包:
yum -y install gcc gcc-c++ cman fence-agents pykickstart debmirror python-ctypes
2) 安装DHCP、TFTP、rsync、xinetd、Apache
yum -y install dhcp tftp-server rsync xinetd httpd
3) 安装cobbler
yum -y install cobbler cobbler-web
[root@CentOS6 ~]# rpm -ql cobbler # 查看安装的文件,下面列出部分。
/etc/cobbler # 配置文件目录
/etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
/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模块配置文件
/var/lib/cobbler # Cobbler数据目录
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默认存放kickstart文件
/var/lib/cobbler/loaders # 存放的各种引导程序
/var/www/cobbler # 系统安装镜像目录
/var/www/cobbler/ks_mirror # 导入的系统镜像列表
/var/www/cobbler/images # 导入的系统镜像启动文件
/var/www/cobbler/repo_mirror # yum源存储目录
/var/log/cobbler # 日志目录
/var/log/cobbler/install.log # 客户端系统安装日志
/var/log/cobbler/cobbler.log # cobbler日志
4) 执行cobbler check检查
[root@mylinux1 ~]# cobbler check The following are potential configuration items that you may want to fix: 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 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support 8 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support 9 : 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 Restart cobblerd and then run ‘cobbler sync‘ to apply changes.
下面简单的解释一下上面的错误:
1.改变server的主机名
2.第二是DHCP的next_server改成172.16.1.101
3.改xined的tftp disable等于no
4.指定目录/var/lib/cobbler/loaders缺少一些网络启动项
5./etc/xinetd.d/rsync 也改成no
6.bug,已经存在
7.debin系统的源
8.生成密码并设置openssl passwd -1 -salt
9.fencing tools 高可用的硬件设备。
既然知道了问题所在,那就根据上面的问题逐一进行解决:
①修改server为cobbler服务器地址
[root@cobbler ~]# sed -n ‘/^server/p‘ /etc/cobbler/settings server: 127.0.0.1 [root@cobbler ~]# sed -i ‘/^server/s/127\.0\.0\.1/192\.168\.49\.210/‘ /etc/cobbler/settings [root@cobbler ~]# sed -n ‘/^server/p‘ /etc/cobbler/settings server: 192.168.49.210
②修改next_server为cobbler服务器地址
[root@cobbler ~]# sed -n ‘/next_server/p‘ /etc/cobbler/settings next_server: 127.0.0.1 [root@cobbler ~]# sed -i ‘/next_server/s/127\.0\.0\.1/192\.168\.49\.210/‘ /etc/cobbler/settings [root@cobbler ~]# sed -n ‘/next_server/p‘ /etc/cobbler/settings next_server: 192.168.49.210
③修改tftp配置文件取消禁用
[root@cobbler ~]# sed -n ‘/disable/p‘ /etc/xinetd.d/tftp disable= yes [root@cobbler ~]# sed -i ‘/disable/s/yes/no/‘ /etc/xinetd.d/tftp [root@cobbler ~]# sed -n ‘/disable/p‘ /etc/xinetd.d/tftp disable= no
④使用cobbler get-loaders下载缺少的网络启动项
[root@cobbler ~]# cobbler get-loaders task started: 2017-07-14_172925_get_loaders task started (id=Download Bootloader Content, time=Fri Jul 14 17:29:25 2017) downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE ***
⑤修改rsync配置文件取消禁用
[root@cobbler ~]# sed -n ‘/disable/p‘ /etc/xinetd.d/rsync disable= yes [root@cobbler ~]# sed -i ‘/disable/s/yes/no/‘ /etc/xinetd.d/rsync [root@cobbler ~]# sed -n ‘/disable/p‘ /etc/xinetd.d/rsync disable= no
⑥这条是个bug,/etc/xinetd.d/rsync文件已经存在
⑦因为并不打算批量部署安装debin,所以这里注释掉相关选项即可
[root@cobbler ~]# sed -n ‘/^\@dists/p‘ /etc/debmirror.conf @dists="sid"; [root@cobbler ~]# sed -i ‘/^\@dists/s/^/#/‘ /etc/debmirror.conf [root@cobbler ~]# sed -n ‘/@dists/p‘ /etc/debmirror.conf #@dists="sid";
⑧同上,注释掉相关选项
[root@cobbler ~]# sed -n ‘/\@arches/p‘ /etc/debmirror.conf @arches="i386"; [root@cobbler ~]# sed -i ‘/\@arches/s/^/#/‘ /etc/debmirror.conf [root@cobbler ~]# sed -n ‘/\@arches/p‘ /etc/debmirror.conf #@arches="i386";
⑨使用openssl生成系统根用户密码
[root@cobbler ~]# openssl passwd -1 -salt ‘cobbler‘ ‘123456‘ $1$cobbler$sqDDOBeLKJVmxTCZr52/11 [root@cobbler ~]# grep default_password_crypted /etc/cobbler/settings default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac." [root@cobbler ~]# sed -i ‘/default_password_crypted/s/^/#/‘ /etc/cobbler/settings [root@cobbler ~]# sed -i ‘/#default_password_crypted/adefault_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"‘ /etc/cobbler/settings [root@cobbler ~]# sed -n ‘/default_password_crypted/p‘ /etc/cobbler/settings #default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac." default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"
5) 重启cobbler服务
[root@cobbler ~]# /etc/init.d/cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ]
6) 指定cobbler sync使配置生效
[root@cobbler ~]# cobbler sync task started: 2017-07-14_174744_sync task started (id=Sync, time=Fri Jul 14 17:47:44 2017) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
7) 修改配置文件,让cobbler接管dhcp服务
[root@cobbler ~]# sed -n ‘/^manage_dhcp/p‘ /etc/cobbler/settings manage_dhcp: 0 [root@cobbler ~]# sed -i ‘/^manage_dhcp/s/0/1/‘ /etc/cobbler/settings [root@cobbler ~]# sed -n ‘/^manage_dhcp/p‘ /etc/cobbler/settings manage_dhcp: 1 [root@cobbler ~]# sed -n ‘/pxe_just_once/p‘ /etc/cobbler/settings pxe_just_once: 0 [root@cobbler ~]# sed -i ‘/pxe_just_once/s/0/1/‘ /etc/cobbler/settings [root@cobbler ~]# sed -n ‘/pxe_just_once/p‘ /etc/cobbler/settings pxe_just_once: 1
8) 修改dhcp配置文件
[root@cobbler ~]# cat /etc/dhcp/dhcpd.conf
.......
subnet 192.168.49.0 netmask 255.255.255.0 {
option routers 192.168.49.2;
option domain-name-servers 192.168.49.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.49.3 192.168.49.40;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.49.210;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}
.........
9) 重启cobbler
[root@cobbler ~]# /etc/init.d/cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ]
10) 配置apache并启动服务
[root@cobbler ~]# sed -n ‘/#ServerName/p‘ /etc/httpd/conf/httpd.conf #ServerName www.example.com:80 [root@cobbler ~]# sed -i ‘/#ServerName/aServerName cobbler.contoso.com‘ /etc/httpd/conf/httpd.conf [root@cobbler ~]# sed -n ‘/^ServerName/p‘ /etc/httpd/conf/httpd.conf ServerName cobbler.contoso.com [root@cobbler ~]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
11) 设置相关服务开机自启动
[root@cobbler ~]# chkconfig httpd on [root@cobbler ~]# chkconfig dhcpd on [root@cobbler ~]# chkconfig xinetd on [root@cobbler ~]# chkconfig cobblerd on
12) 同步配置
[root@cobbler ~]# cobbler sync task started: 2017-07-14_223810_sync task started (id=Sync, time=Fri Jul 14 22:38:10 2017) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86_64.efi removing: /var/lib/tftpboot/grub/grub-x86.efi removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: Starting dhcpd: [ OK ] received on stderr: running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
13) 挂载系统映像并导入cobbler
[root@cobbler ~]# mount /dev/sr0 /mnt/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@cobbler ~]# cobbler import --name=centos6.5 --arch=x86_64 --path=/mnt task started: 2017-07-15_004129_import task started (id=Media import, time=Sat Jul 15 00:41:29 2017) Found a candidate signature: breed=redhat, version=rhel6 Found a matching signature: breed=redhat, version=rhel6 Adding distros from path /var/www/cobbler/ks_mirror/centos6.5-x86_64: creating new distro: centos6.5-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos6.5-x86_64 -> /var/www/cobbler/links/centos6.5-x86_64 creating new profile: centos6.5-x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/centos6.5-x86_64 for centos6.5-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos6.5-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/centos6.5-x86_64 looking for /var/www/cobbler/ks_mirror/centos6.5-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos6.5-x86_64/repodata *** TASK COMPLETE ***
14) 检查导入结果
[root@cobbler ~]# cobbler distro list centos6.5-x86_64 [root@cobbler ~]# cobbler profile list centos6.5-x86_64 [root@cobbler ~]# cobbler distro report Name : centos6.5-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/centos6.5-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/centos6.5-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {‘tree‘: ‘http://@@http_server@@/cblr/links/centos6.5-x86_64‘} Management Classes : [] OS Version : rhel6 Owners : [‘admin‘] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {}
三、客户端开机测试
创建一个网络类型为NAT方式的VMware虚拟机,不载入任何系统介质,开机后从网络启动:
出现上述页面,说明cobbler已经工作了,点击Centos6.5,
系统已经开始自动安装,
安装过程没有任何手工操作,这里就不再对安装过程逐一截图,cobbler部署系统安装至此结束。
本文出自 “IT小二郎” 博客,请务必保留此出处http://jerry12356.blog.51cto.com/4308715/1949473
原文地址:http://jerry12356.blog.51cto.com/4308715/1949473