无人值守安装系统之Cobbler

cobbler介绍

Cobbler集中和简化了通过网络安装操作系统需要使用到的DHCP、TFTP和DNS服务的配置。Cobbler不仅有一个命令行界面,还提供了一个Web界面,大大降低了使用者的入门水平。Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

系统环境准备

[[email protected] ~]$ uname -r

2.6.32-642.el6.x86_64

[[email protected] ~]$ uname -m

x86_64

[[email protected] ~]$ ifconfig eth0|awk -F "[ :]+" ‘NR==2 {print $4}‘

10.0.0.101

安装cobbler

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd

检查Cobbler的配置,如果看不到下面的结果,再次执行/etc/init.d/cobblerd restart,执行后会有一堆错误

[[email protected] ~]$ 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 : file /etc/xinetd.d/rsync does not exist

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

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

9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.

看着上面的错误一个一个解决

# 看着上面的结果,一个一个解决。

# 第1、2、6个问题,顺便修改其他功能

[[email protected]-node1 ~]# cp /etc/cobbler/settings{,.ori} # 备份

# server,Cobbler服务器的IP。

sed -i ‘s/server: 127.0.0.1/server: 10.0.0.101/‘ /etc/cobbler/settings

# next_server,如果用Cobbler管理DHCP,修改本项,作用不解释,看kickstart。

sed -i ‘s/next_server: 127.0.0.1/next_server: 10.0.0.101/‘ /etc/cobbler/settings

# 用Cobbler管理DHCP

sed -i ‘s/manage_dhcp: 0/manage_dhcp: 1/‘ /etc/cobbler/settings

# 防止循环装系统,适用于服务器第一启动项是PXE启动。

sed -i ‘s/pxe_just_once: 0/pxe_just_once: 1/‘ /etc/cobbler/settings

# 设置新装系统的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定。

[[email protected]-node1 ~]# openssl passwd -1 -salt ‘oldboy‘ ‘123456‘

$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1

[[email protected]-node1 ~]# vim /etc/cobbler/settings

default_password_crypted: "$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1"

# 第3个问题

[[email protected]-node1 ~]# cobbler get-loaders # 会自动从官网下载

[[email protected]-node1 ~]# cd /var/lib/cobbler/loaders/ # 下载的内容

[[email protected]-node1 loaders]# ls

COPYING.elilo COPYING.yaboot grub-x86_64.efi menu.c32 README

COPYING.syslinux elilo-ia64.efi grub-x86.efi pxelinux.0 yaboot

# 第4个问题

[[email protected]-node1 ~]# vim /etc/xinetd.d/rsync

disable = no

[[email protected]-node1 ~]# /etc/init.d/xinetd restart

停止 xinetd: [确定]

正在启动 xinetd: [确定]

[[email protected]-node1 ~]# /etc/init.d/cobblerd restart

Stopping cobbler daemon: [确定]

Starting cobbler daemon: [确定]

[[email protected]-node1 ~]# cobbler check

The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories # 和debian系统相关,不需要

2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them # fence设备相关,不需要

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.

执行下面的命令,修改配置文件

sed -i ‘s/server: 127.0.0.1/server: 172.16.1.101/‘ /etc/cobbler/settings

sed -i ‘s/next_server: 127.0.0.1/next_server: 172.16.1.101/‘ /etc/cobbler/settings

sed -i ‘s/manage_dhcp: 0/manage_dhcp: 1/‘ /etc/cobbler/settings

sed -i ‘s/pxe_just_once: 0/pxe_just_once: 1/‘ /etc/cobbler/settings

sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt ‘oldboy‘ ‘123456‘`\"#" /etc/cobbler/settings

sed -i ‘s#yes#no#‘ /etc/xinetd.d/rsync

sed -i ‘s#yes#no#‘ /etc/xinetd.d/tftp

配置DHCP

# 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。

[[email protected] loaders]# sed -i ‘s#192.168.1#172.16.1#g;22d;23d‘ /etc/cobbler/dhcp.template

同步cobbler配置

[[email protected] ~]# cobbler sync

task started: 2017-04-14_101410_sync

task started (id=Sync, time=Fri Apr 14 10:14:10 2017)

running pre-sync triggers

cleaning trees

removing: /var/lib/tftpboot/pxelinux.cfg/default

removing: /var/lib/tftpboot/grub/grub-x86_64.efi

removing: /var/lib/tftpboot/grub/efidefault

removing: /var/lib/tftpboot/grub/grub-x86.efi

removing: /var/lib/tftpboot/grub/images

removing: /var/lib/tftpboot/s390x/profile_list

copying bootloaders

trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi

trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi

copying distros to tftpboot

copying images

generating PXE configuration files

generating PXE menu structure

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

rendering TFTPD files

generating /etc/xinetd.d/tftp

cleaning link caches

running post-sync triggers

running python triggers from /var/lib/cobbler/triggers/sync/post/*

running python trigger cobbler.modules.sync_post_restart_services

running: dhcpd -t -q

received on stdout:

received on stderr:

running: service dhcpd restart

received on stdout: Shutting down dhcpd: [  OK  ]

Starting dhcpd: [  OK  ]

received on stderr:

running shell triggers from /var/lib/cobbler/triggers/sync/post/*

running python triggers from /var/lib/cobbler/triggers/change/*

running python trigger cobbler.modules.scm_track

running shell triggers from /var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

启动服务

/etc/init.d/xinetd restart
/etc/init.d/cobblerd restart
/etc/init.d/httpd restart

打开网页进行操作

输入http://10.0.0.101/cobbler

挂载光盘,到mnt下。或者下好的系统镜像

自动应答模板

#CentOS-6.8

install

url --url=$tree

text

lang en_US.UTF-8

keyboard us

zerombr

bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

$SNIPPET(‘network_config‘)

timezone --utc Asia/Shanghai

authconfig --enableshadow --passalgo=sha512

rootpw  --iscrypted $default_password_crypted

clearpart --all --initlabel

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

part swap --size=1024

part / --fstype=ext4 --grow --asprimary --size=200

firstboot --disable

selinux --disabled

firewall --disabled

logging --level=info

reboot

%pre

$SNIPPET(‘log_ks_pre‘)

$SNIPPET(‘kickstart_start‘)

$SNIPPET(‘pre_install_network_config‘)

# Enable installation monitoring

$SNIPPET(‘pre_anamon‘)

%end

%packages

@base

@compat-libraries

@debugging

@development

tree

nmap

sysstat

lrzsz

dos2unix

telnet

%end

%post --nochroot

$SNIPPET(‘log_ks_post_nochroot‘)

%end

%post

$SNIPPET(‘log_ks_post‘)

# Start yum configuration

$yum_config_stanza

# End yum configuration

$SNIPPET(‘post_install_kernel_options‘)

$SNIPPET(‘post_install_network_config‘)

$SNIPPET(‘func_register_if_enabled‘)

$SNIPPET(‘download_config_files‘)

$SNIPPET(‘koan_environment‘)

$SNIPPET(‘redhat_register‘)

$SNIPPET(‘cobbler_register‘)

# Enable post-install boot notification

$SNIPPET(‘post_anamon‘)

# Start final steps

$SNIPPET(‘kickstart_done‘)

# End final steps

%end

可以去http://blog.oldboyedu.com/autoinstall-cobbler/查看详细的过程

CentOS-7.1

install

url --url=$tree # 这些$开头的变量都是调用配置文件里的值。

text

lang en_US.UTF-8

keyboard us

zerombr

bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

# Network information

$SNIPPET(‘network_config‘)

timezone --utc Asia/Shanghai

authconfig --enableshadow --passalgo=sha512

rootpw --iscrypted $default_password_crypted

clearpart --all --initlabel

part /boot --fstype xfs --size 1024 # CentOS7系统磁盘默认格式xfs

part swap --size 1024

part / --fstype xfs --size 1 --grow

firstboot --disable

selinux --disabled

firewall --disabled

logging --level=info

reboot

%pre

$SNIPPET(‘log_ks_pre‘)

$SNIPPET(‘kickstart_start‘)

$SNIPPET(‘pre_install_network_config‘)

# Enable installation monitoring

$SNIPPET(‘pre_anamon‘)

%end

%packages

@base

@compat-libraries

@debugging

@development

tree

nmap

sysstat

lrzsz

dos2unix

telnet

iptraf

ncurses-devel

openssl-devel

zlib-devel

OpenIPMI-tools

screen

%end

%post

systemctl disable postfix.service

%end

定制化安装

可能从学习kickstart开始就有人想怎样能够指定某台服务器使用指定ks文件,kickstart实现这功能可能比较复杂,但是Cobbler就很简单了。

区分一台服务器的最简单的方法就是物理MAC地址。

物理服务器的MAC地址在服务器上的标签上写了。

虚拟机的MAC查看

cobbler system add --name=oldboy --mac=00:0C:29:7F:2F:A1 --profile=CentOS-7.1-x86_64 --ip-address=10.0.0.111 --subnet=255.255.255.0 --gateway=10.0.0.2 --interface=eth0 --static=1 --hostname=oldboy.example.com --name-servers="114.114.114.114 8.8.8.8"

# --name 自定义,但不能重复

# 查看定义的列表

[[email protected]-node1 ~]# cobbler system list

oldboy

[[email protected]-node1 ~]# cobbler sync

打开新建的虚拟机进行安装系统

原文地址:https://www.cnblogs.com/HByang/p/9207077.html

时间: 2024-10-16 09:32:44

无人值守安装系统之Cobbler的相关文章

Cobbler无人值守安装系统史上最细实践文档

本文档来自老男孩教育VIP课程 内部学员总结笔记文档笔记内容,和大家分享! 老男孩教育2016年全干货博客,http://blog.oldboyedu.com Cobbler无人值守安装系统史上最细实践文档 http://blog.oldboyedu.com/autoinstall-cobbler/

PXE+Kickstart无人值守安装系统re

PXE(Preboot Excute Environment)预启动执行环境,可以让计算机通过网络启动系统,主要用于无人值守安装系统中引导客户端主机安装Linux操作系统. 由于之前有过使用cobbler+kickstart PXE安装系统的博客,这里RHEL7下使用第二种方法. 部署PXE相关环境 第一步:DHCP服务 部署DHCP服务之前,由于使用虚拟机测试,为了避免虚拟机软件的DHCP功能对本实验造成影响,在网络配置中将应用DHCP服务选项取消掉 安装DHCP服务 [root@localh

pxe+dhcp+apache+kickstart无人值守安装系统centos

pxe+dhcp+apache+kickstart无人值守安装系统 挂载系统盘. mkdir /mnt/cdrom mount /dev/cdrom /mnt/cdrom 关闭selinux.关闭防火墙 setenforce 0 /etc/init.d/iptables stop 安装apache服务(默认是安装的) yum install apache -y 复制光盘的内容,到网站目录 cp -rf /mnt/cdrom/* /var/www/html/ 安装tftp-server服务 yum

kickstart 无人值守安装系统

起因:新服务器到货,安装系统,可是公司里的系统盘总是不给力,第一次,只带了一个光盘,结果安装完成一台之后就罢工了,只好回公司第二天再来安装,第二次,有经验了带了3张光盘,刻盘的兄弟估计刻录完成没有测试,结果只有一张盘可用,本来半个小时的工作,这个干了2个多小时,太没有效率了,哥们实在忍不住了,就做了一个kickstart无人值守安装. 一.配置过程 配置PXE安装,要进行如下步骤: 1.配置DHCP,用于给客户端提供IP地址等信息. 安装dhcp 直接yum [[email protected]

虚拟机做服务器实现无人值守安装系统的思考和问题

这个问题我研究很久,目前的情况是这样的,让我慢慢道来. 一.整体拓扑 1.笔记本电脑宿主主机(xp系统),宿主主机上安装一个vm10的虚拟机. 2.虚拟机安装redhat6.0的linux系统,作为DHCP服务器.TFTP服务器.NFS服务器/HTTP服务器/FTP服务器的整体服务器. 3.客户机是另外一台没有任何系统的带有PXE功能的电脑,并且BIOS已经配置成为网卡启动. 4.是我简单画了一个图片,以便理解. 二.思考和问题 本人在一个独立的服务器上部署这些相关的服务器,可以顺利完成无人值守

PXE+Kickstart无人值守安装系统

PXE+Kickstart无人值守安装系统 一.介绍 二.原理 三.安装部署PXE+kickstart 四.安装TFTP 五.安装DHCP 六.生成kickstart(ks.cfg)文件 七.安装HTTP 八.虚拟机测试自动安装 一.介绍 CentOS的安装方法挺多,最常见的有光盘.Kickstart无人值守安装.U盘安装及ISO硬盘安装等.如果现在让你安装100台服务器,甚至更多台服务器,你会用什么办法安装呢,用光盘?这样要损坏多少张光盘呢,价格也不菲,U盘安装?一台一台接,很累好不好,用ki

CentOS7.x安装cobbler无人值守安装系统

CentOS7.x cobbler无人值守安装 cobbler介绍 自打若干年前 Red Hat,推出了 Kickstart,不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE.DHCP.TFTP,还有的 Kickstart 脚本,就能瞬间安装上百台服务器. Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠). Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚

Cobbler实现无人值守安装系统

防伪码:没有相当程度的孤独是不可能有内心的平和. 1.概述 本文部分图片源自网络,侵删. 1.1 介绍 官网地址 http://cobbler.github.io/ 官网介绍:Cobbleris a Linux installation server that allows for rapid setup of networkinstallation environments. It glues together and automates many associatedLinux tasks

PXE无人值守安装系统

实验拓扑:             RHEL6.5_1-----CentOS6.5(vmnet1)----------(vmnet1)            RHEL6.5_2实验一:搭建PXE装机服务器    操作系统:RHEL 6.5    网卡连接:eth0  (VMnet1)    主机名:svr5.tarena.com    IP地址:192.168.4.5/24    关闭 iptables 防火墙.SELinux防护机制 1.检查实验环境[[email protected] ~]#