Server端:

  1. 第一步,启动Cobbler服务
  2. 第二步,进行Cobbler错误检查,执行cobbler check命令
  3. 第三步,进行配置同步,执行cobbler sync命令
  4. 第四步,复制相关启动文件文件到TFTP目录中
  5. 第五步,启动DHCP服务,提供地址分配
  6. 第六步,DHCP服务分配IP地址
  7. 第七步,TFTP传输启动文件
  8. 第八步,Server端接收安装信息
  9. 第九步,Server端发送ISO镜像与Kickstart文件

Client端:

  1. 第一步,客户端以PXE模式启动
  2. 第二步,客户端获取IP地址
  3. 第三步,通过TFTP服务器获取启动文件
  4. 第四步,进入Cobbler安装选择界面
  5. 第五步,客户端确定加载信息
  6. 第六步,根据配置信息准备安装系统
  7. 第七步,加载Kickstart文件
  8. 第八步,传输系统安装的其它文件
  9. 第九步,进行安装系统

自动化运维之cobbler安装centos7.3

一、cobbler简介和服务

Cobbler是一款自动化操作系统安装的实现,与PXE安装系统的区别就是可以同时部署多个版本的系统,而PXE只能选择一种系统。而如今的架构动辄就是上千台的服务器。而存在一些操作系统不统一的现象,例如最初的架构采用的是CentOS5系列的系统,而新出现了一些技术后,需要新的操作系统的支持,一方面是需要批量部署装机,而另一方面还需要考虑到如果老版本的服务器出现故障后还需要重新去部署。并且提供Web配置页面,可以只需要一些点击就可以完成一些操作。

二、cobbler实战

安装cobbler 等依赖服务

# yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd -y
启动httpd 和cobbler服务

# /etc/init.d/httpd restart
# /etc/init.d/cobblerd start
使用 cobbler check (5、6、8三步并不需要执行)检查,检查后使用cobbler sync同步操作
# cobbler check

如果执行# cobbler check 报错,执行 # /etc/init.d/cobblerd restart 重启即可

Traceback (most recent call last):
File "/usr/bin/cobbler", line 36, in <module>
sys.exit(app.main())
File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 657, in main
rc = cli.run(sys.argv)
File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 270, in run
self.token = self.remote.login("", self.shared_secret)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/usr/lib64/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1392, in _parse_response
return u.close()
File "/usr/lib64/python2.6/xmlrpclib.py", line 838, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<class 'cobbler.cexceptions.CX'>:'login failed'">
[root@mini1 html]# /etc/init.d/cobblerd restart 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 : file /etc/xinetd.d/rsync does not exist
5 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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
8 : 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
server: 192.168.3.12
next_server: 192.168.3.12 #指定tftp所在的服务器
manage_dhcp: 1 #使用cobbler管理dhcp

使用openssl对密码加密(前面的cadmin是加盐随机值,后面的admin是密码)

# openssl passwd -1 -salt 'admin' 'admin'
$1$admin$1kgWpnZpUx.vTroWPXPIB0

修改password
vim /etc/cobbler/settings

default_password_crypted: "$1$admin$1kgWpnZpUx.vTroWPXPIB0"
保存文件再次使用# cobbler check重新检查

部署第三步:

# cobbler get-loaders

部署第四步:把disable选项改为no,并重新启动xinetd

# vim /etc/xinetd.d/rsync
service rsync
{
disable = no # 将disable 改为 no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}

# /etc/init.d/xinetd restart

重启cobbler,并重新cobbler check
修改/etc/cobbler/dhcp.template 文件,该文件通过cobbler sync可以管理/etc/dhcp/dhcpd.conf文件,所以在此不需要更改/etc/dhcp/dhcpd.conf文件,因为改了也没用,每次cobbler sync就会按照预定义重新初始化dhcp配置文件

# vim /etc/cobbler/dhcp.template
subnet 192.168.3.0 netmask 255.255.255.0 {
option routers 192.168.3.1;
option domain-name-servers 192.168.1.13;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.3.100 192.168.3.200;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;

执行# cobbler sync

使用vmvare虚拟机的iso镜像挂载到/mnt 路径(如下图),并导入镜像

cobbler –name:倒进后的名字 –arch:镜像架构 –path:挂载路径

# mount /dev/cdrom /mnt
# cobbler import --path=/mnt/ --name=CentOS-7.3-x86_64 --arch=x86_64
task started: 2017-04-20_174857_import
task started (id=Media import, time=Thu Apr 20 17:48:57 2017)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7.3-x86_64:
creating new distro: CentOS-7.3-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.3-x86_64 -> /var/www/cobbler/links/CentOS-7.3-x86_64
creating new profile: CentOS-7.3-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/CentOS-7.3-x86_64 for CentOS-7.3-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.3-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.3-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/repodata
*** TASK COMPLETE ***

导入后镜像所在位置:/var/www/cobbler/ks_mirror/

# ls /var/www/cobbler/ks_mirror/
CentOS-7.3-x86_64 config

给kickstart定义ks文件目录/var/lib/cobbler/kickstarts/为cobbler默认存放kickstart配置文件的位置

# cd /var/lib/cobbler/kickstarts/

vim /var/lib/cobbler/kickstarts/centos7.3_x86_64.cfg

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use network installation
url --url="http://192.168.3.12/cobbler/ks_mirror/CentOS-7.3-x86_64/"
# Use text mode install
text
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Firewall configuration
firewall --disabled
selinux --disabled
# Reboot after installation
reboot # Network information
network --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto
network --hostname=localhost.localdomain # Root password
rootpw --iscrypted $6$23hVX55axEtxScyM$jowXwPr8f2xqipe0Xnaj8XHtwNBlufsvCqqDQDrokM1M0kzxwzPlvzHJmJzusubb6zAU/hKpW5oIDCpa.n7zs0
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
firstboot --disable
# Disk partitioning information
part pv.194 --fstype="lvmpv" --ondisk=sda --size=75779
part /boot --fstype="xfs" --ondisk=sda --size=300
volgroup centos --pesize=4096 pv.194
logvol /data --fstype="xfs" --size=40956 --name=data --vgname=centos
logvol swap --fstype="swap" --size=4096 --name=swap --vgname=centos
logvol / --fstype="xfs" --size=30720 --name=root --vgname=centos %packages
@^minimal
@core
kexec-tools %end # cobbler profile report
Name : CentOS-7.3-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.3-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 # cobbler list
distros:
CentOS-7.3-x86_64 profiles:
CentOS-7.3-x86_64 systems: repos: images: mgmtclasses: packages: files:

使用cobbler profile指定ks文件位置和内核参数(net.ifnames=0和biosdevname=0代表更改网卡为eth0 --> 运维标准化)

# cobbler profile edit --name=CentOS-7.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.3_x86_64.cfg
# cobbler profile edit --name=CentOS-7.3-x86_64 --kopts='net.ifnames=0 biosdevname=0'

根据机器的MAC地址(新建虚拟机的时候直接生成,如果是购买的物理机就可以向供应商获取),自动绑定IP,网关,dns等

cobbler system add --name=chinasoft --mac=00:50:56:3B:DC:7E --profile=CentOS-7.3-x86_64 --ip-address=192.168.3.177 --subnet=255.255.255.0 --gateway=192.168.3.1 --interface=eth0 --static=1 --hostname=node3.chinasoft.com --name-servers="114.114.114.114"

使用sync同步配置
# cobbler sync

# cobbler system list
chinasoft

注意:客户端机器装系统时,要先使用修改bios启动然后修改为网卡启动,把network boot from Intel E1000调整为最上,F10保存

重启机器就开始自动安装操作系统了,安装完成以后进系统发现ifconfig eth0、hostname、防火墙、selinux、都和我们预定义的一致


修改cobbler提示

# vim /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE by jack | http://www.cnclogs.com/reblue520
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end

三、web界面管理cobbler

在最开始yum的时候安装了cobbler-web,当然也就可以使用web界面管理cobbler
新版cobbler的web界面使用的是https,登录https://192.168.3.12/cobbler_web

(默认情况下username和password都是cobbler,可以通过用户名所在文件: /etc/cobbler/users.conf 和 密码所在文件:/etc/cobbler/users.digest进行管理 管理)


待安装完后,关闭机器,否则会反复安装,因此也要注意生产环境,尽量不要从网卡启动,防止机器意外重装

学习Cobbler(二)的更多相关文章

  1. crawler4j 学习(二)

    crawler4j 学习(二) 实现控制器类以制定抓取的种子(seed).中间数据存储的文件夹.并发线程的数目: public class Controller { public static voi ...

  2. 从零开始学习jQuery (二) 万能的选择器

    本系列文章导航 从零开始学习jQuery (二) 万能的选择器 一.摘要 本章讲解jQuery最重要的选择器部分的知识. 有了jQuery的选择器我们几乎可以获取页面上任意的一个或一组对象, 可以明显 ...

  3. Android Animation学习(二) ApiDemos解析:基本Animators使用

    Android Animation学习(二) ApiDemos解析:基本Animatiors使用 Animator类提供了创建动画的基本结构,但是一般使用的是它的子类: ValueAnimator.O ...

  4. AspectJ基础学习之二搭建环境(转载)

    AspectJ基础学习之二搭建环境(转载) 一.下载Aspectj以及AJDT 上一章已经列出了他的官方网站,自己上去download吧.AJDT是一个eclipse插件,开发aspectj必装,他可 ...

  5. WPF的Binding学习笔记(二)

    原文: http://www.cnblogs.com/pasoraku/archive/2012/10/25/2738428.htmlWPF的Binding学习笔记(二) 上次学了点点Binding的 ...

  6. AJax 学习笔记二(onreadystatechange的作用)

    AJax 学习笔记二(onreadystatechange的作用) 当发送一个请求后,客户端无法确定什么时候会完成这个请求,所以需要用事件机制来捕获请求的状态XMLHttpRequest对象提供了on ...

  7. MyBatis学习系列二——增删改查

    目录 MyBatis学习系列一之环境搭建 MyBatis学习系列二——增删改查 MyBatis学习系列三——结合Spring 数据库的经典操作:增删改查. 在这一章我们主要说明一下简单的查询和增删改, ...

  8. MyBatis学习 之 二、SQL语句映射文件(2)增删改查、参数、缓存

    目录(?)[-] 二SQL语句映射文件2增删改查参数缓存 select insert updatedelete sql parameters 基本类型参数 Java实体类型参数 Map参数 多参数的实 ...

  9. MyBatis学习 之 二、SQL语句映射文件(1)resultMap

    目录(?)[-] 二SQL语句映射文件1resultMap resultMap idresult constructor association联合 使用select实现联合 使用resultMap实 ...

  10. UML学习(二)-----类图

    UML学习(二)-----类图 http://www.cnblogs.com/silent2012/archive/2011/09/07/2169946.html http://www.cnblogs ...

随机推荐

  1. 【C# Task】理解Task中的ConfigureAwait配置同步上下文

    原文:https://devblogs.microsoft.com/dotnet/configureawait-faq/ 作者:Stephen 翻译:xiaoxiaotank 静下心来,你一定会有收获 ...

  2. 【C#程序集】程序集

    .net 程序集的组成: 程序集由元数据.清单.il .资源 .net程序集名称 强名称程序集有一个完全限定的名称,由程序集的名称.区域性.公钥.版本号以及(可选)处理器体系结构组成. 使用 Full ...

  3. .NET 6 在小并发下如何生成唯一单据号

    一.场景介绍 小并发下要解决生成单据号的问题,会碰到哪些问题呢?,接下来让我们一探究竟[这是小并发的解决方案,大家有更好的做好可以一起讨论分享]. 之所以叫小并发:是因为确实是小并发场景的应用模式,一 ...

  4. How to use Remote-SSH in Windows

    对于不太会使用 Vim 的我来说,在服务器上用 Vim 去修改 nginx.conf 实在有点麻烦,比如没有高亮和格式化.正好想起前不久微软发布了远程开发工具包,其中一个就是今天要介绍的 Remote ...

  5. SQL从零到迅速精通【实用函数(2)】

    1.对查询结果进行排序 查询stu_info表中所有学生信息,并按照成绩由高到底进行排序,输入语句如下. SELECT * FROM stu_info ORDER BY s_score DESC;   ...

  6. 微信小程序授权登录将open_id传至后台并入库

    要求能把用户昵称.头像以及open_id写入数据库,服务端保持用户登录状态 wxml: <block wx:else> <button type="primary" ...

  7. myBatis plus 去除生成 controller

    ​ 由于我在网上没有找到答案, 所以分享给大家学习, 我也是第一次用 mybtis plus 的新生成器生成代码, 所以基础代码都是在官网复制所得. 在这里也支持大家在解决不了问题时, 可以试着看看源 ...

  8. 关于SQL Server 各种安装失败均失败,报错“等待数据库引擎恢复句柄失败”的经验分享

    最近安装SQL 2019遇到这个问题,试过自己合网上几乎所有办法,怎么都安装不上,最后在微软社区解决了,由于这个问题比较特殊,并且网上几乎没有正确的决绝方案,因此将我的解决过程及经验记录分享一下,也为 ...

  9. 《Shader入门精要》中MVP变换的Projection矩阵与《GAMES101图形学入门》中的区别

    game101的透视投影的投影矩阵是这样的 正交投影是这样的 而shader入门精要的透视投影矩阵是这样子 正交投影矩阵是这样子 game101的透视投影是这样得到的 而正交投影的时候并没有假设中心点 ...

  10. MATLAB绘制三角网及三维网线

    今天博主给大家介绍一些比较常见的可视化操作,绘制三角网及三维网线. 三角网是由一系列连续三角形构成的网状的平面控制图形,是三角测量中布设连续三角形的两种主要扩展形式,同时向各方向扩展而构成网状,优点为 ...