Cobbler应用

Cobbler简介:

Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。

实验:安装Cobbler,能够自动安装系统。

1,  安装Cobbler,(在安装cobbler之前 还需要安装应用)

#yum install cobbler-web pykickstart debmirror

#yum install cobbler

2,  启动服务

# service httpd start

#service cobblerd start

LISTEN    0      5                              127.0.0.1:25151                                 *:*

3,  进行检查

Cobbler check

1 : The'server' field in /etc/cobbler/settings must be set to something other thanlocalhost, or kickstarting features will not work.  This should be a resolvable hostname or IPfor the boot server as reachable by all machines that will use it.

2 : ForPXE to be functional, the 'next_server' field in /etc/cobbler/settings must beset to something other than 127.0.0.1, and should match the IP of the bootserver on the PXE network.

3 : somenetwork boot-loaders are missing from /var/lib/cobbler/loaders, you may run'cobbler get-loaders' to download them, or, if you only want to handlex86/x86_64 netbooting, you may ensure that you have installed a *recent*version of the syslinux package installed and can ignore this messageentirely.  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 theeasiest way to resolve these requirements.

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

5 :debmirror package is not installed, it will be required to manage debiandeployments and repositories

6 :ksvalidator was not found, install pykickstart

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

8 : fencing tools were not found, and are required to usethe (optional) power management features. install cman or fence-agents to usethem

如上各问题的解决方法如下所示:

1)、修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如172.16.100.15

2)、修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如172.16.100.16

3)、如果当前节点可以访问互联网,执行“cobbler get-loaders”命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;

4)、执行“chkconfigrsync on”命令即可;

5)、注释/etc/debmirror.conf文件中的“@dists="sid";”一行;

6)、注释/etc/debmirror.conf文件中的“@arches="i386";”一行;

7)、执行“opensslpasswd -1 -salt $(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings文件中default_password_crypted参数的值;

8)、执行“yum install cman fence-agents”命令安装相应的程序包即可;

 

 

4# openssl passwd -1-salt `openssl rand -hex 4`

Password:caoshujia

$1$001ebc8f$VxYLBp0cdy/7TaGodSaxV0

 

default_password_crypted:"$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

然后把上面得出的替换掉现有的

default_password_crypted: "$1$001ebc8f$VxYLBp0cdy/7TaGodSaxV0"

然后保存退出

 

5,重启cobbler

#service cobblerd restart

 

6,拷贝文件

  #cd /usr/share/syslinux/

  #cp-r ./* /var/lib/cobbler/loaders/

 

7,安装dhcp服务,编辑配置文件,启动服务

   #yuminstall dhcp –y

   #cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

  #vim /etc/dhcp/dhcpd.conf

   optiondomain-name "mageedu.com"; 修改域名,根据实际情况而定

option domain-name-servers 172.16.0.1;

 

subnet 172.16.0.0 netmask 255.255.0.0 {

  range 172.16.31.101172.16.31.201;

  option routers 172.16.31.10;

}

 

next-server 172.16.31.10;

filename="pxelinux.0";

 

# service dhcpd start

UNCONN     0      0  *:67                                    *:*

8,启动tftp服务

   #chkconfig tftp on

   #service xinetd start

   #ss –tunl

udp   UNCONN     0      0       *:69                                 *:*

 

9,使用distro

                                

wKioL1Q6UdvxmdSAAAHj8CoD8ec745.jpg

wKiom1Q6UaSTThvqAABa15WUNs8015.jpg


 

然后挂载

# mount /dev/cdrom  /mnt –r

# ls /mnt

CentOS_BuildTag  p_w_picpaths                    repodata                      RPM-GPG-KEY-CentOS-Testing-6

EFI              isolinux                  RPM-GPG-KEY-CentOS-6           TRANS.TBL

EULA             Packages                  RPM-GPG-KEY-CentOS-Debug-6

GPL              RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Security-6

 

然后用cobbler import 导入

# cobbler import --path=/mnt--name=centos-6.5-x86_64

(开始导入,建议找一个小一点的导入,这一步很慢,请耐心等待)

# cobbler distro list

  centos-6.5-x86_64   (表示已经完成系统导入)

然后cd /tmp  

#wget http://172.16.0.1/centos6.x86_64.cfg(下载cfg文件,这个是系统配置信息)

# cobbler profile add--name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos6.x86_64.cfg(检测文件是否有语法错误)

 

# cobbler profile list

  centos-6.5-x86_64

  centos-6.5-x86_64-basic

在修改# cd /tmp/ centos6.x86_64.cfg文件

url --url=http://172.16.31.10/cobbler/ks_mirror/centos-6.5-x86_64/ 修改为提供服务的地址

 

# cobbler profile edit--name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64--kickstart=/tmp/centos6.x86_64.cfg

 

# cobbler sync



wKiom1Q6Ub7inZ1SAAD4QFFbS08178.jpg