“ubuntu教程”centos6用cobbler批量部署centos、ubunt

来源: 电脑维修教程 阅读:     发表时间:

主动安装cobbler无人职守 颠末屡次实践,改来改去,供列位需要利用cobbler主动摆设系统的朋侪参考 参考文章 1、http://kerry.blog.51cto.com/172631/648430/ 2、http:/

主动安装cobbler无人职守

颠末屡次实践,改来改去,供列位需要利用cobbler主动摆设系统的朋侪参考

参考文章

1、http://kerry.blog.51cto.com/172631/648430/

2、http://my.oschina.net/alanlqc/blog/147047

3、http://hi.baidu.com/chenshake/item/4d94a7dd88a3ec16e0f46ff8

安装cobbler,需要epel或者rpmforge源,若需要摆设debian/ubuntu类系统,需要安装debmirror,需要epel源。到http://dl.fedoraproject.org/pub找合适自己系统的包。我的是centos6.2-x86_64所以安装下面这个epel源

rpm -uvh http://dl.fedoraproject.org/pub/epel/6server/x86_64/epel-release-6-8.noarch.rpm

从下面地址找合适自己系统的debmirror包

http://rpmfind.net/linux/rpm2html/search.php?query=debmirror

安装cobbler与debmirror相关软件

yum install cobbler dhcp xinetd fence-agents pykickstart ed patch perl perl-compress-zlib perl-digest-sha perl-lockfile-simple perl-libwww-perl

起头安装debmirror,

rpm -uvh ftp://rpmfind.net/linux/epel/6/x86_64/debmirror-2.14-2.el6.noarch.rpm

点窜/etc/debmirror.conf设置装备摆设文件,注释失落@dists和@arches两行

vim /etc/debmirror.conf

#@dists="sid";

#@arches="i386";

开启cobbler服务并下载loaders

/etc/init.d/cobblerd restart && /etc/init.d/httpd restart && cobbler get-loaders

设置开机启动项

chkconfig xinetd on && chkconfig httpd on && chkconfig dhcpd on && chkconfig ip6tables off && chkconfig iptables off

点窜cobbler设置装备摆设

默认的,颠末cobbler安装后的系统root暗码是cobbler

若是不改,在cobbler check时会提醒不平安。仍是改一下把。假定预设root暗码为admaster,则用openssl passwd -1 -salt转换可获得md5码加密的字串

openssl passwd -1 -salt 1 admaster

复制获得的字串后

vim /etc/cobbler/settings

全文搜刮default_password_crypted后面的引号里粘上复制的那串

继续全文搜刮127.0.0.1替代成响应服务器ip

若cblr和tftp是统一台机械的环境可以全文查找替代

:%s/127.0.0.1/192.168.44.249/g

若是分歧则别离设置

设置cobbler server的ip地址

server: 192.168.44.249

设置pxe server的ip地址

next-server: 192.168.44.250

开启主动dhcp经管

manage_dhcp: 1

开启主动rsync经管

manage_rsync: 1

开启tftp和rsync

将两个服务设置装备摆设文件的disable = yes改成no

sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp && sed -i '/disable/s/yes/no/g' /etc/xinetd.d/rsync

设置装备摆设dhcp模板

vim /etc/cobbler/dhcp.template

将网段、网关、路由写好留存退出

先从头加载一下cobbler的设置装备摆设,再同步所有设置

/etc/init.d/cobblerd restart && cobbler sync

当执行cobbler sync时报以下过错

dhcpd -t failed

exception occured: <class 'cobbler.cexceptions.cx'>

exception value: 'cobbler trigger failed: cobbler.modules.sync_post_restart_services'

exception info:

file "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 89, in run

rc = self._run(self)

file "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 184, in runner

return self.remote.api.sync(self.options.get("verbose",false),logger=self.logger)

file "/usr/lib/python2.6/site-packages/cobbler/api.py", line 701, in sync

return sync.run()

file "/usr/lib/python2.6/site-packages/cobbler/action_sync.py", line 155, in run

utils.run_triggers(self.api, none, "/var/lib/cobbler/triggers/sync/post/*", logger=self.logger)

file "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 918, in run_triggers

raise cx("cobbler trigger failed: %s" % m.__name__)

!!! task failed !!!

是dhcp服务没起来的原因,查看/etc/dhcp/dhcpd.conf,多是网段超越或者掩码不准确。具体问题可以执行tailf -100 /var/log/messages

导入系统iso

mkdir /cdrom

mount -o loop -t iso9660 ~/iso/centos-6.2-x86_64-bin-dvd1.iso /cdrom

cobbler import --path=/cdrom --name=centos-6.2 --arch=x86_64

umount -l /cdrom

mount -o loop -t iso9660 ~/iso/ubuntu-12.04.4-server-amd64.iso /cdrom

cobbler import --path=/cdrom --name=ubuntu-12.04.4-server --arch=x86_64

因为cobbler在导入initrd.gz的时辰犯错,所以手动把光盘netboot里面的复制过来笼盖。

cp /cdrom/install/netboot/ubuntu-installer/amd64/initrd.gz /var/lib/tftpboot/images/ubuntu-12.04.4-server-x86_64

提醒笼盖选y

设置装备摆设kickstart文件

mkdir -p /var/www/cobbler/ks/

编写centos6的ks.cfg

vim /var/www/cobbler/ks/centos6.cfg

# centos6/ks.cfg

firewall --disabled

install

url --url http://192.168.44.249/cobbler/ks_mirror/centos-6.2-x86_64

text

firstboot --disable

rootpw admaster

auth --useshadow --enablemd5

lang en_us

keyboard us

selinux --disabled

logging --level=info

reboot

timezone --isutc asia/shanghai

network --bootproto=dhcp --device=eth0 --onboot=on

zerombr

bootloader --location=mbr

clearpart --all --initlabel

part swap --fstype="swap" --size=4096

part /boot --fstype="ext4" --size=200

part / --fstype="ext4" --size=1 --grow

%packages

openssh-server

openssh

vim

如需安装图形界面,在vim下面添加下面这三行

@ x window system

@ desktop

@ desktop platform

编写ubuntuserver12的ks文件

vim /var/www/cobbler/ks/ubuntuserver12.cfg

#以下是阿谢的ks.cfg for ubuntu server 12

install

url --url http://192.168.44.249/cobbler/ks_mirror/ubuntu-12.04.4-server-x86_64

preseed passwd/root-login boolean true

lang en_us

langsupport --default en_us.utf-8 en_us.utf-8

keyboard us

mouse

timezone asia/shanghai

rootpw --disabled

user john --fullname "john chu" --password admaster

reboot

text

bootloader --location=mbr

zerombr yes

clearpart --all --initlabel

partman-lvm/device_remove_lvm boolean true

partman-md/device_remove_md boolean true

part / --fstype ext4 --size 1 --grow --asprimary

# 不设置swap时安装进程中会提醒要不要从头添加swap分区

part swap --size 4096

auth --useshadow --enablemd5

network --bootproto=dhcp --device=eth0

firewall --disabled

skipx

%packages

@ base

openssh-server

openssh-client

vim

gcc

make

指定各系统所对应的ks文件位置

cobbler profile edit --name=centos-6.2-x86_64 --kickstart=/var/www/cobbler/ks/centos6.cfg

cobbler profile edit --name=ubuntu-12.04.4-server-x86_64 --kickstart=/var/www/cobbler/ks/ubuntuserver12.cfg

--name后面是/var/lib/cobbler/config/profiles.d目次里json文件名,若是提醒过错就去看看json的名字究竟是什么把name改成响应的便可

若需删除已导入系统安装源,先查看都有哪些安装源

cobbler list

选中一个不顺眼的直接remove profile和distro

cobbler profile remove --name=centos-6.2-i386

cobbler distro remove --name=centos-6.2-i386

验证是不是已成功删除

cobbler profile find --distro=centos-6.2-i386

成果为空暗示成功

注重centos-6.2 x86_64的dvd镜像在导入时辰会被cobbler过错地辨认成既有i386又有x86_64,所以不要删除i386的,不然x86_64也没了,我碰到过一次,可以把pxelinux.cfg/default这个启动菜单点窜一下便可

点窜pxe启动菜单default

vim /var/lib/tftpboot/pxelinux.cfg/default

timeout改成你但愿的秒数x10,因为这个值的单元是100毫秒

totaltimeout不明白干啥的

centos的append后写上ks=http://你kickstart服务器ip/cobbler/ks/设置装备摆设文件名,如许写

append initrd=/images/centos-6.2-x86_64/initrd.img ksdevice=eth0 lang= kssendmac text ks=http://192.168.44.249/cobbler/ks/centos6.cfg

ubuntu的append如许写

append initrd=/images/ubuntu-12.04.4-server-x86_64/initrd.gz ksdevice=eth0 ks=http://192.168.44.249/cobbler/ks/ubuntuserver12.cfg

以上ksdevice暗示从哪块网卡进行安装

封闭selinux

sed -i '/selinux/s/permissive/disabled/g' /etc/selinux/config && sed -i '/selinux/s/enforcing/disabled/g' /etc/selinux/config && setenforce 0

封闭iptables防火墙

/etc/init.d/iptables stop

打开dhcpd和xinetd

/etc/init.d/dhcpd restart && /etc/init.d/xinetd restart

查抄cobbler是不是已设置装备摆设完毕并依照提醒进行批改

cobbler check

呈现以下提醒

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories

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

3 : reposync is not installed, need for cobbler reposync, install/upgrade yum-utils?

4 : yumdownloader is not installed, needed for cobbler repo add with --rpm-list parameter, install/upgrade yum-utils?

5 : one or more repos need to be processed by cobbler reposync for the first time before kickstarting against them: ubuntu-12.04.4-server-x86_64

第一是提醒若是需要安装debian/ubuntu系统,必需安装debmirror包

方式在前面有

第二点是因为没有点窜默认root暗码cobbler

第三、四、五点问题不大,可以疏忽

客户端经由过程pxe收集启动

在指导菜单中选择需要安装的系统便可

若往后哪台服务器需要重装系统了,在这台服务器上需要安装koan东西,是依托rpmforge,先在这机械上安装rpmforge,去http://pkgs.repoforge.org/rpmforge-release/查看合适自己系统的包,好比我的是centos6.2-x86_64所以如许装

rpm -uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

安装好rpmforge后,安装koan

yum install koan

以上是:解决“ubuntu教程”centos6用cobbler批量部署centos、ubunt问题的详细资料教程