cobbler安装配置

一、安装环境
centos 5.4_64
关掉iptables、selinux
selinux可能导致tftp的目录无法访问 pxe停止在引导界面。

二、cobbler使用目录及文件
cobbler相关配置文件 /etc/cobbler
cobbler数据存储目录 /var/www/cobbler
dhcp配置文件 /etc/dhcpd.conf
dhcp租期缓存文件 /var/lib/dhcpd/dhcpd.leases
pxe配置文件 /tftpboot/pxelinux.cfg/default

三、安装cobbler:
安装epel yum库,
rpm -ivh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
yum clean all
yum -y install PyYAML cobbler tftp-server httpd dhcp yum-utils cman xinetd

注意:/var/www/cobbler 目录必须具有足够容纳 Linux 安装文件的空间!!!

四、修改后配置文件:
1.修改cobbler配置文件
vi /etc/cobbler/settings

server: 192.168.0.137 #cobbler服务器地址
next_server: 192.168.0.137
manage_dhcp: 1
default_kickstart: /var/lib/cobbler/kickstarts/CentOS-5.4.ks

2.更改tftp启动方式
vi /etc/xinetd.d/tftp
disable = no #默认开启tftp
或运行#sed -i 's/disable.*$/disable = no/g' /etc/xinetd.d/tftp

3.修改dhcp配置文件
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.0.0 netmask 255.255.255.0 {
option routers 192.168.0.9;
option domain-name-servers 192.168.0.137;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.0.238 192.168.0.252;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}

4.更该sync的配置文件:
#vi /etc/xinetd.d/rsync
disable = no #默认开启sync
或运行#sed -i 's/disable.*$/disable = no/g' /etc/xinetd.d/rsync

五、启动cobbler服务
#service httpd start
#service xinetd start
#service cobblerd start
设置开机自启动:
#chkconfig --level 345 dhcpd on
#chkconfig --level 345 httpd on
#chkconfig --level 345 xinetd on
#chkconfig --level 345 cobblerd on

六、使用cobbler check检测cobbler存在的错误,根据提示解决问题 ,例如:
如果错误如下:httpd does not appear to be running and proxying cobbler
解决办法:检查http是否启动,端口是否被占用,Selinux与Iptables设置等。

The following are potential configuration items that you may want to fix:
1 : service dhcpd is not running
2 : 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.
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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) Dhcpd不用理会它。
(2) 运行cobbler get-loaders
看到*** TASK COMPLETE ***则成功,若看不到,请检查你的网络是否通畅。
(3) Debmirror 不存在,不用理会。
(4) 修改系统初始密码:
使用openssl生成新密码:openssl passwd -1 -salt '' 'gongchang.com'
经过md5加密后的gongchang.com为:$1$$TBGNZfxETBpFOKfAdAV.U0
修改/etc/cobbler/setings文件中“default_password_crypted”字段为$1$$TBGNZfxETBpFOKfAdAV.U0
重新启动cobblerd,再次运行cobbler check 与cobbler sync看到*** TASK COMPLETE ***即为成功。

七、导入CentOS 光盘映像文件
mount /dev/hdc -o,loop /media
cobbler import --path=/media --name=CentOS-5.4 #有点慢,大约需要10分钟。
导入的镜像存储在/var/www/cobbler/ks_mirror/这个目录下
cobbler distro list 查看导入结果

八、kickstart配置文件实例
新建ks文件:
vi /var/lib/cobbler/kickstarts/CentOS-5.4.ks

auth --useshadow --enablemd5
bootloader --location=mbr
clearpart --all --initlabel
text
firewall --disable
firstboot --disable
keyboard us
lang zh_CN
url --url=$tree
them here.
$yum_repo_stanza
network --bootproto=dhcp --device=eth0 --onboot=on
reboot
rootpw --iscrypted $1$$TBGNZfxETBpFOKfAdAV.U0
selinux --disabled
skipx
timezone Asia/Shanghai
install
zerombr
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LV00l --vgname=VG001 --size=1024 --grow
logvol swap --fstype swap --name=LV002 --vgname=VG001 --size=256 --grow
%packages #定制安装的组件
@development-tools
@base
@development-libs
@system-tools
@admin-tools
@ editors
lvm2
httpd
%post
# Add service httpd
/sbin/chkconfig --level 345 httpd on
/sbin/service httpd start

为了使上面的设置生效,需要应用配置模板
cobbler sync

看到以下内容即成功:
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
若看到以下内容:
dhcpd -t failed
Exception occured: cobbler.cexceptions.CX
Exception value: 'cobbler trigger failed: cobbler.modules.sync_post_restart_services'
......................................................................
去查看下/var/log/messages这里一定有你需要的信息。

九、设置profile和system
1.profile可以理解为按角色进行分类,下面是几个添加删除修改profile配置的例子:

增加一个profile配置:
名称为:DB
指定镜像为:CentOS-5.4-x86_64,kickstart
文件为/var/lib/cobbler/kickstarts/db.ks
命令:cobbler profile add --name=DB --distro=CentOS-5.4-x86_64 --kickstart=
/var/lib/cobbler/kickstarts/db.ks

修改镜像名称:
指定镜像由CentOS-5.4-x86_64修改为CentOS5.4-i386
cobbler profile edit --name= DB --distro=CentOS5.4-i386

变更profile配置名称,名称由DB修改为Web
#cobbler profile rename --name= DB --newname=Web

删除profile配置,需要删除的profile名称为DB
#cobbler profile remove --name= DB
注意:修改删除名为DB的profile,profile中必须存在。

十、利用cobbler重装系统
1、在客户端上安装koan
# rpm -ihv koan-1.2.5-1.el5.noarch.rpm

#rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
#yum -y install koan
2、查看cobbler server上的配置文件
# koan --server=192.168.0.137 --list=profiles
3、重新安装客户端系统
# koan --replace-self --server=192.168.0.137 --profile= CentOS-5.4-x86_64
#reboot
4、reboot重启服务器后,客户端服务器会自动重新安装操作系统
十一、图形化管理cobbler:
Cobbler web界面是一个很好的前端,非常容易管理很多Cobbler操作。可以用它列出和编辑distros, profiles, subprofiles, systems, repos and kickstart文件。
安装Cobbler web:
yum install cobbler-web
设置用户名密码:
为已存在的用户重置密码:
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
添加新用户:
htdigest /etc/cobbler/users.digest "Cobbler" your_newname
设置/etc/cobbler/modules.conf如下:
[authentication]
module = authn_configfile #将原来的module = authn_denyall注释掉。
重启Cobbler服务:
#service cobblerd restar
Cobbler web界面访问地址:
http://192.168.0.137/cobbler_web/ (192.168.0.137为Cobbler web server地址)

你可能感兴趣的:(职场,休闲,cobbler)