<特别声明: 该图来源“煮酒品茶”的博客,如有不妥,请联系本人删除,谢谢!>
# 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 "zhangdh.com" |openssl passwd -1 -salt ‘randomstr‘ –stdin`”
# 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
本文出自 “linuxblind开放空间” 博客,请务必保留此出处http://linuxblind.blog.51cto.com/7616603/1655565
原文地址:http://linuxblind.blog.51cto.com/7616603/1655565