手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS 6.5 安装和配置Cobbler

[日期:2015-02-07] 来源:Linux社区  作者:kongxx [字体: ]

Cobbler是一个开源项目,用来部署和安装系统。Cobbler不仅仅是一个pxe服务器,他还可以管理dns和dhcp。一般数据中心里或者生产环境,是不允许dhcp, 但是pxe需要使用dhcp,所以我们这里根据mac地址来分配IP,这样dhcp就不会影响现有网络了。

1. 首先关闭selinux

sudo sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
重新启动linux系统


2. 关闭防火墙iptables

sudo chkconfig iptables off
sudo chkconfig ip6tables off
sudo /etc/init.d/iptables stop
sudo /etc/init.d/ip6tables stop
3. 安装 epel 包

sudo yum install http://mirrors.ustc.edu.cn/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
4. 安装 Cobbler 和它需要的第三方工具包

sudo yum install cobbler cobbler-web xinetd pykickstart cman dhcp tftp-server bind
安装完成后需要设置几个服务自动启动

sudo chkconfig httpd on
sudo chkconfig dhcpd on
sudo chkconfig cobblerd on

sudo service httpd start
sudo service cobblerd start
注:此时dhcpd应该启动失败,因为还没有对dhcp做配置。


5. 配置
5.1 修改/etc/xinetd.d/tftp

disable = yes
=>
disable = no


5.2 修改/etc/xinetd.d/rsync

disable = yes
=>
disable = no


5.3 编辑 /etc/cobbler/settings 文件,设置以下各项,其中 192.168.145.102 是当前机器IP。

server: 192.168.145.102
next_server: 192.168.145.102
pxe_just_once: 1
manage_rsync: 1
manage_dhcp: 1
5.4 设置默认 root 用户的秘密

$ sudo openssl passwd -1 -salt 'random-phrase-here' 'Letmein'

然后将结果替换 /etc/cobbler/settings 文件中的
default_password_crypted:


5.5 设置 Cobbler Web访问的密码

sudo htdigest /etc/cobbler/users.digest "Cobbler" cobbler

5.6 编辑 /etc/cobbler/dhcp.template 文件,下面是我改动部分的配置信息

...
subnet 192.168.145.0 netmask 255.255.255.0 {
    option routers            192.168.145.102;
    option domain-name-servers 192.168.145.1;
    option subnet-mask        255.255.255.0;
    #range dynamic-bootp        192.168.145.150 192.168.145.200;
    default-lease-time        21600;
    max-lease-time            43200;
    next-server                $next_server;
    filename          "/pxelinux.0";
    host test { # 为指定机器指定ip地址
        hardware ethernet 08:00:27:2C:30:8C; 
        fixed-address 192.168.145.155;
    }
}
...

注意:如果在现有网段内已经有DHCP服务器,需要把 range dynamic-bootp 注释掉,否则会有冲突。这个地方需要特别注意,要根据自己的网络情况来设置。

5.7 重启服务

sudo service xinetd restart
sudo service httpd restart
sudo service cobblerd restart

5.8 启动和检测 cobbler

sudo cobbler get-loaders
sudo cobbler check
此时如果有错误,cobbler会提示,可以根据提示来修复。但是对参数的任何修改都需要使用下面的命令来使其生效

sudo cobbler sync
5.9 Web 测试

访问 http://192.168.145.102/cobbler_web
用户名/密码:cobbler/Letmein

6. 导入系统镜像
这里假定使用CentOS-6.6-x86_64来测试

sudo mount -t auto -o loop /home/kongxx/share/os/CentOS-6.6-x86_64-bin-DVD1.iso /mnt
sudo cobbler import --path=/mnt --name=CentOS-6.6 --arch=x86_64
运行这两条命令后,可以使用下面的命令来查看了

$ sudo cobbler distro list
$ sudo cobbler profile list
也可以通过 Web 界面的 Distros 和 Profiles 来查看。

7. 自动安装系统
由于是在家里的虚拟机里做测试,所以没法使用 IPMI 来管理物理机。这里就只测试一下新的虚拟机可以通过PXE来自动安装系统。

使用VirtualBox创建一个虚拟机,网络设置使用和上面同样的桥接模式。但是在 "虚拟机设置-> 系统 -> 启动顺序" 里把网络勾上并上移到第一位,然后启动虚拟机。此时就可以进入 Cobbler 的网络安装界面,选择上面创建的 CentOS-6.6-x86_64 然后就可以自动安装了。装完后,记得把虚拟机启动顺序改回到硬盘启动优先,然后就可以启动新安装的虚拟机了。

 

运维自动化之Cobbler安装配置 http://www.linuxidc.com/Linux/2013-03/81575.htm

RHEL5.5下Cobbler的配置 http://www.linuxidc.com/Linux/2013-06/86115.htm

运维自动化部署Cobbler之服务安装篇 http://www.linuxidc.com/Linux/2013-02/80133.htm

利用Cobbler批量快速网络安装CentOS http://www.linuxidc.com/Linux/2012-12/75838.htm

CentOS 6.3上安装部署 Cobbler http://www.linuxidc.com/Linux/2012-10/72094.htm

Cobbler批量部署Linux系统 http://www.linuxidc.com/Linux/2014-02/97259.htm

更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-02/113043.htm

linux
相关资讯       Cobbler 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款