环境:
OEL6.3 x64 (CentOS6.3 x64)
网络环境中无其它DHCP服务器
本文出自:http://koumm.blog.51cto.com
# chkconfig iptables off # vi /etc/selinux/config SELINUX=disabled
# sestatus 重启后查看
说明:基础源与epel源。
rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum -y install cobbler cobbler-web httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart fence-agents
开启tftp与rsync服务
sed -i '/disable/c disable = no' /etc/xinetd.d/tftp sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync
# vi /etc/httpd/conf/httpd.conf ServerName 127.0.0.1:80
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.10/g' /etc/cobbler/settings sed -i 's/server: 127.0.0.1/server: 192.168.1.10/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/module = authn_denyall/module = authn_configfile/g' /etc/cobbler/modules.conf
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
# openssl passwd -1 -salt 'random-phrase-here' '111111' $1$random-p$WbZ3JxhRzCS/1Ne4S9g4Z.
# vi /etc/cobbler/settings # 修改为如下配置 default_password_crypted: "$1$random-p$WbZ3JxhRzCS/1Ne4S9g4Z."
# mv /etc/cobbler/dhcp.template /etc/cobbler/dhcp.template.bak # vi /etc/cobbler/dhcp.template ddns-update-style interim; allow booting; allow bootp; ignore client-updates; set vendorclass = option vendor-class-identifier; subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option domain-name-servers 202.100.192.68; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.1.120 192.168.1.254; filename "/pxelinux.0"; default-lease-time 21600; max-lease-time 43200; next-server $next_server; }
chkconfig httpd on chkconfig xinetd on chkconfig dhcpd on chkconfig cobblerd on service httpd start service xinetd start service dhcpd start service cobblerd start
[root@pxe ~]# cobbler get-loaders task started: 2013-12-15_191305_get_loaders task started (id=Download Bootloader Content, time=Sun Dec 15 19:13:05 2013) downloading http://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README downloading http://www.cobblerd.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading http://www.cobblerd.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading http://www.cobblerd.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading http://www.cobblerd.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading http://www.cobblerd.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot downloading http://www.cobblerd.org/loaders/pxelinux.0-3.61 to /var/lib/cobbler/loaders/pxelinux.0 downloading http://www.cobblerd.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32 downloading http://www.cobblerd.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading http://www.cobblerd.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE *** [root@pxe ~]#
# vi /etc/debmirror.conf 说明:前提是安装debmirror pykickstart这两个包,注释掉如下两行。 #@dists="sid"; #@arches="i386";
[root@pxe ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : service dhcpd is not running Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@pxe ~]# cobbler sync task started: 2013-12-15_192432_sync task started (id=Sync, time=Sun Dec 15 19:24:32 2013) running pre-sync triggers cleaning trees mkdir: /var/lib/tftpboot/pxelinux.cfg mkdir: /var/lib/tftpboot/grub mkdir: /var/lib/tftpboot/s390x mkdir: /var/lib/tftpboot/ppc mkdir: /var/lib/tftpboot/etc 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.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 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 rendering Rsync files 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: 正在启动 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 *** [root@pxe ~]#
说明:本节在前面已经考虑过cobbler check的错误提示了,大部分处理了。
[root@pxe ~]# service cobblerd restart Stopping cobbler daemon: [确定] Starting cobbler daemon: [确定] [root@pxe ~]# service xinetd restart 停止 xinetd: [确定] 正在启动 xinetd: [确定]
# mount /dev/cdrom /mnt
# cobbler import --path=/mnt --arch=x86_64 --name=Centos-5.9 task started: 2013-12-15_193916_import task started (id=Media import, time=Sun Dec 15 19:39:16 2013) Found a candidate signature: breed=redhat, version=rhel5 Found a matching signature: breed=redhat, version=rhel5 Adding distros from path /var/www/cobbler/ks_mirror/Centos-5.9-x86_64: creating new distro: Centos-5.9-x86_64 trying symlink: /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 -> /var/www/cobbler/links/Centos-5.9-x86_64 creating new profile: Centos-5.9-x86_64 creating new distro: Centos-5.9-xen-x86_64 trying symlink: /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 -> /var/www/cobbler/links/Centos-5.9-xen-x86_64 creating new profile: Centos-5.9-xen-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/Centos-5.9-x86_64 for Centos-5.9-x86_64 processing repo at : /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 looking for /var/www/cobbler/ks_mirror/Centos-5.9-x86_64/repodata/*comps*.xml running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/Centos-5.9-x86_64/repodata/comps.xml /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 received on stdout: Spawning worker 0 with 3579 pkgs Worker 0: .......... ... 略.... .......... Worker 0: Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete received on stderr: starting descent into /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 for Centos-5.9-xen-x86_64 processing repo at : /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-5.9-x86_64 looking for /var/www/cobbler/ks_mirror/Centos-5.9-x86_64/repodata/*comps*.xml *** TASK COMPLETE ***
说明: cobbler将镜像拷贝一份放在/var/www/cobbler/ks_mirrors/CentOS-5.9-x86_64目录下。
同时会创建一个名字为CentOS-5.9-x86_64的一个发布版本,以及一个名字为CentOS-5.9-x86_64的profile文件。
[root@pxe kickstarts]# cobbler list distros: Centos-5.9-x86_64 Centos-5.9-xen-x86_64 profiles: Centos-5.9-x86_64 Centos-5.9-xen-x86_64 systems: repos: images: mgmtclasses: packages: files:
说明:
默认kickstart文件是/var/lib/cobbler/kickstarts/sample.ks,需要手动为每个发行版单独指定, 或单独修改。
# cobbler distro list Centos-5.9-x86_64 Centos-5.9-xen-x86_64 #
vi /var/lib/cobbler/kickstarts/centos-5.9.ks
install text cdrom lang zh_CN.UTF-8 keyboard us reboot url --url=http://192.168.1.10/cobbler/ks_mirror/Centos-5.9-x86_64 network --device eth0 --bootproto dhcp --noipv6 --hostname oa rootpw --iscrypted $1$H0bnNoWM$HE1R/mWv6LqbhUGI8Xw/t. firewall --disabled authconfig --enableshadow --enablemd5 selinux --disabled timezone Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="rhgb quiet" # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work clearpart --all --initlabel part /boot --fstype ext3 --size=200 --asprimary part swap --size=2048 part / --fstype ext3 --size=200 --grow %packages @admin-tools @base @chinese-support @core @development-libs @development-tools @dialup @editors @gnome-desktop @games @graphical-internet @graphics @java @legacy-software-development @legacy-software-support @office @printing @sound-and-video @text-internet @base-x system-config-kickstart kexec-tools iscsi-initiator-utils fipscheck squashfs-tools device-mapper-multipath sgpio imake emacs libsane-hpaio xorg-x11-utils xorg-x11-server-Xnest xorg-x11-server-Xvfb %post service sendmail stop
说明
1. 选择Centos-5.9-x86_64,将采用Centos-5.9-x86_64安装源,并通过/var/lib/cobbler/kickstarts/centos-5.9.ks文件进行全自动安装。
2. 如有其它发行版,导入完镜像后,可以通过以下方式进行修改,否则将采用默认KS进行安装系统。
3. 也可以采用不同的ks文件来实现个性能自动安装,如下面第三条add命令,添加一个半自动的ks文件。
4. 如果没有按下面内容修改指定ks文件的话,引导菜单只显示Centos-5.9-x86_64默认一项。指定ks文件后,会在启动菜单中显示。
# cobbler profile edit --name=Centos-5.9-x86_64 --distro=Centos-5.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-5.9.ks
示例:
# cobbler profile edit --name=Centos-5.9-xen-x86_64 --distro=Centos-5.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-5.9-xen.ks # cobbler profile add --name=Centos-5.9-half-auto --distro=Centos-5.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-5.9-halfauto.ks
如图所示:
# cobbler profile rename --name=Centos-5.9-x86_64 --newname=CentOS-5U9-x64
# cobbler profile remove --name=Centos-5.9-x86_64
1. 指定一个网段使用特定的装机配置
cobbler system add --name=test_000 --ip=192.168.1.0/24 --profile=Centos-5.9-x86_64
指定服务器的mac地址,并设置好主机名、IP地址等信息,需要提示知道服务器MAC地址,根据MAC应用到具体机器上。
还可以指定ks参数。--kickstart=/var/lib/cobbler/kickstarts/webserver.ks cobbler system add --name=test_001 --hostname=test_001 --mac=00:0C:29:E3:81:32 --interface=eth0 --ip-address=192.168.1.123 --subnet=255.255.255.0 --gateway=192.168.1.1 --static=1 --profile=Centos-5.9-x86_64
机器IP地址变更为192.168.10.110
cobbler system add --name=test_001 --ip=192.168.1.110
变更system配置名称
cobbler system rename --name=test001 --newname=abc
需要删除的profile名称为test_001
cobbler system remove --name=test_001
cobbler system list test_001
wget ftp://rpmfind.net/linux/epel/5/i386/koan-1.6.6-1.el5.noarch.rpm rpm -ivh koan-1.6.6-1.el5.noarch.rpm
查看cobbler server上的配置文件,对于centos5.x 的系统koan不能采用yum安装,否则会因python版本过低而报错。
# koan --server=192.168.1.10 --list=profiles
- looking for Cobbler at http://192.168.1.10/cobbler_api - reading URL: http://192.168.1.10/cblr/svc/op/ks/profile/Centos-5.9-x86_64 install_tree: http://192.168.1.10/cobbler/ks_mirror/Centos-5.9-x86_64 downloading initrd initrd.img to /boot/initrd.img url=http://192.168.1.10/cobbler/images/Centos-5.9-x86_64/initrd.img - reading URL: http://192.168.1.10/cobbler/images/Centos-5.9-x86_64/initrd.img downloading kernel vmlinuz to /boot/vmlinuz url=http://192.168.1.10/cobbler/images/Centos-5.9-x86_64/vmlinuz - reading URL: http://192.168.1.10/cobbler/images/Centos-5.9-x86_64/vmlinuz - ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz', '--initrd', '/boot/initrd.img', '--args', '"ks=http://192.168.1.10/cblr/svc/op/ks/profile/Centos-5.9-x86_64 ksdevice=link kssendmac lang= text "', '--copy-default', '--make-default', '--title=kick1387098833'] - reboot to apply changes
# reboot
reboot重启服务器后,客户端服务器会自动重新安装操作系统