一、cobbler介绍

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等

1、主要功能:
①Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用
②Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理
③Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack

2、Cobbler可管理的服务

PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
电源管理
Kickstart服务支持
YUM仓库管理
TFTP(PXE启动时需要)
Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

二、Cobbler部署配置

1、环境

[root@cobbler ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@cobbler ~]# uname -r
2.6.-.el6.x86_64
[root@cobbler ~]# /etc/init.d/iptables status
iptables: Firewall is not running.
[root@cobbler ~]# getenforce
Disabled
[root@cobbler ~]# hostname -I
10.0.0.121 172.16.1.121

2、安装Cobbler

CentOS6安装
yum localinstall Django14-1.4.-.el6.noarch.rpm -y
yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd
#说明:yum源里已经去除了Diango的下载源
CentOS7安装
yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd
#CentOS7安装cobbler文档#
https://github.com/congto/cobbler-1

3、启动Cobbler服务

[root@cobbler ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@cobbler ~]# /etc/init.d/cobblerd start
Starting cobbler daemon: [ OK ]

4、检查Cobbler配置

[root@cobbler tools]# cobbler check
The following are potential configuration items that you may want to fix: : 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.
: 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.
: change 'disable' to 'no' in /etc/xinetd.d/tftp
: 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., menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
: change 'disable' to 'no' in /etc/xinetd.d/rsync
: file /etc/xinetd.d/rsync does not exist
: debmirror package is not installed, it will be required to manage debian deployments and repositories
: 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
: 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

5、解决Cobbler问题

cp /etc/cobbler/settings{,.bak} #备份Cobbler主配置文件

sed -i 's/server: 127.0.0.1/server: 172.16.1.121/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.121/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings #使用cobbler管理dhcp
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings #防止有些机子第一启动是pxe循环重装系统,此处设置为只能装一次
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'cobbler' '123456'`\"#" /etc/cobbler/settings #设置系统的默认密码为123456
sed -i 's#yes#no#' /etc/xinetd.d/rsync
sed -i 's#yes#no#' /etc/xinetd.d/tftp

6、配置Cobbler的dhcp模板

sed -i 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template
#修改过后内容如下:
……
subnet 172.16.1.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
range dynamic-bootp 172.16.1.100 172.16.1.254;
default-lease-time ;
max-lease-time ;
next-server $next_server;
…… [root@cobbler tools]# /etc/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@cobbler tools]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[root@cobbler tools]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

7、同步Cobbler配置

[root@cobbler tools]# cobbler sync
task started: --07_145244_sync
task started (id=Sync, time=Tue Nov :: )
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
copying distros to tftpboot
copying images
generating PXE configuration files
#再次检查cobbler
[root@cobbler tools]# cobbler check
The following are potential configuration items that you may want to fix: : 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., menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
: debmirror package is not installed, it will be required to manage debian deployments and repositories
: 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. #问题解决完毕

8、此时打开浏览器输入

三、使用Cobbler的web页面实现自动化安装系统

1、导入镜像

[root@cobbler ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@cobbler ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 19G .6G 16G % /
tmpfs 931M 931M % /dev/shm
/dev/sda1 190M 35M 146M % /boot
/dev/sr0 .7G .7G % /mnt

通过rsync导入镜像

[root@cobbler ~]# ps -ef|grep rsync
root 2087 1599 18 16:57 ? 00:00:05 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS6.9-x86_64 --progress
root 2088 2087 0 16:57 ? 00:00:00 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS6.9-x86_64 --progress
root 2089 2088 13 16:57 ? 00:00:03 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS6.9-x86_64 --progress
root 2106 1256 0 16:58 pts/1 00:00:00 grep rsync

 导入完成之后

2、创建ks文件

3、定制系统

根据机器的mac地址固定ip地址

eth1

eth0

CentOS7,修改网卡名

保存

4、新建空白虚拟机测试

休息片刻,一会儿回来查看结果

4、CentOS6与CentOS7的ks.cfg文件

CentOS6.9

# Cobbler for Kickstart Configurator for CentOS 6.9 by yan xinjiang
install
url --url=$tree
text
lang en_US.UTF-
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=
part swap --size=
part / --fstype=ext4 --grow --asprimary --size=
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end %packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end %post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end %post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end

CentOS7.2

# Cobbler for Kickstart Configurator for CentOS 7.2 by yan xinjiang
install
url --url=$tree
text
lang en_US.UTF-
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# Network information
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size
part swap --size
part / --fstype xfs --size --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
htop
wget
vim
bash-completion
net-tools
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
%end
%post
systemctl disable postfix.service
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
%end

linux运维、架构之路-cobbler无人值守的更多相关文章

  1. linux运维架构师职业规划

    1.假如你从来未接触过Linux的话,首先要做的就找一本指导书来学习.现在公认的Linux的入门书籍是“鸟哥的私房菜”,讲的很全面,鸟哥的私房菜一共分为两部,一部是基础篇,一部是服务器篇.“鸟哥的私房 ...

  2. 从苦逼到牛逼,详解Linux运维工程师的打怪升级之路

    做运维也快四年多了,就像游戏打怪升级,升级后知识体系和运维体系也相对变化挺大,学习了很多新的知识点. 运维工程师是从一个呆逼进化为苦逼再成长为牛逼的过程,前提在于你要能忍能干能拼,还要具有敏锐的嗅觉感 ...

  3. Nginx+Lua+Redis整合实现高性能API接口 - 网站服务器 - LinuxTone | 运维专家网论坛 - 最棒的Linux运维与开源架构技术交流社区! - Powered by Discuz!

    Nginx+Lua+Redis整合实现高性能API接口 - 网站服务器 - LinuxTone | 运维专家网论坛 - 最棒的Linux运维与开源架构技术交流社区! - Powered by Disc ...

  4. Linux运维企业架构实战系列

    Linux运维企业架构项目实战系列 项目实战1-LNMP的搭建.nginx的ssl加密.权限控制的实现 项目实战2-LVS.nginx实现负载均衡系列 2.1 项目实战2.1-实现基于LVS负载均衡集 ...

  5. Linux运维企业架构项目实战系列

    Linux运维企业架构项目实战系列 项目实战1—LNMP的搭建.nginx的ssl加密.权限控制的实现 项目实战2—LVS.nginx实现负载均衡系列2.1 项目实战2.1—实现基于LVS负载均衡集群 ...

  6. Linux 运维入门到跑路书单推荐

    一.基础入门 <鸟哥的Linux私房菜基础学习篇>:最具知名度的Linux入门书<鸟哥的Linux私房菜基础学习篇>,全面而详细地介绍了Linux操作系统. https://b ...

  7. 从零起步做到Linux运维经理, 你必须管好的23个细节

    “不想成为将军的士兵,不是好士兵”-拿破仑 如何成为运维经理? 一般来说,运维经理大概有两种出身:一种是从底层最基础的维护做起,通过出色的维护工作,让公司领导对这个人非常认可,同时对Linux运维工作 ...

  8. 从零起步做到Linux运维经理,你必须管好的23个细节

    不想成为将军的士兵,不是好士兵-拿破仑 如何成为运维经理?成为运维经理需要什么样的能力?我想很多运维工程师都会有这样的思考和问题. 如何成为运维经理.一般来说,运维经理大概有两种出身,一种是从底层最基 ...

  9. linux 运维知识体系

    这里将会介绍一下,LINUX运维工程师的知识体系. 只能说是个人理解吧.并不是必要或者充分的,仅供网友参考. 大部分本博客都有涉及,并不完整. 1.LINUX运维基础 1.1.LINUX系统的简介,分 ...

随机推荐

  1. ActionList及Action使用

    ActionList及Action使用 https://blog.csdn.net/adamrao/article/details/7450889 2012年04月11日 19:09:27 阅读数:1 ...

  2. 知识图谱之图数据库Neo4j

    知识图谱中的知识是通过RDF结构来进行表示的,其基本单元是事实.每个事实是一个三元组(S, P, O),在实际系统中,按照存储方式的不同,知识图谱的存储可以分为基于表结构的存储和基于图结构的存储. 基 ...

  3. 应用安全 - 工具 - Adobe - Adobe Flash Player - 漏洞 - 汇总

    CVE-2018-4878 Date 类型软件漏洞可被用于钓鱼 影响范围Flash Player版本28.0.0.137以及之前的所有版本 复现 分析

  4. cdh平台问题

    问题背景:内容的不懂之处,可以私信博主.友好交流使用.主要针对的问题种类有:网络桥接报错.网卡文件问题(该问题主要看你的安装脚本文件里面写的是否和主机对应,也是运行环境的问题).scm表中没有节点信息 ...

  5. 为企业服务器配置RAID0、raid1、 raid10、raid5、raid6、等常见RAID

    RAID卡操作手册先从开机启动时如何进入管理界面开始介绍: 1)当机器开启后,显示器出现阵列卡检测信息时,会提示用户是否要进入管理界面对阵列卡进行操作,此时按下Ctrl + H 即可,如下图 2)按下 ...

  6. mysql中的范式

    范式 范式:Normal Format,是一种离散数学中的知识,是为了解决数据的存储与优化的问题:保存数据的存储之后,凡是能够通过关系寻找出来的数据,坚决不再重复存储,终极目标是为了减少数据的冗余.范 ...

  7. Java 向上造型详解

    子类的对象可以向上造型为父类的类型.即父类引用子类对象,这种方式被称为向上造型. 在日常生活中,我们都扮演着不一样的角色.我们有可能是老师,有可能是学生,有可能是……, 但是我们都有共同的属性,例如: ...

  8. 原生js事件委托(事件代理)方法扩展

    原生js事件委托(事件代理)方法扩展: 通过Node底层原型扩展委托方法 /** * 事件委托方法 * @param eventName {string}:事件名称,如'click' * @param ...

  9. 似乎在梦中见过的样子 (KMP)

    # 10047. 「一本通 2.2 练习 3」似乎在梦中见过的样子 [题目描述] 「Madoka,不要相信 QB!」伴随着 Homura 的失望地喊叫,Madoka 与 QB 签订了契约. 这是 Mo ...

  10. 14-jquery元素节点操作

    **创建节点** ```var Div = $('<div>');var Div2 = $('<div>这是一个div元素</div>');``` **插入节点** ...