Cobbler(补鞋匠)装机系统是较早前kickstart的升级版,配置简单自带web界面

配置环境:

操作系统:CentOS 6.5

测试机器ip:100.100.100.100

先将iptables selinux 关掉。

/etc/init.d/iptables stop

chkconfig iptables off

setenforce 0

并修改配置文件/etc/sysconfig/selinux 将其disable

一、安装cobbler

rpm -Uvh http://mirrors.hustunique.com/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum install cobbler cobbler-web

yum install dhcp httpd

chkconfig cobblerd on

chkconfig httpd on

cobbler check    //检查cobbler环境,按照提示安装相应的软件(可忽略一直提示yum-utils未安装)

二:配置

1.修改cobbler 的配置文件

vim  /etc/cobbler/settings

修改如下地方:

next_server: 100.100.100.100          //这里未修改的话执行cobbler check也有提示的

server: 100.100.100.100

manage_dhcp: 1

manage_rsync: 1

2.生成root的密码串

openssl passwd -1 -salt "cobbler" "123456"    //openssl passwd -1 -salt '任间字符' '密码'

$1$cobbler$sqDDOBeLKJVmxTCZr52/11

这个命令的用法,其中任意字符可以随便写,然而这个密码就是安装完系统root的密码了。

3.替换配置文件里的字串。

vim  /etc/cobbler/settings

default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"

4.配置tfpt和rsync

vim /etc/xinetd.d/tftp

 disable                 = no    //将yes的值修改成no

vim /etc/xinetd.d/rsync

 disable                 = no    //将yes的值修改成no

/etc/init.d/xinetd restart

5.配置dhcp

vim /etc/cobbler/dhcp.template     //修改以下内容即可

ddns-update-style interim;

allow booting;

allow bootp;

ignore client-updates;

set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 100.100.100.0 netmask 255.255.255.0 {

     option routers             100.100.100.1;

     option domain-name-servers 8.8.8.8;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        100.100.100.200 100.100.100.254;

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

   }

6.同步文件

cobbler get-loaders     //*** TASK COMPLETE ***输出这个则同步成功

 

三、配置web环境

1.添加登录账号

htdigest /etc/cobbler/users.digest "Cobbler" admin  //添加cobbler用户web登录

2.检查配置

cobbler sync           //*** TASK COMPLETE ***输出这个则表示配置无错误

3.添加系统镜像

mount /dev/cdrom /mnt/cdrom/                  //挂载镜像

cobbler import --path=/mnt/cdrom --name=centos6.5      //因为镜像较大需要一段时间

导入镜像name可自定义导入成功后web界面会有显示,需要添加多个镜像的话也只需要执行这个命令把要添加的镜像挂载然后导入即可

4.启动

/etc/init.d/httpd restart

/etc/init.d/cobblerd restart

附上一个启动cobbler脚本

#!/bin/sh

# chkconfig: - 80 90

# description:cobbler

case $1 in

start)

/etc/init.d/httpd start

/etc/init.d/xinetd start

/etc/init.d/dhcpd start

/etc/init.d/cobblerd start

;;

stop)

/etc/init.d/httpd stop

/etc/init.d/xinetd stop

/etc/init.d/dhcpd stop

/etc/init.d/cobblerd stop

;;

restart)

/etc/init.d/httpd restart

/etc/init.d/xinetd restart

/etc/init.d/dhcpd restart

/etc/init.d/cobblerd restart

;;

status)

/etc/init.d/httpd status

/etc/init.d/xinetd status

/etc/init.d/dhcpd status

/etc/init.d/cobblerd status

;;

sync)

cobbler sync

;;

*)

echo "Input error,please in put 'start|stop|restart|status|sync'!";

exit 2>&1 >/dev/null &

;;

esac

5.进入web界面

   //访问这个链接使用刚刚创建的账号登录

6.修改启动配置文件

cd /var/lib/cobbler/kickstarts    //创建系统安装ks文件

点击web左边的Profiles选项选择刚刚导入镜像的点击Edit

修改Kickstart选项选择你的系统安装ks文件

附上我的centos6.5ks文件,我这个是最小化安装方式(可以根据自己的需求修改)

# Use network installation 

url --url=$tree

#Root password

rootpw  --iscrypted $default_password_crypted

#Install OS instead of upgrade 

install

#Firewall configuration 

firewall --service=ssh

#System authorization information

authconfig --enableshadow --passalgo=sha512

#System keyboard 

keyboard us

#System language

lang en_US.UTF-8

#SELinux configuration 

selinux --disabled

#Installation logging level 

logging --level=info

#Reboot after installation 

reboot

#System timezone 

timezone --utc Asia/Shanghai

#Network information

network --onboot no --device eth0 --bootproto dhcp --noipv6 --hostname=test.test

#System bootloader configuration 

key --skip

bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

#Clear the Master Boot Record 

zerombr

#Partition clearing information 

clearpart --all --initlabel

#Disk partitioning information 

part /boot --fstype=ext4 --size=200

part swap --size=4000

part pv.008003 --grow --size=200

volgroup volGroup00 --pesize=4096 pv.008003

logvol / --fstype=ext4 --name=LogVol00 --vgname=volGroup00 --size=20000

logvol /data --fstype=ext4 --name=LogVol01 --vgname=volGroup00 --size=16756

%packages

@chinese-support

@core

@server-policy

@workstation-policy

%end

四、客户端

设置客户端通过网络启动后即会出现cobbler安装菜单选项,选择刚刚配置的系统启动即可自动安装

完成后自动重启,可以用先前定义好的密码"123456"登陆了

在已经有系统的的机器要重装的话

安装koan  

yum install koan  

查看cobbler服务器有哪些安装盘  

koan --list-profiles --server=100.100.100.100  

#选择要重装的系统并重启  

koan --replace-self --server=100.100.100.100 --profile=CentOS6.5-x86-64  

reboot

附:错误排除

# cobbler check 

The following are potential configuration items that you may want to fix:

1 : Must enable a selinux boolean to enable vital web services components, run: setsebool -P httpd_can_network_connect true 

2 : you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*" && /usr/sbin/semanage fcontext -a -t public_content_t "/var/www/cobbler"/p_w_picpaths/.* 

3 : you need to set some SELinux rules if you want to use cobbler-web (an optional package), run the following: /usr/sbin/semanage fcontext -a -t httpd_sys_content_rw_t "/var/lib/cobbler/webui_sessions/.*"

解决:关闭selinux

# vim /etc/sysconfig/selinux 

SELINUX=disabled

4 : change 'disable' to 'no' in /etc/xinetd.d/tftp 

解决:编辑/etc/xinetd.d/tftp文件,将文件中的disable字段的配置由yes改为no

5 : change 'disable' to 'no' in /etc/xinetd.d/rsync 

解决:编辑/etc/xinetd.d/rsync文件,将文件中的disable字段的配置由yes改为no

6 : since iptables may be running, ensure 69, 80, and 25151 are unblocked 

解决:在iptables中将69,80,25151端口打开。如果仅仅只是在内部环境中使用,建议直接将防火墙关掉

7 : debmirror package is not installed, it will be required to manage debian deployments and repositories

解决:yum install debmirror

或:rpm -Uvh ftp://rpmfind.net/linux/epel/5/i386/debmirror-20090807-1.el5.noarch.rpm –nodeps –force

8 : ksvalidator was not found, install pykickstart 

解决:yum install pykickstart

9 : 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

解决: 修改默认密码就OK了,然后把密码写入到/etc/cobbler/settings中 

# openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'

10 : comment 'dists' on /etc/debmirror.conf for proper debian support 

11 : comment 'arches' on /etc/debmirror.conf for proper debian support

解决:注释/etc/debmirror.conf 下面两行 

#@dists="sid"; 

@sections="main,main/debian-installer,contrib,non-free"; 

#@arches="i386";

12:fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them 

解决: yum install cman

修复完成,再用 cobbler check 检查一下,确认没问题后用 cobbler sync 做同步操作:

# cobbler check

No configuration problems found. All systems go.

13. comment out 'dists' on /etc/debmirror.conf for proper debian support

comment out 'arches' on /etc/debmirror.conf for proper debian supportvim              vi /etc/debmirror.conf

#注释掉@dists="sid"与@arches="i386即可

#@dists="sid";

#@arches="i386";

14. 较验cobbler check出错

Traceback (most recent call last):

 File "/usr/bin/cobbler", line 35, in ?

 sys.exit(app.main())

 File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 558, in main

 rc = cli.run(sys.argv)

 File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 202, in run

 self.token = self.remote.login("", self.shared_secret)

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__

 return self.__send(self.__name, args)

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request

 verbose=self.__verbose

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request

 return self._parse_response(h.getfile(), sock)

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response

 return u.close()

 File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close

 raise Fault(**self._stack[0])

xmlrpclib.Fault:

解决方法:此为BUG,按下方操作执行即

service cobblerd restart

cobbler get-loaders

返回这个结果就OK了

参考:http://blog.chinaunix.net/uid-16728139-id-4174109.html