网络安装操作系统之——-cobbler批量安装操作系统

cobbler批量安装操作系统

环境:workstation10

cobbler server:操作系统 Centos6.6

ip:192.168.1.17 桥接物理机上(可上外网)

关闭iptables ,关闭selinux

[[email protected] ~]# chkconfig iptables off 
[[email protected] ~]# /etc/init.d/iptables stop 
[[email protected] ~]# getenforce 
Disabled

进入主题了

[[email protected] ~]#rpm -Uvh http://mirrors.hustunique.com/epel/6/x86_64/epel-release-6-8.noarch.rpm   #导入epel源

[[email protected] ~]#yum -y install httpd rsync tftp-server xinetd dhcp python-ctypes cman pykickstart   #安装cobbler依赖的包

[[email protected] ~]#yum -y install cobbler* debmirror*  #安装cobbler

[[email protected] ~]# cobbler check                    #检查cobbler配置
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 : 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. 
4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync 
5 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support 
6 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support 
7 : 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

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

[[email protected] ~]# vi /etc/cobbler/settings      #主要修改以下配置

server: 192.168.1.17              #配置cobbler server ip地址

next_server: 192.168.1.17         #配置cobbler server ip地址

manage_rsync: 1                   #同意cobbler 管理rsync

manage_dhcp: 1                    #同意cobbler 管理dhcp

pxe_just_once: 1                  #预防将机器中的安装循环配置为始终从网络引导

生成密码串

[[email protected] ~]# openssl passwd -1 -salt "cobber" "123abc"    #生成cobbler安装系统root的初始密码
$1$cobber$/quWjJZYZSFe/Zrk2FBVP1

[[email protected] ~]# vi /etc/cobbler/settings +101

default_password_crypted: "$1$cobber$/quWjJZYZSFe/Zrk2FBVP1"  # ""内为刚刚生成的密码

[[email protected] ~]# vi /etc/cobbler/dhcp.template             #配置cobbler dhcp模板,只需修改这一个{ }内的,其他默认就行.

subnet 192.168.1.0 netmask 255.255.255.0 {

option routers             192.168.1.1;                   #配置路由

option domain-name-servers 8.8.8.8;                       #配置DNS

option subnet-mask         255.255.255.0;

range dynamic-bootp        192.168.1.100 192.168.1.254;   #配置可分配ip地址池

default-lease-time         21600;

max-lease-time             43200;

next-server                $next_server;

filename "pxelinux.0";

}

[[email protected] ~]# vi /etc/xinetd.d/rsync     #开启rsync

disable = no

[[email protected] ~]# vi /etc/xinetd.d/tftp      #开启tftp

disable = no

[[email protected] ~]# vi /etc/dhcp/dhcpd.conf    #配置dhcp

subnet 192.168.1.0 netmask 255.255.255.0 {

option routers             192.168.1.1;

option domain-name-servers 8.8.8.8;

option subnet-mask         255.255.255.0;

range dynamic-bootp        192.168.1.100 192.168.1.254;

default-lease-time         21600;

max-lease-time             43200;

next-server                192.168.1.17;

filename                   "pxelinux.0";

}

[[email protected] ~]# /etc/init.d/xinetd start

[[email protected] ~]# /etc/init.d/cobblerd start

[[email protected] ~]# /etc/init.d/dhcpd start

[[email protected] ~]# vi /etc/debmirror.conf      #注释以下两行

#@dists="sid";

#@arches="i386";

[[email protected] ~]# cobbler get-loaders         #安装cobbler相关包

task started: 2015-01-10_214302_get_loaders 
task started (id=Download Bootloader Content, time=Sat Jan 10 21:43:02 2015) 
downloading http://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README 
downloading http://www.cobblerd.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo 
downloading http://www.cobblerd.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot 
downloading http://www.cobblerd.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux 
downloading http://www.cobblerd.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi 
downloading http://www.cobblerd.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot 
downloading http://www.cobblerd.org/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 
downloading http://www.cobblerd.org/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 
downloading http://www.cobblerd.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi 
downloading http://www.cobblerd.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi 
*** TASK COMPLETE ***

[[email protected] ~]# cobbler check       #再次检查cobbler配置
No configuration problems found. All systems go. 
[[email protected] ~]# cobbler sync         #使cobbler配置生效
task started: 2015-01-10_214521_sync 
task started (id=Sync, time=Sat Jan 10 21:45:21 2015) 
running pre-sync triggers 
cleaning trees 
mkdir: /var/lib/tftpboot/pxelinux.cfg 
mkdir: /var/lib/tftpboot/grub 
mkdir: /var/lib/tftpboot/s390x 
mkdir: /var/lib/tftpboot/ppc 
mkdir: /var/lib/tftpboot/etc 
removing: /var/lib/tftpboot/grub/images 
copying bootloaders 
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot 
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi 
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.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 
rendering Rsync files 
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 ***

[[email protected] ~]# chkconfig httpd on 
[[email protected] ~]# chkconfig dhcpd on 
[[email protected] ~]# chkconfig xinetd on 
[[email protected] ~]# chkconfig cobblerd on

[[email protected] ~]# mount /dev/cdrom /media/cdrom/   #挂载光盘镜像

[[email protected] ~]# ls /media/cdrom/                 #确定挂载成功
CentOS_BuildTag EULA images Packages repodata RPM-GPG-KEY-CentOS-Debug-6 RPM-GPG-KEY-CentOS-Testing-6 
EFI GPL isolinux RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Security-6 TRANS.TBL

[[email protected] ~]# cobbler import --path=/media/cdrom/ --name=centos6.6x86_64      #导入安装安装文件

task started: 2015-01-10_214758_import

task started (id=Media import, time=Sat Jan 10 21:47:58 2015)

Found a candidate signature: breed=redhat, version=rhel6

Found a matching signature: breed=redhat, version=rhel6

Adding distros from path /var/www/cobbler/ks_mirror/centos6.6x86_64:

creating new distro: centos6.6x86_64-x86_64

trying symlink: /var/www/cobbler/ks_mirror/centos6.6x86_64 -> /var/www/cobbler/links/centos6.6x86_64-x86_64

creating new profile: centos6.6x86_64-x86_64

associating repos

checking for rsync repo(s)

checking for rhn repo(s)

checking for yum repo(s)

starting descent into /var/www/cobbler/ks_mirror/centos6.6x86_64 for centos6.6x86_64-x86_64

processing repo at : /var/www/cobbler/ks_mirror/centos6.6x86_64

need to process repo/comps: /var/www/cobbler/ks_mirror/centos6.6x86_64

looking for /var/www/cobbler/ks_mirror/centos6.6x86_64/repodata/*comps*.xml

Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos6.6x86_64/repodata

*** TASK COMPLETE ***                     #表示cobbler sync成功

[[email protected] ~]# cobbler list          #列出导入后的配置,详细信息可用cobbler report
distros: 
centos6.6x86_64-x86_64

profiles: 
centos6.6x86_64-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

[[email protected] ~]# cobbler profile find --distro=centos6.6x86_64-x86_64  #查看配置是否存在
centos6.6x86_64-x86_64

[[email protected] ~]#cd /var/lib/cobbler/kickstarts

[[email protected] kickstarts]# cp sample.ks centos6.6x86_64-x86_64.cfg      #定义ks文件ks可根据需求自行配置

[[email protected] kickstarts]# cobbler profile edit --name=centos6.6x86_64-x86_64                                       --kickstart=/var/lib/cobbler/kickstarts/centos6.6x86_64-x86_64.cfg                                                                                  [[email protected] kickstarts]# cobbler distro list        #查看系统列表

centos6.6x86_64-x86_64

[[email protected] kickstarts]# cobbler check              #再次检查cobbler配置
No configuration problems found. All systems go. 
[[email protected] kickstarts]# cobbler sync               #同步cobbler配置
task started: 2015-01-10_221010_sync 
task started (id=Sync, time=Sat Jan 10 22:10:10 2015) 
running pre-sync triggers 
cleaning trees 
removing: /var/www/cobbler/images/centos6.6x86_64-x86_64 
removing: /var/lib/tftpboot/pxelinux.cfg/default 
removing: /var/lib/tftpboot/grub/grub-x86.efi 
removing: /var/lib/tftpboot/grub/images 
removing: /var/lib/tftpboot/grub/efidefault 
removing: /var/lib/tftpboot/grub/grub-x86_64.efi 
removing: /var/lib/tftpboot/images/centos6.6x86_64-x86_64 
removing: /var/lib/tftpboot/s390x/profile_list 
copying bootloaders 
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi 
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi 
copying distros to tftpboot 
copying files for distro: centos6.6x86_64-x86_64 
trying hardlink /var/www/cobbler/ks_mirror/centos6.6x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos6.6x86_64-x86_64/vmlinuz 
trying hardlink /var/www/cobbler/ks_mirror/centos6.6x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos6.6x86_64-x86_64/initrd.img 
copying images 
generating PXE configuration files 
generating PXE menu structure 
copying files for distro: centos6.6x86_64-x86_64 
trying hardlink /var/www/cobbler/ks_mirror/centos6.6x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos6.6x86_64-x86_64/vmlinuz 
trying hardlink /var/www/cobbler/ks_mirror/centos6.6x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos6.6x86_64-x86_64/initrd.img 
Writing template files for centos6.6x86_64-x86_64 
rendering DHCP files 
generating /etc/dhcp/dhcpd.conf 
rendering TFTPD files 
generating /etc/xinetd.d/tftp 
processing boot_files for distro: centos6.6x86_64-x86_64 
cleaning link caches 
rendering Rsync files 
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 ***         #发现没有问题接下来就可以测试cobber安装os了。

配置完成现在可以装机了,因为是虚拟机测试,当然先新建虚拟机,注意客户端要和cobbler server 都是桥接,os启动默认是以pxe启动的。

然后点击开启虚拟机

选择centos6.6我们就可以开始装机了,搞定。

当然我们也可以通过web的方式哦

[[email protected] ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler   #添加cobbler用户
Changing password for user cobbler in realm Cobbler 
New password: 
Re-type new password:

我们可以通过 https://192.168.1.17/cobbler_web/来访问了

用户名:cobbler

密码:cobbler (这个是我自己设置的哦)

图形界面import

[[email protected] opt]# mkdir /iso          #创建挂载目录

[[email protected] opt]# ls                  #上传一个新的iso镜像文件
CentOS-6.2-x86_64-minimal.iso 
[[email protected] opt]# mount CentOS-6.2-x86_64-minimal.iso /iso/ -o loop          #挂载镜像 
[[email protected] opt]# ls /iso/ 
CentOS_BuildTag EULA images Packages repodata RPM-GPG-KEY-CentOS-Debug-6 RPM-GPG-KEY-CentOS-Testing-6 
EFI GPL isolinux RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-6

导入cobbler

点击run就行了。

最后大概说下cobbler

Cobbler由python语言开发,是对PXE和 Kickstart以及DHCP的封装。

融合很多特性,提供了CLI和Web的管理形式。更加方便的实行网络安装。

同时,Cobbler也提供了API接口,使用其它语言也很容易做扩展。

它不仅可以安装物理机,同时也支持kvm、xen虚拟化、Guest OS的安装。

更多的是它还能结合Puppet等集中化管理软件,实现自动化的管理。

PXE 预启动执行环境(Preboot eXecution Environment,PXE,也被称为预执行环境)是让计算机通过网卡独立地使用数据设备(如硬盘)或者安装操作系统。

Cobbler提供以下服务集成:

* PXE服务支持

* DHCP服务管理

* DNS服务管理

* 电源管理

* Kickstart服务支持

* yum仓库管理

以下是cobbler命令及配置文件的一些说明

1.cobbler命令说明

cobbler check:检查cobbler配置

cobbler list:列出所有的cobbler元素

cobbler report:列出元素的详细信息

cobbler distro:查看导入的发行版系统信息

cobbler system:查看添加的系统信息

cobbler profile:查看配置信息

cobbler sync:同步cobbler配置

cobbler reposync:同步yum仓库

2.cobbler配置文件说明:

/etc/cobbler/seetings cobbler的主配置文件

/etc/cobbler/users.digest 用于web访问的用户名密码配置文件

/etc/cobbler/modules.conf 模块配置文件

/etc/cobbler/users.conf cobbler webui/web服务授权配置文件

/etc/cobbler/iso/ buildiso模板配置文件

/etc/cobbler/power 电源配置文件

/etc/cobbler/pxe pxeprofile配置模板

/etc/cobbler 此目录包含rsync,dhcp,dns,pxe,等服务的模板配置文件

3.系统镜像数据目录/var/www/cobbler

导入的系统发行版,repos镜像和kickstart文件都放置在/var/www/cobbler目录下

/var/www/cobbler/images存储所有导入发行版的kernel和initrd镜像用于远程网络启动

/var/www/cobbler/ks_mirror存储导入的发行版系统数据

/var/www/cobbler/repo_mirror 仓库存储目录

/var/log/cobbler cobbler日志文件

4.cobbler数据目录/var/lib/cobbler

/var/lib/cobbler/config/存放distros,repos,systems,和profile等信息配置文件,一般是json文件

/var/lib/cobbler/snippets存放ks文件可以导入的脚本小片段

/var/lib/cobbler/triggers存放用户定义的cobbler命令

/var/lib/cobbler/kickstarts/存放kictstart配置文件

时间: 2024-11-02 09:06:19

网络安装操作系统之——-cobbler批量安装操作系统的相关文章

cobbler批量安装linux(centos6.5)

1.安装 cobbler (1).安装第三方软件库所需要的包 #cd /tmp #wget  http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm #rpm -ivh epel-release-6-8.noarch.rpm (2).安装 dhcp #yum -y install dhcp (3). 安装其他的相关软件 #yum -y install tftp rsync xinetd httpd (

使用Cobbler批量安装操作系统

个人博客地址:http://www.pojun.tech/ 欢迎访问 前言 在实际生产中,我们常常会遇到这样一种情况,就是我们需要同时安装几十甚至上百台服务器,如果我们使用U盘或者光盘的方式的话,或许老板直接就将我们辞退了.这里我们介绍一种能够实现自动化安装操作系统的方式. 我们搭建Cobbler的实验环境是基于CentOS 7.3 -1611 的基础的. 同时这个实验可以帮助你一步步的完成所有的操作,不过,如果你想自定义安装的内容的话,建议你先看本文 自定义kickstart文件 部分,以便有

Cobbler批量安装操作系统

Cobbler介绍 Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像. 一.安装和修改cobbler配置 1. Cobbler不在CentOS的基本源中,需要导入EPEL源升级软件包, # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/

使用cobbler批量安装操作系统(基于Centos7.x )

1.1 cobbler简介 Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等. Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用. Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理. Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集

cobbler批量安装系统使用详解-技术流ken

1.前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 2.系统环境准备及其下载cobbler 一.系统环境 系统版本:CentOS release 6.7 (Final) 内网IP:192.168.232.7/24    #用来对内通信,提供cobbler服务 外网IP:10.220.5.166/24      #连接外网 二. 关闭安全服务 [[email protected] ~

自动化运维(一):Cobbler批量部署操作系统

作者:独笔孤行@TaoCloud 前言 Cobbler是自动化运维的必备工具,可通过网络启动(PXE)方式实现操作系统快速批量安装.Cobbler快速安装操作系统基于kickstart实现,但Cobbler功能更完善,管理更加简便.高效.Cobbler通过将安装系统所涉及的服务(tftp.dhcp.kickstart)集中管理,提供全自动化批量快速安装系统的网络环境,以实现大规模机房设备的统一管理. 一.简介 Cobbler支持CLI与WEB两种管理方式.要求所有被安装系统的服务器与Cobble

cobbler批量安装服务器

1,安装epel 手动安装(https://fedoraproject.org/wiki/EPEL) wget http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm rpm -Uvh /root/Desktop/epel-release-7-9.noarch.rpm 2,安装cobbler以及相关包 yum -y install cobbler httpd xinetd tftp-ser

基于centos7系统部署cobbler批量安装系统

1.cobbler cobbler是一个可以实现批量安装系统的linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. cobbler部署安装: 1. 下载相关软件 2. 配置dhcp 3. 配置tftp 4. 启动httpd 5. 启动cobbler 6. cobbler自检 7. 根据提示进行修改 8. cobbler重启及同步 9. 挂载光盘 10. 生成distro 11. 创建kickstart文件 12. 创建profile

自动化工具cobbler批量安装Centos6.0系统

一.安装与配置cobbler: 1.导入epel源:由于互联网上的6.5版本已经没有办法下载了,我用的最新版本:epel-release-6-8.noarch.rpm        # rpm -ivh epel-release-6-8.noarch.rpm        # yum update        # yum upgrade 2.安装cobbler:        # yum install cobbler 3.修改配置:       # vi /etc/cobbler/setti