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

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/  时间可能比较长

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/57b6352b4821a718946b47b92a157612.html