码迷,mamicode.com
首页 > 其他好文 > 详细

自动化安装工具Cobbler简易安装配置

时间:2015-08-30 01:09:44      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:cobbler kickstart linux 自动部署

Cobbler的安装方式和传统的方式相差无几,但是相对配置简单,

提供WEB界面,不过相对运维工程师来讲,这个WEB反而不太实用。

我个人比较喜欢的是Cobbler可以在一套系统内定义多个系统和菜单,

在大规模、多样化定制环境中非常实用。

如果只是单纯安装某一个操作系统,批量的,传统的就可以。


实际生产环境为了DHCP不冲突,这很重要,由于没有开启DHCP中继,

所以放在一个新的VLAN即可。


实际在应用中,服务器是静态IP,即便服务器重启并从PXE启动也默认从

local启动,所以影响不大。


Server: 192.168.1.110

GATEWAY:192.168.1.253
system:centos 6.6 minimal


注:我在centos6.7上安装此版本有问题,可能是BUG。

开始安装:
#配置yum源,使用epel安装,基本安装源没有cobbler
cd /etc/yum.repos.d/
yum install -y epel-release
[root@cobsrv yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo  epel-testing.repo
CentOS-Debuginfo.repo  CentOS-Media.repo      epel.repo

yum clean all

yum install -y cobbler cobbler-web pykickstart debmirror cman fence-agents
  #pykickstart(检查kickstart语法错误)

service httpd start
chkconfig httpd on
service cobblerd start

/etc/init.d/iptables stop
chkconfig --level 35 iptables off

[root@cobsrv ~]# getenforce
Enforcing
 vi /etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled

reboot生效


cobbler check    #报错,注意核对纠错
The following are potential configuration items that you may want to fix:

1 : The ‘server‘ field in /etc/cobbler/settings must be set to something other than localhost, or

kickstarting features will not work.  This should be a resolvable hostname or IP for the boot

server as reachable by all machines that will use it.
2 : For PXE to be functional, the ‘next_server‘ field in /etc/cobbler/settings must be set to

something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp
4 : 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.
5 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync
6 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support
7 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support
8 : 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.

#/etc/cobbler/settings中next_server和server修改为主机IP,默认127.0.0.1
next_server: 192.168.1.110
server: 192.168.1.110

#修改default_password_crypted默认密码,随机生成密码
openssl passwd -1 -salt `openssl rand -hex 4`
Password:
$1$df2d0ac2$F3dFQIzkBge6b7NYivb250
default_password_crypted: "$1$df2d0ac2$F3dFQIzkBge6b7NYivb250"

cobbler get-loaders  #需要联网,没网的话可以从镜像中拿出pxelinux.0和menu.c32文件
*** TASK COMPLETE ***

ls /var/lib/cobbler/loaders  #最终会copy到/var/lib/tftpboot/images


chkconfig rsync on

vi /etc/debmirror.conf    #注释掉@dists="sid"和@arches="i386"
#@dists="sid";
@sections="main,main/debian-installer,contrib,non-free";
#@arches="i386";

cobbler sync    #同步一下数据

vi /etc/cobbler/settings    #manage_dhcp和manage_dns值为0表示管理员管理,
值为1表示由cobbler来管理,默认是0,修改如下
manage_dhcp: 1
manage_rsync: 1
manage_tftpd: 1

yum -y install dhcp

rpm -q tftp-server
tftp-server-0.49-7.el6.x86_64

cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
vi /etc/dhcp/dhcpd.conf
option domain-name "cobsrv.test";
option domain-name-servers 219.239.26.42, 124.207.160.106;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.100 192.168.1.120;
        option routers 192.168.1.253;
}
next-server 192.168.1.110;
filename="pxelinux.0";
#将原来的subnet以***释或者删除

service dhcpd restart
Starting dhcpd:          [  OK  ]

service cobblerd restart

#插入并挂载光盘,准备生成树,
mount /dev/cdrom /media/ -r
ls /media/    #确认下是否挂载成功

vi /etc/httpd/conf/httpd.conf
ServerName 192.168.1.110:80

service httpd restart

cobbler sync
cobbler check

之前tftp没启动
chkconfig tftp on
service xinetd restart

cobbler import --name="centos-6.6-minimal-x86_64" --path=/media  
#复制全部镜像到/var/www/  时间可能比较长

[root@cobsrv kickstarts]# cd /var/lib/cobbler/kickstarts/
[root@cobsrv kickstarts]# ls
default.ks    esxi5-ks.cfg      legacy.ks     sample_autoyast.xml  sample_esx4.ks   

sample_esxi5.ks  sample_old.seed
esxi4-ks.cfg  install_profiles  pxerescue.ks  sample_end.ks        sample_esxi4.ks  sample.ks      

  sample.seed

cobbler distro list
centos-6.6-minimal-x86_64

cobbler profile add --name=centos-6.6-minimal-x86_64 --distro=rhel-6.4-x86_64 --

kickstart=/var/lib/cobbler/kickstarts/sample.ks

cobbler profile list   #profile即启动时选择菜单的内容

cobbler sync     #每次改动最好都同步一下,使其生效

vi /var/lib/tftpboot/pxelinux.cfg/default
已经生成菜单

此时启动一台虚机,放在一个网络,选择PXE启动可以正常加载了

使用如下web地址登陆
http://192.168.1.110/cobbler_web
cobbler/cobbler

我这次使用时在virtualbox虚机,选择的是桥接,为了避免无线路由影响,

关闭了无线路由的DHCP功能,且virtualbox网卡选择fast III,支持PXE启动。


































本文出自 “天魂永恒” 博客,请务必保留此出处http://tianhunyongheng.blog.51cto.com/1446947/1689652

自动化安装工具Cobbler简易安装配置

标签:cobbler kickstart linux 自动部署

原文地址:http://tianhunyongheng.blog.51cto.com/1446947/1689652

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!