1 # chkconfig iptables off
2 # vi /etc/selinux/config
SELINUX=disabled
说明:基础源与epel源。
rpm �Civh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
(要装32位机器可以打开网页选择合适的epel源)
yum -y install cobbler cobbler-web httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart fence-agents
二、 配置tftp-server与rsync
开启tftp与rsync服务
|
sed -i '/disable/c disable = no' /etc/xinetd.d/tftp sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync 把/etc/xinetd/tftp 和/etc/xinetd/rsync 中的disable选项中的yes改成no。
|
# vi /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
ServerName localhost:80
1 sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.10/g' /etc/cobbler/settings
2 sed -i 's/server: 127.0.0.1/server: 192.168.1.10/g' /etc/cobbler/settings
3 sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
4 sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings
修改/etc/cobbler/settings 这个配置文件里面的内容,把server:127.0.0.1 把IP改成自己的IP地址,把next_server 里面的地址也改成自己的地址。那manage_dhcp和manage_rsync后面的0改成1
sed -i 's/module = authn_denyall/module = authn_configfile/g' /etc/cobbler/modules.conf
module = authn_configfile /修改认证方式为密码文件类型
htdigest /etc/cobbler/users.digest "Cobbler" 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;
}
注: 不要修改/etc/dhcpd.conf 这个文件,过会我们会配置让cobbler接管启动dhcpd的任务,cobbler会把你修改的dhcp.template拷贝到/etc/dhcpd.conf
chkconfig httpd on
chkconfig xinetd on
chkconfig dhcpd on
chkconfig cobblerd on
service httpd start
service xinetd start
service dhcpd start
service cobblerd start
# 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.
运行cobbler sync
直到出现*** TASK COMPLETE ***算成功
说明:本节在前面已经考虑过cobbler check的错误提示了,大部分处理了。
service cobblerd restart
service xinetd restart
# 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)
running: createrepo -c cache -s sha --groupfile
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文件。
用cobbler list查看
说明:
默认kickstart文件是/var/lib/cobbler/kickstarts/sample_end.ks,需要手动为每个发行版单独指定, 或单独修改。
vi /var/lib/cobbler/kickstarts/centos-5.9.ks
可以先把默认的拷贝一份改个名字。然后根据需求进行编辑
install
text
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
base、updates库使用163的repo源并增加EPEL库
base
cobbler repo add --name=centos5.8-x86_64-Base --mirror=http://mirrors.163.com/centos/5/os/x86_64/
将定义的仓库大写名字Base修改为小写base
cobbler repo edit --name=centos5.8-x86_64-base --mirror=http://mirrors.163.com/centos/5/os/x86_64/ --arch=x86_64 --breed=yum
updates
cobbler repo add --name=centos5.8-x86_64-updates --mirror=http://mirrors.163.com/centos/5/updates/x86_64/ --arch=x86_64 --breed=yum
添加EPEL仓库
cobbler repo add --name=centos5.8-x86_64-epel --mirror=http://mirrors.ustc.edu.cn/epel/5/x86_64/ --arch=x86_64 --breed=yum
时间较长,注意磁盘容量是否满足。
cobbler reposync
task started: 2013-03-26_111553_reposync
task started (id=Reposync, time=Tue Mar 26 11:15:53 2013)
hello, reposync
run, reposync, run!
creating: /var/www/cobbler/repo_mirror/centos5.8-x86_64-updates/.origin/centos5.8-x86_64-updates.repo
running: /usr/bin/reposync -l -m -d --config=/var/www/cobbler/repo_mirror/centos5.8-x86_64-updates/.origin/centos5.8-x86_64-updates.repo --repoid=centos5.8-x86_64-updates --download_path=/var/www/cobbler/repo_mirror -a x86_64
………………略…………………………
received on stdout:
received on stderr:
*** TASK COMPLETE ***
安装系统时会自动添加仓库配置
cobbler profile edit --name=centos5.8-x86_64 --repos="centos5.8-x86_64-base centos5.8-x86_64-epel centos5.8-x86_64-updates" --distro=centos5.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos5u8-x64.cfg
cobbler repo remove --name=centos5.8-x86_64- updates
cobbler reposync --tries=3 --no-fail
加入crontab 每周日更新一次即可
echo "0 2 * * 0 cobbler reposync --tries=3 --no-fail" >> /var/spool/cron/root
注意检查crond是否启动
/etc/init.d/crond status
crond is stopped
/etc/init.d/crond start
Starting crond: [ OK ]
chkconfig crond on
如果你想安装系统时自动配置yum,请进行以下配置。
vim /etc/cobbler/settings
yum_post_install_mirror: 1
在装机脚本ks文件加入以下内容
%post
# Start yum configuration
$yum_config_stanza
# End yum configuration
说明
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文件后,会在启动菜单中显示。
1 # cobbler profile edit --name=Centos-5.9-x86_64 --distro=Centos-5.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-5.9.ks
2 # 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
3 # 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