Cobbler自动化批量安装linux服务器的操作记录
Cobbler为何物?
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、TFTP、RSYNC以及yum仓库、构造系统ISO镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。
Cobbler功能
使用Cobbler,可以做到无需进行人工干预即可安装机器;
Cobbler设置一个PXE引导环境(它还可使用yaboot支持PowerPC),并控制与安装相关的所有方面,比如网络引导服务(DHCP和TFTP)与存储库镜像。
当希望安装一台新机器时,Cobbler可以:
使用一个以前定义的模板来配置DHCP服务(如果启用了管理 DHCP)将一个存储库(yum或rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统
在DHCP配置文件中为需要安装的机器创建一个条目,并使用您指定的参数(IP和MAC地址);
在TFTFP服务目录下创建适当的PXE文件;
重新启动DHCP服务以反映更改;
重新启动机器以开始安装(如果电源管理已启用)。
Cobbler的安装部署
基础环境
[root@cobbler-server ~]# cat /etc/redhat-release #系统版本
CentOSLinux release 7.1.1503(Core)
[root@cobbler-server ~]# uname –r #内核版本
3.10.0-229.el7.x86_64
[root@cobbler-server ~]# getenforce #检测selinux是否关闭(必须关闭)
Disabled
[root@cobbler-server ~]# systemctl stop firewalld #关闭防火墙
[root@cobbler-server ~]# ifconfig eth0|awk -F '[ :]+''NR==2 {print $3}' #查看IP地址
10.0.0.101
[root@cobbler-server ~]# hostname #查看主机名
cobbler-server
[root@cobbler-server ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #cobbler安装必须使用到epel源
安装
[root@cobbler-server ~]# yum install cobbler cobbler-web pykickstart httpd dhcp tftp xinetd
配置说明
cobbler #cobbler程序包
cobbler-web #cobbler的web服务包
pykickstart #cobbler检查kickstart语法错误
httpd #Apache web服务
dhcp #Dhcp服务
tftp #tftp服务
/etc/cobbler #配置文件目录
/etc/cobbler/settings #cobbler主配置文件
/etc/cobbler/dhcp.template #DHCP服务的配置模板
/etc/cobbler/tftpd.template #tftp服务的配置模板
/etc/cobbler/rsync.template #rsync服务的配置模板
/etc/cobbler/iso #iso模板配置文件目录
/etc/cobbler/pxe #pxe模板文件目录
/etc/cobbler/power #电源的配置文件目录
/etc/cobbler/users.conf #web服务授权配置文件
/etc/cobbler/users.digest #web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template #DNS服务的配置模板
/etc/cobbler/modules.conf #Cobbler模块配置文件
/var/lib/cobbler #Cobbler数据目录
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/kickstarts #默认存放kickstart文件
/var/lib/cobbler/loaders #存放的各种引导程序
/var/www/cobbler #系统安装镜像目录
/var/www/cobbler/ks_mirror #导入的系统镜像列表
/var/www/cobbler/images #导入的系统镜像启动文件
/var/www/cobbler/repo_mirror #yum源存储目录
/var/log/cobbler #日志目录
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志
Cobbler的检测
cobbler的运行依赖于dhcp、tftp、rsync及dns服务,其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler功能提供,rsync有rsync程序包提供,dns可由bind提供,也可由dnsmasq提供cobbler可自行管理这些服务中的部分甚至是全部,但需要配置文件/etc/cobbler/settings中的“manange_dhcp”、“manager_tftpd”、“manager_rsync”、“manager_dns”分别来进行定义,另外,由于各种服务都有着不同的实现方式,如若需要进行自定义,需要通过修改/etc/cobbler/modules.conf配置文件中各服务的模块参数的值来实现。
[root@cobbler-server ~]# systemctl start httpd #启动apache服务
[root@cobbler-server ~]# systemctl start cobblerd #启动cobbler程序
查看检查
[root@cobbler-server ~]# 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.Filesin 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:enable and start rsyncd.service with systemctl
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.
对于上述问题,一个个的解决,其实每个问题的后面都给出了解决方法:
1)修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如server:10.0.0.101;
[root@cobbler-server ~]# sed -i 's/server: 127.0.0.1/server: 10.0.0.101/'/etc/cobbler/settings
2)修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如next_server:10.0.0.101;
[root@cobbler-server ~]# sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.101/'/etc/cobbler/settings
3)修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
4)执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
5)执行 systemctl enable rsyncd命令即可;
6)如果有强迫症可以选择 yum –y install debmirror 然后根据错误进行解决,一般错误如下。
注释/etc/dedmirror.conf文件中的@dists=”sid”;@arches=”i386”;
7)[root@cobbler-server ~]# openssl passwd -1-salt '$(openssl rand -hex 4)''xuliangwei'
$1$$(openss$.wbDUBV/STL0YaNuAcusK/
[root@cobbler-server~]# grep "default_password_crypted"/etc/cobbler/settings #替换/etc/cobbler/setting内的default_password_crypted为上个命令结果
default_password_crypted:"$1$$(openss$.wbDUBV/STL0YaNuAcusK/"
8)[root@cobbler-server~]# yum –y install cman fence-agents
最后重启Cobbler:
[root@cobbler-server~]# systemctl restart cobblerd
配置DHCP
[root@cobbler-server~]# sed -i 's#manage_dhcp: 0#manage_dhcp: 1#g'/etc/cobbler/settings #使用cobbler管理dhcp
[root@cobbler-server~]# vim /etc/cobbler/dhcp.template #修改cobbler的dhcp模版,因为cobbler会替换。
subnet 10.0.0.0 netmask 255.255.255.0{
option routers 10.0.0.2;
option domain-name-servers 10.0.0.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.20010.0.0.250;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
同步cobbler
[root@cobbler-server~]# systemctl restart xinetd #重启xinetd
[root@cobbler-server~]# systemctl restart cobblerd #重启cobbler
[root@cobbler-server~]# cobbler sync #同步最新cobbler配置,可以看具体做了哪些操作
Cobbler管理
cobbler使用profile来为特定的需求类别提供锁需要安装的配置,即在distro的基础上通过提供kiskstart文件来生成一个特定的系统安装配置。distro的profile可以出现在pxe的引导菜单中作为安装的选择之一:
Cobbler-CentOS-7.1-x86_64.cfg
Cobbler-CentOS-6.7-x86_64.cfg
默认是有kickstart文件的,所以edit,如果没有kickstart文件可以add。
[root@cobbler-server ~]# cobbler profile edit --name=CentOS-7.1-x86_64-distro --kickstart=/var/lib/cobbler/kickstarts/Cobbler-CentOS-7.1-x86_64.cfg #指定ks路径
CentOS7系统网卡名变成eno...这种,为了运维标准化,我们需要修改为我们常用的eth0,使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
[root@cobbler-server ~]# cobbler profile edit --name=CentOS-7.1-x86_64-distro --kopts='net.ifnames=0 biosdevname=0' #修改centos7内核
新部署机器安装yum源,并同步。建议使用内网yum源,在这里使用阿里云yum源
[root@cobbler-server ~]# cobbler repo add --name=base --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/--arch=x86_64 --breed=yum #添加yum源
[root@cobbler-server ~]# cobbler reposync #同步yum源
[root@cobbler-server ~]# cobbler sync #每次修改profile都需要同步
解析来直接启动一台机器,然后开启网络启动就OK了。
自定义安装
system主要目的配置网络接口,通过system来固定机器的IP、掩码、网关、DNS、主机名、等等实现基础环境标准化。
根据机器的MAC地址,自动绑定IP,网关,dns等。
[root@cobbler-server ~]# cobbler system add --name=wangshibo--mac=00:0C:29:6E:41:CB --profile=Centos7.1-profile-x86_64 \
--ip-address=10.0.0.110--subnet=255.255.255.0--gateway=10.0.0.2--interface=eth0 \
--static=1--hostname=wangshibo
--name-servers="114.114.114.114 8.8.8.8"
[root@cobbler-server ~]# cobbler sync
[root@linux-node1 ~]# cobbler system list
wangshibo
自定义登录界面
[root@cobbler-server ~]# grep "wangshibo"/etc/cobbler/pxe/pxedefault.template#自定义装机页面
MENU TITLE wangshibo | http://wangshibo
[root@cobbler-server ~]# cobbler sync #同步
Web管理Cobbler
新版cobbler的web界面使用的是https,登录https://10.0.0.7/cobbler_web
cobbler_web支持多种认证方式,如authn_configfil、authn_ldap或authn_pam等,默认为authn_denyall,即拒绝所有用户登陆。
下面说明三种能认证用户登录cobbler_web的方式
1)使用authn_pam模块认证cobbler_web用户
首先修改modules中的[authentication]段中的module参数的值为authn_pam
接着创建系统用户,并为用户设定密码
而后将设定的系统用户添加至cobbler_web的admin组中,修改/etc/cobbler/users.conf
文件,将设定的用户添加为admin参数的值即可
2)使用authn_configfile模块认证cobbler_web用户
首先修改modules中的[authentication]段中的module参数的值为authn_configfile
添加第一用户时,需要为htdigest命令使用“-c” etc/cobbler/users.digest,后续添加其他用户则不能再使用,同步cobbler重启httpd以及cobbler
3)使用cobbler默认的web账号密码认证
user:cobbler
pass:cobbler
Cobbler自动化批量安装linux服务器的操作记录的更多相关文章
- Cobbler自动化批量安装Linux操作系统 - 运维总结
一.Cobbler简述 Cobbler是一个自动化和简化系统安装的工具,通过使用网络引导来控制和启动安装.Cobbler的特性包括存储库镜像.Kickstart模板和连接电源管理系统.Cobbler通 ...
- (转)Cobbler无人值守批量安装Linux系统
本文目录: 1.1 pxe安装系统 1.2 cobbler基本介绍 1.3 安装和配置cobbler 1.3.1 安装cobbler 1.3.2 配置dhcp和tftp 1.4 cobbler从本地光 ...
- cobbler无人值守批量安装Linux系统
本文目录: 1.1 pxe安装系统 1.2 cobbler基本介绍 1.3 安装和配置cobbler 1.3.1 安装cobbler 1.3.2 配置dhcp和tftp 1.4 cobbler从本地光 ...
- Cobbler全自动批量安装部署Linux系统
说明: Cobbler服务器系统:CentOS 5.10 64位 IP地址:192.168.21.128 需要安装部署的Linux系统: eth0(第一块网卡,用于外网)IP地址段:192.168.2 ...
- pxe+kickstart实现无人值守批量安装linux
pxe+kickstart实现无人值守批量安装linux 实验准备:主机myrhel2作为服务器端,新建一个没有安装操作系统的虚拟主机,而且其与服务器端在同一个网段 安装的条件: 服务器端: ...
- pxe+kickstart自动化批量安装系统详解-技术流ken
前言 pxe+kickstart是一款可以实现自动化批量安装系统的服务,比较经典,下面将详细介绍此服务的安装和使用. 系统环境准备 系统版本:CentOS release 6.7 (Final) 内网 ...
- kvm cobbler无人值守批量安装操作系统
kvm cobbler无人值守批量安装操作系统 cobbler:一个自动网络安装系统的工具,集成PEX.dhcp.dns.tftpd.sync等服务.可以供大家管理安装操作系统 kvm:Linux系统 ...
- ansible批量修改linux服务器密码的playbook
从网上找到批量修改Linux服务器root密码的playbook. 使用方法: 1.输入要修改的inventory组 2.按需要,在playbook中输入要修改的IP.新密码,如下: - hosts: ...
- linux学习(2):linux服务器常用操作和命令
linux服务器常用操作和命令 目录 1. 什么是linux服务器load average?2. 如何查看linux服务器负载3. 服务器负载高怎么办?4. 如何查看服务器内存使用率?5. 如何查看单 ...
随机推荐
- 关于原生的Javascript
JQuery是个好工具,它做了太多的事. 以至于让人渐渐忘记原生的JS该怎么写了,导致连为了用个DOM选择器或者Ajax就直接加个JQuery,确实,JQuery太方便了. 坏处: 由于JQuery的 ...
- RecyclerView和ScrollView嵌套使用
我们的recyclerView有多个layoutmanager,通过重写layoutmanager的方法就可以让recyclerView和ScrollView嵌套了.但是请注意,如果recyclerV ...
- HBase读写路径的工作机制
出处:http://wuyudong.com/1946.html HBase 写路径工作机制 在HBase 中无论是增加新行还是修改已有的行,其内部流程都是相同的.HBase 接到命令后存下变化信息, ...
- 【读书笔记】iOS-NSDate
+dateWithTimeIntervalSinceNow:接受一个NSTimeInterval参数,该参数是一个双精度值,表示以秒为单位的时间间隔.通过该参数可以指定时间偏移的方式:对于将来的时间, ...
- 【读书笔记】iOS-UIWindow-密码框
一,工程结构,如下图所示: 二,代码 PasswordInputWindow.h #import <UIKit/UIKit.h> @interface PasswordInputWindo ...
- iOS 架构模式-MVVM
iOS 架构模式-MVVM MVVM Model-View-ViewModelMVVM 其实是MVC的进化版,他将业务逻辑从VC中解耦到ViewModel,实现VC的瘦身. 做一个简单的登录判断: 创 ...
- Swift语言
本文为熟悉使用Objective-C开发iOS快速转入swift开发提供一些便利的途径,没有过多华丽的说明底层原理,也没有过多的概念说明,只提供swift的基本使用以及一些使用示例.高手请让路哈. S ...
- git proxy
git config --global http.proxy http://127.0.0.1:1080 git config --global https.proxy https://127.0.0 ...
- java集合 之 Map集合
Map用于保存具有映射关系的数据,具有两组值:一组用于保存Map中的key:另一组用于保存Map中的value,形成key-value的存储形式. Map集合中包含的一些方法: void clear( ...
- Visual Studio发布Web项目报错:Unable to add 'xxx' to the Web site. Unable to add file 'xxx'. The specified file could not be encrypted.
背景 Visual Studio下的Web项目 现象 发布时遇到Unable to add 'xxx' to the Web site. Unable to add file 'xxx'. The ...