Cobbler部署简介

Cobbler是自动化安装的工具,由python开发。使用cobbler可以快速简单的安装部署系统。

Cobbler具有以下功能:

  • 使用一个模板来配置DHCP服务(如果启用了DHCP管理)
  • 将一个存储库(yum或rsync)建立镜像或解压缩的媒介,用来注册一个新的操作系统。
  • 在DHCP配置文件中为需要安装的机器创建一个条目,并指定参数(IP/MAC).
  • 在TFTP服务目录下创建适当的PXE文件
  • 重新启动DHCP服务以反映更改
  • 重启机器以开始安装(如果电源管理已启动)

Cobbler部署

环境准备:

cobbler1 192.168.1.10

安装所需软件包:

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

安装完成之后,在httpd的conf.d目录下会生成cobbler.web.conf和cobber.conf 两个文件。

[[email protected] ~]# ls -l /etc/httpd/conf.d/
total 36
-rw-r--r--. 1 root root 2926 Jul 18 23:30 autoindex.conf
-rw-r--r--. 1 root root 1087 Jan 24  2016 cobbler.conf
-rw-r--r--. 1 root root 1165 Jan 24  2016 cobbler_web.conf
-rw-r--r--. 1 root root  366 Jul 18 23:30 README
-rw-r--r--. 1 root root 9438 Jul 18 23:22 ssl.conf
-rw-r--r--. 1 root root 1252 Jul 18 23:22 userdir.conf
-rw-r--r--. 1 root root  824 Jul 18 23:22 welcome.conf

启动Apache和cobbler:

systemctl start  httpd
systemctl start cobblerd

执行cobbler check:

[[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 : SELinux is enabled. Please review the following wiki page for details 
on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
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.

根具体的提示来安装配置cobbler.

# vim /etc/cobbler/settings 
next_server: 192.168.1.10
server: 192.168.1.10
# vim /etc/xinetd.d/tftp
  disable                 = no
# cobbler get-loaders
# systemctl start rsyncd

设置密码:

# openssl passwd -1 -salt ‘cobbler‘ ‘cobbler‘
$1$cobbler$M6SE55xZodWc9.vAKLJs6.

配置密码:

# vim /etc/cobbler/settings
default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6."

重启cobbler,执行check:

# systemctl restart cobblerd
# cobbler check

使用cobbler管理DHCP:

# vim /etc/cobbler/settings 
manage_dhcp: 1

修改dhcp的模板文件:

# vim /etc/cobbler/dhcp.template 
subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.2;
     option domain-name-servers 192.168.1.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;

重启cobbler:

# systemctl restart cobblerd
# cobbler sync

导入一个cs7镜像:

# mount /dev/cdrom  /mnt/
# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64

导入一个cs6镜像:

导入前需要先卸载镜像,然后装载新的镜像,

# umount  /mnt/
# mount /dev/cdrom  /mnt/
# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64

导入成功后,查看镜像信息:

[[email protected] /]# cobbler profile
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report
[[email protected] /]# cobbler profile list
   CentOS-6-x86_64
   CentOS-7-x86_64
[[email protected] /]# cobbler profile report
Name                           : CentOS-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}  # 可添加内核参数
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : [‘admin‘]
Parent Profile                 : 
Internal proxy                 : 
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm
Name                           : CentOS-6-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS-6-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : [‘admin‘]
Parent Profile                 : 
Internal proxy                 : 
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm

镜像存放的路径为:

/var/www/cobbler/ks_mirror

自定义kickstarts  文件,并将定义的kickstarts 文件放在/var/lib/cobbler/kickstarts目录下:

# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg
# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg

CentOS7 kickstarts文件的内容为:

#Kickstart Config
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel 
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5 
#Network information
$SNIPPET(‘network_config‘)
#network --bootproto=dhcp --device=em1 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled 
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET(‘log_ks_pre‘)
$SNIPPET(‘kickstart_start‘)
$SNIPPET(‘pre_install_network_config‘)
# Enable installation monitoring
$SNIPPET(‘pre_anamon‘)
%end
%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end
%post
systemctl disable postfix.service

%yum_config_stanza
%end

CS6 kickstarts 文件内容:

#Kickstart Configurator for cobbler
#platform=x86, AMD64, or Intel EM64T
key --skip
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel 
#Disk partitioning information
part /boot --fstype ext4 --size 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype ext4 --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5 
#Network information
$SNIPPET(‘network_config‘)
#network --bootproto=dhcp --device=em1 --onboot=on
#Reboot after installation
reboot
#Firewall configuration
firewall --disabled 
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%packages
@ base
@ chinese-support
@ core
sysstat
iptraf
ntp
e2fsprogs-devel
keyutils-libs-devel
krb5-devel
libselinux-devel
libsepol-devel
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
lockdev
minicom
nmap
%post
#/bin/sed -i ‘s/#Protocol 2,1/Protocol 2/‘ /etc/ssh/sshd_config
/bin/sed  -i ‘s/^ca::ctrlaltdel:/#ca::ctrlaltdel:/‘ /etc/inittab
/sbin/chkconfig --level 3 diskdump off
/sbin/chkconfig --level 3 dc_server off
/sbin/chkconfig --level 3 nscd off
/sbin/chkconfig --level 3 netfs off
/sbin/chkconfig --level 3 psacct off
/sbin/chkconfig --level 3 mdmpd off
/sbin/chkconfig --level 3 netdump off
/sbin/chkconfig --level 3 readahead off
/sbin/chkconfig --level 3 wpa_supplicant off
/sbin/chkconfig --level 3 mdmonitor off
/sbin/chkconfig --level 3 microcode_ctl off
/sbin/chkconfig --level 3 xfs off
/sbin/chkconfig --level 3 lvm2-monitor off
/sbin/chkconfig --level 3 iptables off
/sbin/chkconfig --level 3 nfs off
/sbin/chkconfig --level 3 ipmi off
/sbin/chkconfig --level 3 autofs off
/sbin/chkconfig --level 3 iiim off
/sbin/chkconfig --level 3 cups off
/sbin/chkconfig --level 3 openibd off
/sbin/chkconfig --level 3 saslauthd off
/sbin/chkconfig --level 3 ypbind off
/sbin/chkconfig --level 3 auditd off
/sbin/chkconfig --level 3 rdisc off
/sbin/chkconfig --level 3 tog-pegasus off
/sbin/chkconfig --level 3 rpcgssd off
/sbin/chkconfig --level 3 kudzu off
/sbin/chkconfig --level 3 gpm off
/sbin/chkconfig --level 3 arptables_jf off
/sbin/chkconfig --level 3 dc_client off
/sbin/chkconfig --level 3 lm_sensors off
/sbin/chkconfig --level 3 apmd off
/sbin/chkconfig --level 3 sysstat off
/sbin/chkconfig --level 3 cpuspeed off
/sbin/chkconfig --level 3 rpcidmapd off
/sbin/chkconfig --level 3 rawdevices off
/sbin/chkconfig --level 3 rhnsd off
/sbin/chkconfig --level 3 nfslock off
/sbin/chkconfig --level 3 winbind off
/sbin/chkconfig --level 3 bluetooth off
/sbin/chkconfig --level 3 isdn off
/sbin/chkconfig --level 3 portmap off
/sbin/chkconfig --level 3 anacron off
/sbin/chkconfig --level 3 irda off
/sbin/chkconfig --level 3 NetworkManager off
/sbin/chkconfig --level 3 acpid off
/sbin/chkconfig --level 3 pcmcia off
/sbin/chkconfig --level 3 atd off
/sbin/chkconfig --level 3 sendmail off
/sbin/chkconfig --level 3 haldaemon off
/sbin/chkconfig --level 3 smartd off
/sbin/chkconfig --level 3 xinetd off
/sbin/chkconfig --level 3 netplugd off
/sbin/chkconfig --level 3 readahead_early off
/sbin/chkconfig --level 3 xinetd off
/sbin/chkconfig --level 3 ntpd on
/sbin/chkconfig --level 3 avahi-daemon off
/sbin/chkconfig --level 3 ip6tables off
/sbin/chkconfig --level 3 restorecond off
/sbin/chkconfig --level 3 postfix off

这里关闭了一些不必要的启动项。

添加内核参数,使CS7启动后网卡格式自动修改为ethx格式:

# cobbler profile edit --name=CentOS-7-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘

确认内核参数已经加上:

# cobbler profile report CentOS-7-x86_64|grep "Kernel Options" 
Kernel Options                 : {‘biosdevname‘: ‘0‘, ‘net.ifnames‘: ‘0‘}

执行sync命令,使配置生效:

# cobbler sync

Cobbler 自动安装

可以通过创建的虚拟机来查看Cobbler的安装过程,首先启动TFTP(如果没有安装需要安装):

# yum install xinetd -y 
# systemctl start xinetd

新启动一个客户端,默认从网络启动,会自动获取IP地址,进行安装和自动设置。

Cobbler自动重装系统

如果需要从一个已经安装了的CentOS系统重新安装新的系统,可以执行下面的命令查看cobbler服务器上提供的安装镜像:

如果没有koan命令需要先yum安装:

# koan --server=192.168.1.10 --list=profiles  # 指定cobbler服务器
- looking for Cobbler at http://192.168.1.10:80/cobbler_api
CentOS-7-x86_64    #显示当前可用的系统软件版本
CentOS-6-x86_64

指定需要重装的软件版本,此处指定为CS6:

# koan --replace-self --server=192.168.1.10 --profile=CentOS-6-x86_64

根据提示进行reboot 即可开始安装。

使用Cobbler-Web来管理Cobbler

登录的地址为: https://192.168.1.10/cobbler_web

默认的用户和密码都为cobbler

修改用户名和密码:

# htdigest  /etc/cobbler/users.digest  "Cobbler" cobbler   # “描述”  用户

输入此命令后,会提示修改密码。

修改cobbler的启动安装界面

Cobbler的启动安装界面可以有自定义的提示,通修改pxe的模板文件来实现:

[[email protected] ~]# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler this is test==^-^ |   #提示栏信息 
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local                         #默认的启动列表
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1
$pxe_menu_items
MENU end

执行sync 使命令生效:

# cobbler sync

在新建的设备启动界面为:

时间: 2024-08-01 20:33:29

Cobbler部署简介的相关文章

自动化运维之Cobbler部署系统

一 .Cobbler简介 Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP.DNS.yum仓库.构造系统ISO镜像. Cobbler支持命令行管理,web界面管理,还提供了API接口,方便二次开发 Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷. Cobbler提供的功能 使用C

cobbler部署centos6与centos7系列

cobbler部署centos6与centos7系列 转载自:http://www.jianshu.com/p/a4bed77bf40d 版权声明:完全抄自 http://www.jianshu.com/p/a4bed77bf40d 自动化工具分为三大类 预备类(Os Provisioning) PXE cobbler 配置管理类(Os config & Devops ) cfengine chef puppet saltstack func fabric ansible 监控类(Mointor

自动化之cobbler部署

运维自动化之cobbler部署 cobbler介绍 Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用python开发,小巧轻便,使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像. Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用. 优点: 和Kickstart不同的是,使用cobbler不会因为在局域网中启动了dhcp而导致有些机器因为默认从pxe启动

cobbler部署

1.cobbler介绍 Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP.DNS.TFTP.RSYNC以及yum仓库.构造系统ISO镜像.Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用.Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷.  

Cobbler部署之FAQ处理

Cobbler报错处理 通过cobbler check检查出现的报错 红色标注为报错关键信息 9.1 报错一 # cobbler check httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/c

热部署简介及在eclipse安装插件JRebel进行热部署

一.热部署简介 1.热部署与热加载在应用运行的时候升级软件,无需重新启动的方式有两种,热部署和热加载.它们之间的区别是:(1).部署方式: 热部署在服务器运行时重新部署项目.热加载在运行时重新加载class.(2).实现原理热部署直接重新加载整个应用,这种方式会释放内存,比热加载更加干净,但是它比热加载更加的浪费时间.热加载在运行时重新加载class,主要使用的是类加载机制,在实现方式上就是在容器启动的时候起一条后台线程,定时的检测类文件的时间戳变化,如果类的时间戳发生变化,则将类重新载入.(3

Cobbler部署文档V1.0

一.Cobbler 简介 Cobbler由python语言开发,是对PXE和Kickstart以及DHCP的封装.融合很多特性,提供了CLI和Web的管理形式.使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP.DNS.以及yum仓库.构造系统ISO镜像,Cobbler客户端Koan支持虚拟机安装和操作系统重新安装. Cobbler服务是一个容器,它整合了以下几个开源软件: 1 Dhcp 2 Dns (可选bind,dnsmasq) 3 Kickstart/PXE 4 Apa

运维自动化之Cobbler部署安装RHEL7.0(详细图解版)

一.简介     Cobbler 可以用来快速建立 Linux 网络安装环境,它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会.          网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业.自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增.不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE.DHCP.TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚

ELK日志管理平台部署简介

ELK是对Elasticsearch.Logstash.Kibana整合平台的简称.在日常的运维工作中,要实时监控服务器的业务.系统和硬件状态,除了使用监控之外,还需要搜集大量的日志来进行分析.但是在面对海量的服务器和集群时,通过单台登录查询的方式显然是不可能的,对于不同时间段和集群日志的分析仅仅通过简单的脚本来统计也是难以实现.ELK日志平台通过日志搜集,查询检索和前端展示的方式帮我们实现了这样的功能. Elasticsearch是个开源分布式搜索引擎,具有分布式,零配置,自动发现,索引自动分