(注:图来自煮酒品茶)
# rpm -Uvh http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
或者
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum install -y cobbler rsync tftp dhcphttpd cman pykickstart debmirror tftp-server xinetd python-ctypes
# yum install -y ed patch perlperl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
# chkconfig httpd on
# chkconfig dhcpd on
# chkconfig xinetd on
# chkconfig cobblerd on
# sed -i '/SELINUX/s/enforcing/disabled/'/etc/selinux/config
# setenforce 0
# chkconfig iptables off
# service iptables stop
# vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
# service httpd start
# PASSWORD=”`echo "jiayuan.com" |openssl passwd -1 -salt 'randomstr' �Cstdin`”
# sed -is@"^default_password_crypted.*$"@"default_password_crypted:\"$PASSWORD\""@g /etc/cobbler/settings
# sed -i 's/server: 127.0.0.1/server:10.240.216.1/g' /etc/cobbler/settings
# sed -i 's/next_server:127.0.0.1/next_server: 10.240.216.1/g' /etc/cobbler/settings
# 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
# sed -i 's/pxe_just_once: 0/pxe_just_once:1/g' /etc/cobbler/settings
# cat /etc/cobbler/dhcp.template
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = optionvendor-class-identifier;
option pxe-system-type code 93 = unsignedinteger 16;
subnet 10.240.216.0 netmask 255.255.255.0 {
option routers 10.240.216.254; #路由地址
#option domain-name-servers 8.8.8.8; #DNSserver地址
option subnet-mask 255.255.255.0; #子网掩码
#rangedynamic-bootp 10.240.216.210.240.216.200; #分配IP地址段
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
filename "pxelinux.0";
}
subnet 10.240.217.0 netmask 255.255.255.0 {
option routers 10.240.217.254;
option subnet-mask 255.255.255.0;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
# service cobblerd start
# cobbler check
# cobbler get-loaders
# sed -i '/disable/c\\tdisable\t\t\t= no'/etc/xinetd.d/tftp
# sed -i -e 's/\=\ yes/\=\ no/g'/etc/xinetd.d/rsync
# service xinetd start
# cat /etc/dhcp/dhcpd.conf
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = optionvendor-class-identifier;
option pxe-system-type code 93 = unsignedinteger 16;
#可以添加多子网(保持和dhcp.template一致)
subnet 10.240.216.0 netmask 255.255.255.0 {
option routers 10.240.216.254;
option subnet-mask 255.255.255.0;
filename "/pxelinux.0";
#rangedynamic-bootp 10.240.216.210.240.216.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 10.240.216.1;
}
subnet 10.240.217.0 netmask 255.255.255.0 {
option routers 10.240.217.254;
option subnet-mask 255.255.255.0;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server 10.240.216.1;
}
# group for Cobbler DHCP tag: default
group {
}
# service dhcpd start
# sed -i "s/^@dists/#@dists/g"/etc/debmirror.conf
# sed -i "s/^@arches/#@arches/g"/etc/debmirror.conf
# service cobblerd restart
# cobbler sync
# mkdir /mnt/rhel6.5
# mkdir /mnt/rhel7.0
# mount -t iso9660 -o loop,ro/opt/rhel-server-6.5-x86_64-dvd.iso /mnt/rhel6.5
# cobbler import --name=redhat6.5--arch=x86_64 --path=/mnt/rhel6.5
# cobbler distro list
# cobbler profile list
# cobbler report
# vim rhel6.5.ks
install
text
key --skip
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw root
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
url --url=$tree
$SNIPPET('network_config')
bootloader --location=mbr --driveorder=sda
zerombr yes
clearpart --all
part /boot --fstype ext4 --size=200
#part / --fstype ext4 --size=20000
part swap --fstype swap --size=4096
#part /u01 --fstype ext4 --grow --size=200
reboot
%packages
@base
@core
@server-policy
ipmitool
OpenIPMI
openssh-clients
net-snmp
%post
# cobbler profile edit--name=redhat6.5-x86_64 --distro=redhat6.5-x86_64--kickstart=/var/lib/cobbler/kickstarts/rhel6.5.ks
# cobbler sync ###下面贴出完整信息,注意红色部分
task started: 2015-05-25_154818_sync
task started (id=Sync, time=Mon May 2515:48:18 2015)
running pre-sync triggers
cleaning trees
removing:/var/www/cobbler/images/redhat6.5-x86_64
removing:/var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/images
removing:/var/lib/tftpboot/images/redhat6.5-x86_64
removing:/var/lib/tftpboot/s390x/profile_list
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/var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink/var/lib/cobbler/loaders/grub-x86_64.efi ->/var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: redhat6.5-x86_64
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/vmlinuz ->/var/lib/tftpboot/images/redhat6.5-x86_64/vmlinuz
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/initrd.img ->/var/lib/tftpboot/images/redhat6.5-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: redhat6.5-x86_64
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/vmlinuz ->/var/www/cobbler/images/redhat6.5-x86_64/vmlinuz
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/initrd.img ->/var/www/cobbler/images/redhat6.5-x86_64/initrd.img
Writing template files for redhat6.5-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro:redhat6.5-x86_64
cleaning link caches
rendering Rsync files
running post-sync triggers
running python triggers from/var/lib/cobbler/triggers/sync/post/*
running python triggercobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout: Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ] <-- 必须要看到dhcpd服务启动才行
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 ***
<--到此就可以从一台新机器通过pxe启动系统了 -->
# yum -y install cobbler-web
# sed -i's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf
# /etc/init.d/cobblerd restart
# /etc/init.d/httpd restart
访问地址:https://10.240.216.1/cobbler_web
cobbler system add --name bgw-os-node151--hostname bgw-os-node151 --profileceph
cobbler system edit --namebgw-os-node151 --interface eth0 --macB4:99:BA:BF:1F:EA --ip-address 10.240.216.151 --netmask 255.255.255.0 --gateway 10.240.216.254 --static 1
cobbler system edit --namebgw-os-node151 --interface eth1 --macB4:99:BA:BF:1F:EC --ip-address 10.240.217.151 --netmask 255.255.255.0 --static1
因为设置了只初始化一次,如果还想让系统能够通过pxe来启动重装,那么你需要做下面的操作
cobbler system remove --name bgw-os-node151
问题1:[root@bgw-os-node1 ~]# cobbler check
httpd does not appear to be running andproxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line252, in check_setup
s.ping()
File"/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in__request
verbose=self.__verbose
File "/usr/lib64/python2.6/xmlrpclib.py", line 1243, inrequest
headers
ProtocolError: <ProtocolError for127.0.0.1:80/cobbler_api: 502 Proxy Error>
[root@bgw-os-node1 ~]# vim /etc/hosts
127.0.0.1 localhost
[root@bgw-os-node1 ~]# cobbler check
The following are potential configurationitems that you may want to fix:
1 : The 'server' field in/etc/cobbler/settings must be set to something other than localhost, orkickstarting features will not work. This should be a resolvable hostname or IP for the boot server asreachable 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 otherthan 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : some network boot-loaders are missingfrom /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to downloadthem, or, if you only want to handle x86/x86_64 netbooting, you may ensure thatyou have installed a *recent* version of the syslinux package installed and canignore this message entirely. Files inthis directory, should you want to support all architectures, should includepxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' commandis the easiest way to resolve these requirements.
4 : change 'disable' to 'no' in/etc/xinetd.d/rsync
5 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked
6 : comment out 'dists' on/etc/debmirror.conf for proper debian support
7 : comment out 'arches' on/etc/debmirror.conf for proper debian support
8 : The default password used by the sampletemplates 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 'cobblersync' to apply changes.
问题2:
[root@bgw-os-node1 ~]# cobbler check
The following are potential configurationitems that you may want to fix:
1 : service dhcpd is not running
2 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked
Restart cobblerd and then run 'cobblersync' to apply changes.
[root@bgw-os-node1 ~]# service iptablesstop
[root@bgw-os-node1 cobbler]# vim/etc/cobbler/dhcp.template
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = optionvendor-class-identifier;
option pxe-system-type code 93 = unsignedinteger 16;
subnet 10.240.216.0 netmask 255.255.255.0 {
option routers 10.240.216.254;
#option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.240.216.2 10.240.216.200;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
filename "pxelinux.0";
#class "pxeclients" {
# match if substring (optionvendor-class-identifier, 0, 9) = "PXEClient";
# if option pxe-system-type =00:02 {
# filename "ia64/elilo.efi";
# } else if optionpxe-system-type = 00:06 {
# filename"grub/grub-x86.efi";
# } else if optionpxe-system-type = 00:07 {
# filename"grub/grub-x86_64.efi";
# } else {
# filename"pxelinux.0";
# }
#}
}
[root@bgw-os-node1 cobbler]# vim/etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = optionvendor-class-identifier;
option pxe-system-type code 93 = unsignedinteger 16;
subnet 10.240.216.0 netmask 255.255.255.0 {
option routers 10.240.216.254;
option subnet-mask 255.255.255.0;
filename "/pxelinux.0";
range dynamic-bootp 10.240.216.2 10.240.216.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 10.240.216.1;
}
[root@bgw-os-node1 cobbler]# servicecobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[root@bgw-os-node1 cobbler]# service dhcpdstart
Starting dhcpd: [ OK ]
[root@bgw-os-node1 cobbler]# cobbler check
No configuration problems found. All systems go.