cobbler自动化安装操作系统

Cobbler安装与部署

目录

Cobbler安装与部署... 1

理论部分:Cobbler简介... 1

Collber 对象关系图... 1

工作流程... 2

部署安装cobbler4

一、系统环境... 4

二、部署阶段... 5

三、配置部分... 5

四、后续部署... 13

理论部分:Cobbler简介

Cobbler由python语言开发,是对PXE和Kickstart以及DHCP的封装。融合很多特性,提供了CLI和Web的管理形式。更加方便的实行网络安装。适用场景:需要大批量的部署操作系统。

Collber 对象关系图

Distros(发行版):表示一个操作系统。它承载了内核和 initrd 的信息,以及内核参数等其他数据。

profile:定义Kickstart文件

repos:安装源

system:表示要配给的机器。它包含一个配置文件或一个镜像,还包含 IP 和 MAC 地址、电源管理(地址、凭据、类型)以及更为专业的数据等信息。

image:可替换一个包含不属于此类别的文件的发行版对象(例如,无法分为内核和 initrd 的对象)。

集成的服务

PXE 服务

DHCP服务管理

DNS服务管理

HTTP服务管理

TFTP服务管理

Kickstart服务

yum仓库管理

电源管理

工作流程

(1).需要安装系统的客户端主机的网卡支持网络安装,也就是支持以PXE模式启动。

(2).客户端主机需要有一个IP地址来与Cobbler Server进行通信,这时网络中必须要有一个主机能自动分配IP。DHCP就是一个能为客户端主机自动分配IP地址的服务,DHCP就是安装在CobblerServer主机上。

(3).客户端得到IP地址后,需要提供一个引导程序pxelinux.0(类似于grub) 此文件由syslinux程序提供,所以需要安装syslinux并且能加载内核及内核镜像文件(vmlinuz与initrd.img),客户端可以通过TFTP协议到TFTP Server上下载内核及内核镜像文件(vmlinuz与initrd.img),所以需要一个TFTP 服务,TFTP也是安装在Cobbler Server主机上,客户端只是知道可以用TFTP协议下载文件,但是TFTP Server的IP是那个,这个还得需要DHCP服务器指名告诉客户端那个是TFTP Server(注,所以我们在配置DHCP模板时指定next-server,同时指定了filename,这里的filename就是指定的pxelinux.0引导程序),而TFTP服务需要超级进程进行管理,此进程是xinetd,因此需要在Cobbler Server上安装xinet服务。

(4).然后通过distro找到安装的发行版,通过设置的profile找到kickstart文件,完成自动安装。

部署安装cobbler

一、系统环境

1、系统版本(最小化安装)

cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

uname  -r

3.10.0-327.el7.x86_64

cat /etc/hosts

127.0.0.1   localhostlocalhost.localdomain localhost4 localhost4.localdomain4

::1         localhostlocalhost.localdomain localhost6 localhost6.localdomain6

192.168.56.11 linux.node1.expmale.com

2、防火墙等

systemctl  stop firewalld.service

systemctl  disable firewalld.service

2、关闭selinux

3、IP地址:inet 192.168.56.11

二、部署阶段

1、配置epel源

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

yum clean all

yum makecache

2、安装所需软件包

yum -y install httpd  dhcp tftp cobbler xinetd

3、启动 httpd cobbler

systemctl  start httpd

systemctl start cobblerd.service

三、配置部分

/etc/cobbler/settings cobbler主配置文件

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

/etc/cobbler/pxe pxe模板文件

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

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

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

/etc/cobbler/dhcp.template DHCP服务的配置模板

/etc/cobbler/dnsmasq.template DNS服务的配置模板

/etc/cobbler/tftpd.template tftp服务的配置模板

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

(命令部分全部加粗,特别注意的地方标红字)

1、检查是否满足启动cobbler条件

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 somethingother than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IPfor the boot server as reachable by all machines that will use it.

(请修改server标签的IP地址,配置文件是/etc/cobbler/settings,在384行,注意不要删除空格。)

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 shouldmatch the IP of the boot server on the PXE network.

(请修改next_server标签的IP地址为本机网卡地址,不可以使用127.0.0.1,配置文件是/etc/cobbler/settings,在272行)

3 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp

(请开启tftp服务,更改/etc/xinetd.d/tftp disable改为 enable在14行,启动xinetd服务

systemctl start xinetd.service

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 tohandle x86/x86_64 netbooting, you may ensure that you have installed a *recent*version of the syslinux package installed and can ignore this messageentirely.  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 theeasiest way to resolve these requirements.

(请下载这个组件,使用cobbler get-loaders下载)

5 : enable and start rsyncd.service with systemctl

(将rsync服务启动并添加为开机自动启动)

systemctl  start rsyncd.service

systemctl  enable rsyncd.service

6 : debmirror package is not installed, it will be required to managedebian deployments and repositories

(在debian系列的操作系统上部署,请安装这个包debmirror)

7 : ksvalidator was not found, install pykickstart

(没有找到这个软件包pykickstart,请安装)

8 : The default password used by the sample templates for newly installedmachines (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

(random-phrase-here这一段改为密码加密前段,your-password-here这里输入你的密码)

openssl passwd -1 -salt‘password‘ ‘123456‘

$1$password$7ZK8mMeLGXxbNPeJEFJOU0

将此字符串放到/etc/cobbler/settings配置文件中的default_password_cypted配置项中,删除之前的字符串在101行

default_password_crypted: "$1$password$7ZK8mMeLGXxbNPeJEFJOU0"

(请修改安装的操作系统密码,这个123456密码为安装之后的root密码)

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

(这个fencing功能,很少用,不用处理)

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

systemctl restart cobblerd

(重新启动cobblerd并且运行 cobbler sync同步配置。)

把以上问题处理

重新启动cobbler并重新检查一下

cobbler check

检查结果不能多于两个,上面提到的可不需要处理的直接跳过即可。

之后进行同步

cobbler sync

2、配置开启dhcp

Cobbler自身带了管理dhcp的功能,所以不需要修改/etc/dhcp/dhcpd.conf文件,只需要修改/etc/cobbler/settings文件,将以下配置由0改为1即可。

vi /etc/cobbler/settings

242: manage_dhcp: 1

3、配置dhcp分配的地址

vi /etc/cobbler/dhcp.template

修改过的

subnet 192.168.56.0 netmask 255.255.255.0 {分配的地址段(固定格式)

option routers             192.168.56.2;网关地址

option domain-name-servers192.168.56.2;#dns服务器逗号分隔,可以写多个

option subnet-mask         255.255.255.0;#子网掩码

range dynamic-bootp        192.168.56.100 192.168.56.254;#分配的地址池

default-lease-time         21600;

max-lease-time             43200;

next-server                $next_server;#这里掉用的就是配置文件中的变量,不要修改

4、重启cobbler服务

systemctl  restart cobblerd.service

5、同步配置

cobbler sync

netstat  -lunpt

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0     0 0.0.0.0:873            0.0.0.0:*               LISTEN      3580/rsync         

tcp       0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      2788/mysqld

tcp       0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1300/sshd

tcp       0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2433/master

tcp        0     0 127.0.0.1:25151        0.0.0.0:*               LISTEN      3986/python2       

tcp6      0      0 :::873                  :::*                    LISTEN      3580/rsync

tcp6       0     0 :::80                  :::*                    LISTEN      3948/httpd         

tcp6      0      0 :::22                   :::*                    LISTEN      1300/sshd

tcp6      0      0 ::1:25                  :::*                    LISTEN      2433/master

udp        0     0 0.0.0.0:69             0.0.0.0:*                          4352/xinetd

上传需要安装的镜像,这里以centos7.2为例

6、挂载镜像(上传到本地的iso)

mount-o loop /opt/CentOS-7-x86_64-DVD-1511.iso /mnt/

7、导入镜像

cobbler import --path=/mnt--name=Centos7.2-x86-64 arch=x86_64

cobbler import 导入镜像命令

--path=镜像挂载的目录

--name=镜像的名字,可以随便起

arch 系统的架构版本

再导入的同时,后台会开启rsync进程

导入的路径,在下图中均有体现,

8、检查导入

cobbler list

准备应答文件

cd /var/lib/cobbler/kickstarts #默认的应答文件存放路径

9、上传或者自己生成文件(制作过程略)

rz

或者安装一个已准备批量部署的系统,安装图形化以及kickstart图形化工具进行应答文件生成。上传到/var/lib/cobbler/kickstarts目录下执行一下两条命令

cobbler profile list

Centos7.2-64-x86_64

10、查看系统默认配置

cobblersetting report

11、编辑profile镜像,在安装的时候,去哪里找应答文件以及指定他的name

cobblerprofile edit --name=Centos7.2-64-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64_cobbler.cfg

修改内核参数,使其网卡变成默认的eth0的格式(可忽略,如不想改)

cobblerprofile edit --name=Centos7.2-64-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘

cobbler profile report

如果有多个系统,请重复执行6-11步

12、重新同步配置

cobbler sync

到了这一步,就可以新推机器了,将服务器设置为网卡启动,保证网络内只有一台dhcp服务器。

出现这一步,基本上就完成了,因为,如果一旦重启,一旦走网卡启动,则有可能会格式化,所以这里设计了等待原则时间,不动则就会从本地重启。

自定义界面

就是这个等待界面的自定义信息,没有什么用,生产环境下,我=我们都不用显示器 。

vi/etc/cobbler/pxe/pxedefault.template 

四、后续部署

Cobbler提供了web界面进行管理配置,非常简单。安装以下组件,即可。

1、 安装cobbler_web组件

yum install cobbler-web

systemctl  restart httpd

默认web界面的用户名和密码控制文件在/etc/cobbler/user*

用户文件有点类似于svn的权限管理,默认不需要改变

grep "^[a-Z]"/etc/cobbler/users.conf

admin = ""

cobbler = ""

2、设置用户密码

grep "^[a-Z]" /etc/cobbler/users.digest

cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3

以上信息是默认信息,不知道密码是多少,我们可以重新生成

htdigest/etc/cobbler/users.digest "Cobbler" cobbler

grep "^[a-Z]"/etc/cobbler/users.digest

cobbler:Cobbler:4af20912b96aba2b59fca3b8aa8aad74

打开界面https://192.168.56.11/cobbler_web

3、重新安装客户端系统

如果有需求进行重新安装操作系统,则直接在客户端装好软件,无需到机房即可安装。

在客户端安装工具koan(就是上一步安装的机器)

yum -y install koan

指定server地址

koan --server=192.168.56.11--list=profiles

指定镜像名以及操作的指令

koan --replace-self--server=192.168.56.11 --profile=Centos7.2-64-x86_64

执行完以上命令之后,会在/boot/grup2/grup.cfg中添加了一个启动项,如下图

之后进行重启

reboot

出现了这个启动项就表明,接下来会自动重新安装系统,完全自动化。

4、构建仓库

导入epel仓库

cobbler repo add --name=CentOS-7-x86_64-epel --mirror=https://mirrors.aliyun.com/epel/7Server/x86_64/ --arch=x86_64 --breed=yum

打开web界面,开始同步

构建openstack仓库

cobbler repo add --name=openstack-newton --mirror=https://mirrors.aliyun.com/centos/7.3.1611/cloud/x86_64/openstack-newton/ --arch=x86_64 --breed=yum

增加计划任务,每天进行增量同步

crontab–e

#每天一点一分进行同步,检查机制,这样可以增量同步

1 1 * * * cobbler reposync --tries=3 --no-fail

基于MAC地址继进行定制安装

如果,需求每一个mac地址绑定一个固定的IP地址,hostname提前定义好。

检查profile文件,从那个profile文件安装

cobbler profile list

Centos7.2-64-x86_64

cobblersystem add --name=linux-node3 --mac=00:50:56:35:75:16--profile=Centos7.2-64-x86_64 --ip-address=192.168.56.110--subnet=255.255.255.0 --static=1 --hostname=linux-node3.example.com--name-servers="192.168.56.2" --interface=eth0--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64_cobbler.cfg

之后启动那个mac地址是00:50:56:35:75:16这个的服务器即可开机进行安装,整个过程不会出现选项。

Cobbler学习地址(手册)

http://www.ibm.com/developerworks/cn/linux/l-cobbler/index.html

官网地址:http://cobbler.github.io/manuals/2.8.0/

到此为止,cobbler就配置完成了,后面还有很多功能,请自行测试。Web界面,请自行测试,比较简单。

时间: 2024-08-24 08:24:27

cobbler自动化安装操作系统的相关文章

Cobbler:自动化安装成千上万台服务器实战!!!

项目背景: 在我们的公司刚买了一大批服务器,这个时候需要你全部安装成linux环境的系统,这个时候你是肯定不愿意一台一台服务器的进行安装.这个时候Cobbler华丽上场. 实验环境: vmware workstation 11 centos6.5的系统下 Cobbler服务器:ip:192.168.0.32   防火墙关闭  setenforce 0 SecureCRT (ssh远程连接软件) 软件介绍: Cobbler 是一个免费开源系统安装部署软件,用于自动化网络安装操作系统;基于Pytho

网络安装操作系统之——-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 Disable

LINUX自动化安装操作系统

自动化就是无人职守安装大量操作系统,只要客户机开机,就能自动安装操作系统. 首先调试环境: 基于DHCP.TFTP.HTTP来完成PXE自动的实现 1.  安装服务 [[email protected]/]# yum install dhcp---------dhcp服务 [[email protected]/]# yum install tftp tftp-server-----tftp服务 [[email protected]/]# yum install http--------http服

cobbler自动化安装centos6.2

cobbler自动化安装 官网地址: http://www.cobblerd.org 1.安装epel源 #rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #vim /etc/yum.repos.d/epel.repo 2.安装cobbler组件 #yum -y install cobbler dhcp tftp xinetd httpd syslinux 3.准备ISO直接挂载

Cobbler实现自动化安装操作系统

一.cobbler简介 cobbler是实现自动化安装操作系统的工具.它解决了PXE安装时的弊端(只能实现单一操作系统的安装).实际上,cobbler是对PXE二次封装可实现多版本,多环境操作系统安装的高级抽象工具. 工作原理大致如下: 实际上,cobbler是对PXE的二次封装.cobbler可以自动的实现PXE配置中的某些手动过程.PXE的工作原理大致如下: 关于PXE具体配置,可参考http://guoting.blog.51cto.com/8886857/1533029 二.cobble

CentOS 6.5自动化运维之基于cobbler服务的自动化安装操作系统详解

一.Cobbler安装 前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可进行类似下面的安装过程. # yum install -y epel-release # yum install -y cobbler cobbler-web pykickstart debmirror # service httpd start # service cobblerd start # ss -tuanlp | grep :25151 tcp LISTEN 0 5 127.0.0

使用Cobbler批量安装操作系统

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

Cobbler自动化安装系统

现在都知道运维自动化的重要性,尤其是对于在服务器数量按几百台.几千台增加的公司而言,单单是装系统,如果不通过自动化来完成,根本是不可想象的. 运维自动化安装方面,早期一般使用人工配置pxe+dhcp+tftp配合kickstart,现在开源工具就多了,如cobbler,OpenQRM和Spacewalk等,下面我们就来了解其中的一个开源工具cobbler. Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用python开发,小巧轻便(才1

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/