您的位置:首页 > 运维架构 > Linux

centos6.2 安装部署cobbler

2014-05-15 16:01 441 查看

一. 安装DHCP服务

安装DHCP服务

#yum -y install dhcp

配置DHCP服务

DHCP配置文件为/etc/dhcp/dhcpd.conf,但该文件默认是没有内容的,可以从dhcp安装目录复制一个到/etc下。

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

vi /etc/dhcp/dhcpd.conf

修改DHCP内容如下:

subnet 10.42.0.0 netmask 255.255.255.0 {

  range 10.42.0.26 10.42.0.30;

  option domain-name-servers ns1.internal.example.org;

  option domain-name "10.42.0.3";

  option routers 10.42.0.2;

  option broadcast-address 10.42.0.255;

  default-lease-time 600;

  max-lease-time 7200;

在dhcpd.conf末尾添加如下内容:

# for Cobbler setup

host cobbler {

    option host-name "cobbler";

    ddns-hostname "cobbler";

    hardware ethernet 00:0C:29:6D:F1:E1; #MAC address of cobbler server

            fixed-address 10.42.0.3; #IP of Cobbler server

            allow booting;

    allow bootp;

    class "PXE" {

        match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";

        next-server 10.42.0.3; #IP of Cobbler server

            filename "pxelinux.0";

    }

}

 

指定DHCP端口

#vi /etc/sysconfig/dhcpd

修改内容如下:

# Command line options here

DHCPDARGS=eth0

启动DHCP服务器

#service dhcpd start

让dhcp服务随系统而启动:

#chkconfig dhcpd on

二.安装和配置Cobbler 

由于Cobbler 不在 CentOS 6.2 的基本源中,需要导入 EPEL 源:

#rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

#yum update

安装 cobbler:

#yum install cobbler

修改 cobbler 服务器所在的 IP 地址:(默认的是:127.0.0.1)

# vi /etc/cobbler/settings

修改内容如下:

next_server: 10.42.0.3 #IP of Cobblerserver

server: 10.42.0.3 #IP of Cobbler server

启用 httpd, xinetd 和 cobbler 服务并确认已经加到系统自动启动服务中:

# /etc/init.d/httpd start

# /etc/init.d/xinetd start

# /etc/init.d/cobblerd start

# chkconfig httpd on

# chkconfig xinetd on

# chkconfig cobblerd on

修改 rsync 和 tftp 这两个服务的 xinetd 配置:

# vi /etc/xinetd.d/rsync

修改内容如下(将默认的disable = yes 改为disable = no):

service rsync

{

       disable = no

...

}

 

# vi /etc/xinetd.d/tftp

service tftp

{

       ...

       disable = no

       ...

}

关闭防火墙和 SELinux 后重启系统:

# /etc/init.d/iptables stop

# chkconfig iptables off

# vi /etc/sysconfig/selinux

修改内容如下:

 SELINUX=disabled

重启服务器:

# reboot

 

 

 

 

 

 

 

 

 

 

 

 

三.检查和修改Cobbler
配置

#cobbler get-loaders
#cobbler check
系统重启后用 cobbler check 检查发现4个配置信息问题,第一个是如果要部署 debian/ubuntu 系统需要 debmirror 软件包;第二个是没有安装第三个是需要修改 cobbler 的默认密码;第四个是可选,想使用电源管理功能的话需要安装 cman 或 fence-agents:

1 : debmirror package is not installed, it willbe required to manage debian deployments and repositories
2 : ksvalidator was not found, installpykickstart
3 : The default password used by the sampletemplates 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
4 : fencing tools were not found, and arerequired to use the (optional) power management features. install cman orfence-agents to use them
现在来修复上面四个问题,我们希望能让这台 cobbler 服务器能同时部署 CentOS/Fedora 和 Debian/Ubuntu 系统,所以需要安装 debmirror,安装 debmirror-20090807-1.el5.noarch.rpm前需要先安装依赖包:

修复问题1:

# yum install wget

# yum install ed patch perl perl-Compress-Zlibperl-Cwd perl-Digest-MD5 \

perl-Digest-SHA1 perl-LockFile-Simpleperl-libwww-perl

# wgetftp://fr2.rpmfind.net/linux/epel/5/ppc/debmirror-20090807-1.el5.noarch.rpm

# rpm -ivhdebmirror-20090807-1.el5.noarch.rpm

修改 /etc/debmirror.conf 配置文件,注释掉@dists 和 @arches 两行

# vi /etc/debmirror.conf

修改内容如下:

#@dists="sid";

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

#@arches="i386";

修复问题2:

安装ksvalidator

#yum install pykickstart

修复问题3:

修改默认系统密码用 openssl 生成一串密码后加入到 cobbler 的配置文件(/etc/cobbler/settings)里,替换 default_password_crypted 字段:

 

# openssl passwd -1 -salt 'cobbler''root1234'

$1$www.bolu$1Z8uxDS.hS3dD8lTQzvPG/

 

# vi /etc/cobbler/settings

修改内容如下:

default_password_crypted:"$1$www.bolu$1Z8uxDS.hS3dD8lTQzvPG/"

修复问题4:

安装 cman:

# yum install cman

修复完成后,重启cobbler服务

# /etc/init.d/cobblerd restart

再用 cobbler check 检查一下

# cobbler check

No configuration problems found.  All systems go.

确认没问题后用 cobbler sync 做同步操作:

# cobbler sync

 

 

 

 

 

 

 

四.导入引导系统

挂载 CentOS-6.2-x86_64-bin-DVD1.iso 安装光盘然后导入到 cobbler(注意这个 iso 文件有 4GB 多,导入可能需要一段时间),导入成功后 cobbler list 查看一下:

# mount -o loop -t iso9660CentOS-6.2-x86_64-bin-DVD1.iso /mnt

或者是从光驱导入:

#mount -t iso9660 /dev/cdrom /mnt/

完成上述二选一步骤后:

# cobbler import --path=/mnt--name=CentOS-6.2-x86_64-bin-DVD1 --arch=x86_64

# cobbler sync

# cobbler list

显示内容如下:

distros:

  CentOS-6.2-bin-DVD1-x86_64

 

profiles:

  CentOS-6.2-bin-DVD1-x86_64

 

systems:

 

repos:

 

images:

 

五.测试

最后创建一台虚拟机测试一下,把虚拟机设置成网络 PXE 启动(和cobbler 在同一个网络),启动后就可以看到 Cobbler 引导界面,看到界面后选择CentOS-6.2-bin-DVD1-x86_64 条目就可以顺利开始无人工干预安装系统,Cobbler 引导界面如下:

安装完系统后默认的密码是啥呢?根据 sample.ks 的配置提示,这个密码 $default_password_crypted 就是我们上面用 opensslpasswd -1 -salt ‘www.bolu.com’ ‘bolu’ 生成的密码,所以这里的 root 密码是bolu:

 

# cat/var/lib/cobbler/kickstarts/sample.ks

 

4000
#Root password

rootpw --iscrypted$default_password_crypted

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

六.其他

1.如何导入Centos DVD的第二张光盘?

导入进去的 iso 其实都是在/var/www/cobbler/ks_mirror/ 目录下面,直接把 DVD2 的内容拷贝到 /var/www/cobbler/ks_mirror/CentOS-6.2-x86_64-bin-DVD1/ 的相关目录里就可以。

2.如何在 Cobbler
上导入和启动 Ubuntu?

Cobbler 在 CentOS/RHEL/Fedora 系的发行版上工作良好,在CentOS/RHEL/Fedora
上安装 Cobbler 以后可以直接导入 CentOS/RHEL/Fedora ISO 文件,很顺利(6月15日按以上方法导入Ubuntu iso正常).

不过如果在导入 Ubuntu/Debian ISO不幸运,ubuntu-11.10-server-amd64.iso 会报错的话,可尝试用以下方法:

# cobbler import --path=/mnt/ –-name=ubuntu-11.10-server-amd64

...

sent 710595315 bytes  received 36388 bytes  52639385.41 bytes/sec

total size is 710349452  speedup is 1.00

...

!!! TASK FAILED !!!

忽略上面的错误,会发现在 ks_mirror 下面已经导入了 ubuntu-11.10-server-amd64 整个 ubuntu 目录:

# ls /var/www/cobbler/ks_mirror/

config ubuntu-11.10-server-amd64

如果对上面已经导入的 ubuntu 目录还不放心的话,可以删除这个目录后手动导入(直接 cp 就行):

# rm -rf /var/www/cobbler/ks_mirror/ubuntu-11.10-server-amd64

# mount -o loop -t iso9660 ubuntu-11.10-server-amd64.iso/mnt

# cp -r /mnt//var/www/cobbler/ks_mirror/ubuntu-11.10-server-amd64

完成导入(拷贝)后,做个链接:

# cd /var/www/cobbler/links/

#ln -s /var/www/cobbler/ks_mirror/ubuntu-11.10-server-amd64ubuntu-11.10-server-amd64

 

 

 

然后加入 distro 和 profile:

# cobbler distro add --name=ubuntu-11.10-server-amd64--kernel=/var/www/cobbler/ks_mirror/ubuntu-11.10-server-amd64/install/netboot/ubuntu-installer/amd64/linux--initrd=/var/www/cobbler/ks_mirror/ubuntu-11.10-server-amd64/install/netboot/ubuntu-installer/amd64/initrd.gz--arch=x86_64
--breed=ubuntu --ksmeta="directory=/cblr/links/ubuntu-11.10-server-amd64"

# cobbler profile add --name=ubuntu-11.10-server-amd64--distro=ubuntu-11.10-server-amd64--kickstart=/var/lib/cobbler/kickstarts/ubuntu-11.10-server-amd64.seed

最后我们需要 ubuntu 能完成自动安装,加入以下 kickstart 脚本 ubuntu-11.10-server-amd64.seed到 /var/lib/cobbler/kickstarts/ :

# vi /var/lib/cobbler/kickstarts/ubuntu-11.10-server-amd64.seed
d-i     debian-installer/localestring en_US.UTF-8
d-i     debian-installer/splashboolean false
d-i    console-setup/ask_detect       boolean false
d-i    console-setup/layoutcode       string us
d-i    console-setup/variantcode      string
d-i     netcfg/get_nameservers  string
d-i     netcfg/get_ipaddress    string
d-i     netcfg/get_netmask      string 255.255.255.0
d-i     netcfg/get_gateway      string
d-i     netcfg/confirm_static   boolean true
d-i     clock-setup/utc boolean true
d-i     partman-auto/method stringregular
d-i    partman-lvm/device_remove_lvm boolean true
d-i     partman-lvm/confirm booleantrue
d-i    partman/confirm_write_new_label boolean true
d-i    partman/choose_partition       select Finish partitioning and write changes to disk
d-i     partman/confirm boolean true
d-i     partman/confirm_nooverwriteboolean true
d-i     partman/default_filesystemstring ext3
d-i     clock-setup/utc boolean true
d-i     clock-setup/ntp boolean true
d-i     clock-setup/ntp-server  string ntp.ubuntu.com
d-i    base-installer/kernel/image    string linux-server
d-i     passwd/root-login       boolean false
d-i     passwd/make-user        boolean true
d-i     passwd/user-fullname    string ubuntu
d-i     passwd/username stringubuntu
d-i    passwd/user-password-crypted   password $default_password_crypted
d-i     passwd/user-uid string
d-i    user-setup/allow-password-weak boolean false
d-i     user-setup/encrypt-homeboolean false
d-i    passwd/user-default-groups     string adm cdrom dialout lpadmin plugdev sambashare
d-i    apt-setup/services-select      multiselect security
d-i     apt-setup/security_hoststring security.ubuntu.com
d-i     apt-setup/security_pathstring /ubuntu
d-i    debian-installer/allow_unauthenticated string false
d-i     pkgsel/upgrade  select safe-upgrade
d-i     pkgsel/language-packs   multiselect
d-i     pkgsel/update-policy    select none
d-i     pkgsel/updatedb boolean true
d-i     grub-installer/skip     boolean false
d-i     lilo-installer/skip     boolean false
d-i    grub-installer/only_debian     boolean true
d-i    grub-installer/with_other_os   boolean true
d-i    finish-install/keep-consoles   boolean false
d-i    finish-install/reboot_in_progress      note
d-i     cdrom-detect/eject      boolean true
d-i    debian-installer/exit/halt     boolean false
d-i    debian-installer/exit/poweroff boolean false
d-i     pkgsel/include stringopenssh-server
 

cobbler profile remove --name=centos6.0

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: