CentOS 7 Cobbler 自动化安装系统
在上一篇Cobbler 安装中,配置好了Cobbler,下面来配置自动化安装
配置cobbler-DHCP
# 修改settings中参数,由cobbler控制dhcp
[root@cobbler ~]# egrep '^manage_dhcp' /etc/cobbler/settings
manage_dhcp: 1
修改dhcp.templates配置文件(仅列出修改部分)
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.2;
option domain-name-servers 114.114.114.114;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.100 10.0.0.254;
重启服务并同步配置
改完dhcp必须要sync同步配置
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler sync
task started: 2018-09-27_161333_sync
task started (id=Sync, time=Thu Sep 27 16:13:33 2018)
running pre-sync triggers
cleaning trees
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 /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
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
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:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
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 ***
检查dhcp
[root@cobbler ~]# netstat -lntup | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 1733/dhcpd
导入CentOs-7的镜像
# 挂载光盘镜像
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@cobbler ~]# cobbler import --path=/mnt --name=Centos-7.5 --arch=x86_64
task started: 2018-09-27_161633_import
task started (id=Media import, time=Thu Sep 27 16:16:33 2018)
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.5-x86_64:
creating new distro: Centos-7.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/Centos-7.5-x86_64 -> /var/www/cobbler/links/Centos-7.5-x86_64
creating new profile: Centos-7.5-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.5-x86_64 for Centos-7.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/Centos-7.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-7.5-x86_64
looking for /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos-7.5-x86_64/repodata
*** TASK COMPLETE ***
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64,如果重复,系统会提示导入失败
查看
[root@cobbler ~]# cobbler list
distros:
Centos-7.5-x86_64
profiles:
Centos-7.5-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
导入kickstarts配置文件
[root@cobbler ~]# cd /var/lib/cobbler/kickstarts
[root@cobbler kickstarts]# ls
default.ks esxi5-ks.cfg legacy.ks sample_autoyast.xml sample_esx4.ks sample_esxi5.ks sample.ks sample.seed
esxi4-ks.cfg install_profiles pxerescue.ks sample_end.ks sample_esxi4.ks sample_esxi6.ks sample_old.seed
查看导入信息及默认ks文件
[root@cobbler kickstarts]# cobbler report
distros:
==========
Name : Centos-7.5-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/Centos-7.5-x86_64'}
Management Classes : []
OS Version : rhel7
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
profiles:
==========
Name : Centos-7.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7.5-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
systems:
==========
repos:
==========
images:
==========
mgmtclasses:
==========
packages:
==========
files:
==========
我ks文件(只是简单配置的,具体可以按自己业务来)
[root@cobbler kickstarts]# cat Centos7.5-x86_64.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1
# Use network installation
url --url="$tree"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=eth0
network --bootproto=dhcp --device=eth1
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=200
part swap --fstype="swap" --size=1024
part / --fstype="ext4" --grow --size=1
%packages
@base
@core
@compat-libraries
@debugging
@development
@gnome-desktop
@X Window System
%end
检查ks命令
# 写完 ks 文件之后,先通过 validateks 测试一下有没有语法错误
# cobbler validateks
# 通过下面这个命令查看 ks 文件,发现一些逻辑上的问题
# cobbler system getks --name=test
编辑修改指定ks文件为我们刚刚上传的ks
[root@cobbler kickstarts]# cobbler profile edit --name Centos-7.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7.5-x86_64.cfg
# 编辑profile,修改ks文件为我们刚刚上传的Centos7.2-x86_64.cfg
[root@cobbler kickstarts]# cobbler profile edit --name Centos-7.5-x86_64 --kopts='net.ifnames=0 biosdevname=0'
# 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用上面的参数。但要注意是CentOS7才需要上面的步骤,CentOS6不需要。
[root@cobbler kickstarts]# cobbler profile report
Name : Centos-7.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/Centos7.5-x86_64.cfg
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
[root@cobbler kickstarts]# cobbler sync
task started: 2018-09-27_162820_sync
task started (id=Sync, time=Thu Sep 27 16:28:20 2018)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/Centos-7.5-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/Centos-7.5-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: Centos-7.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos-7.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos-7.5-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: Centos-7.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos-7.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos-7.5-x86_64/initrd.img
Writing template files for Centos-7.5-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: Centos-7.5-x86_64
cleaning link caches
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:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
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 ***
新建一个虚拟机测试
为避免发生未知问题,先把服务端所有服务重启
[root@cobbler ~]# systemctl restart xinetd.service
[root@cobbler ~]# systemctl restart cobblerd.service
[root@cobbler ~]# systemctl restart httpd.service
[root@cobbler cobbler]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | I'm here # 修改这里为你想修改的内容
[root@cobbler cobbler]# cobbler sync # 同步之后就可以看到效果了
通过MAC地址定制化安装
我们可以根据不同的MAC地址来给安装不同的操作系统,配置不同的静态iP,设置不同的主机名等等,虚拟机查看MAC地址步骤
配置定制化安装(需要验证,后续验证后添加验证结果)
[root@cobbler ~]# cobbler system add \
--name=linux-web01 \
--mac=00:0C:29:3B:03:9B \
--profile=Centos-7.2-x86_64 \
--ip-address=10.0.0.200 \
--subnet=255.255.255.0 \
--gateway=10.0.0.2 \
--interface=eth0 \
--static=1 \
--hostname=linux-web01 \
--name-servers="10.0.0.2" \
--kickstart=/var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg
| 参数 | 解释 |
|---|---|
| system add | 添加定制系统 |
| name | 定制系统名称 |
| mac | mac地址 |
| profile | 指定profile |
| ip-address | 指定IP地址 |
| subnet | 指定子网掩码 |
| gateway | 指定网关 |
| interface | 指定网卡,eth0上面配置已经修改,centos7默认网卡名称不是eth0 |
| static | 1表示启用静态IP |
| hostname | 定义hostname |
| name-server | dns服务器 |
| kickstart | 指定ks文件 |
配置成功后我们可以查看到刚才定制的系统
[root@cobbler ~]# cobbler system list
linux-web01
接下来我们创建一个虚拟机,mac地址为00:0C:29:3B:03:9B,启动后你就会发现自动进入安装系统了,等安装完以后,所有的配置都和我们当初设置的一样。
使用koan实现重新安装系统
在客户端安装koan(要配置好源)
[root@cobbler ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
[root@cobbler ~]# yum install koan
查看cobbler上的配置文件
[root@cobbler ~]# koan --server=10.0.0.101 --list=profiles
-looking for Cobbler at http://10.0.0.101:80/cobbler_api Centos-7.2-x86_64
重新安装客户端系统
[root@cobbler ~]# koan --replace-self --server=10.0.0.101 --profile=webserver1
重启系统后会自动重装系统
CentOS 7 Cobbler 自动化安装系统的更多相关文章
- cobbler自动化安装系统
笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 在很久很久以前,使用kickstart实现自动化安装的时候,我一直认为装系统是多么高大上的活,直到cobbler的 ...
- s33 cobbler自动化安装系统
1. Cobbler介绍 参考链接:http://blog.oldboyedu.com/autoinstall-cobbler/ Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PX ...
- 为cobbler自动化安装系统工具添加epel源
关于cobbler的安装及部署,参考:CentOS 6.5自动化运维之基于cobbler服务的自动化安装操作系统详解http://blog.csdn.net/reblue520/article/det ...
- 其他综合-Cobbler无人值守安装系统 CentOS 7
Cobbler 无人值守安装系统 CentOS 7 1.实验描述 1.1 概述 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1 ...
- 基于CentOS7系统部署cobbler批量安装系统(week3_day5_part1)-技术流ken
前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cobbler ...
- 末学者笔记--Centos7系统部署cobbler批量安装系统
[前言]: cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cob ...
- Cobbler自动化安装
# Cobbler自动化安装 [Cobbler官网](http://cobbler.github.io) ![](/Users/wanyongzhen/Library/Containers/com.t ...
- 基于Centos7系统部署cobbler批量安装系统
前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本 系统环境的准备及下载cobbler 一 ...
- cobbler批量安装系统
cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 1.系统环境准备及其下载cobbler 1 ...
随机推荐
- [springboot 开发单体web shop] 2. Mybatis Generator 生成common mapper
Mybatis Generator tool 在我们开启一个新项目的研发后,通常要编写很多的entity/pojo/dto/mapper/dao..., 大多研发兄弟们都会抱怨,为什么我要重复写CRU ...
- 拼多多后台开发面试真题:如何用Redis统计独立用户访问量
众所周至,拼多多的待遇也是高的可怕,在挖人方面也是不遗余力,对于一些工作3年的开发,稍微优秀一点的,都给到30K的Offer,当然,拼多多加班也是出名的,一周上6天班是常态,每天工作时间基本都是超过1 ...
- 从壹开始【NetCore3.0】 46 ║ 授权认证:自定义返回格式
前言 哈喽大家好,马上就要年末了,距离新的一年,只有50天了,春节是75天. 在这个时节内,天气逐渐变凉,但是大家的心肯定很热吧,因为发生了两件大事: 1.双十一买买买,在这个让人激动又纠结的一天,大 ...
- 洛谷P3452 [POI2007]BIU-Offices的思考
这题就是坑人的,因为way我前一半存正图,后一半存反图,导致一般扩大两倍过不了,而是要扩大四倍,就是这个坑!!!!! #include<iostream> #include<cstd ...
- m74 考试反思
这次不叫考试题解,叫做考试反思,为什么折磨说,因为这次犯的错误太多了! 事情还要从昨天晚上说起,昨晚放学,班主任来机房说我被子不合格,要停课反思 ###&&¥%#%¥@#%¥#@……% ...
- 『题解』Codeforces1142A The Beatles
更好的阅读体验 Portal Portal1: Codeforces Portal2: Luogu Description Recently a Golden Circle of Beetlovers ...
- 使用.net core中的类DispatchProxy实现AOP
在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是软件开发中的一个热点,利用A ...
- Maven/Docker快速搭建RocketMQ
官方文档 [https://rocketmq.apache.org/docs/quick-start/] ①:Bin_二进制安装版 1. 环境准备 系统环境:Centos7 x64 JDK:jdk-8 ...
- it公司比较
1:本人西电通院2013届毕业硕士,根据今年找工作的情况以及身边同学的汇总,总结各大公司的待遇如下,吐血奉献给各位学弟学妹,公司比较全,你想去的公司不在这里面,基本上是无名小公司了:但无名小公司有时也 ...
- Linux跨网段通信小实验
一.实验场景. 实验准备,Linux主机4台.分别是主机A,路由主机R1,路由主机R2,主机 C,主机A的ip是192.168.56.66/24,且只有一块网卡eth0:路由主机R1有两块网卡eth0 ...