cobbler+kickstart安装笔记

本文参考老男孩配置:https://blog.oldboyedu.com/autoinstall-cobbler/

centos7:开机如果不启动网卡,需要修改/etc/sysconfig/network-scripts/本地的网卡(一般为ens-xxx)将onboot改为yes

1.安装epel rpm源(这里使用的阿里云源)

yum clean all

rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

2.安装前置安装环境

关闭防火墙,和selinux(不愿意关的话可以开放相应端口25151 69 22 80)

    systemctl stop firewalld  #停止防火墙

    systemctl disable firewalld  #禁止开机启动防火墙

    vi /etc/sysconfig/selinux  #修改selinux

     SELINUX=disabled

    reboot #重启 

下面安装基础环境

yum -y install cobbler cobbler-web pykickstart debmirror httpd dhcp xinetd xftp rsyncd

#这里我们启动服务,并设置开机启动

systemctl start httpd

systemctl enable httpd

systemctl start cobblerd

systemctl enable cobblerd

systemctl start xftp

systemctl enable xftp

systemctl start rsyncd

systemctl enable rsyncd
ksvalidator /var/lib/cobbler/kickstarts/CentOS7-7-x86_64.cfg #安装的pykickstart里面的工具,用来检查简单的语法错误登,但是有时候会误判,发现有朋友ks文件出问题,当初写的时候忘了补充下

配置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 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. 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.
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.

按照步骤设置

修改cobbler配置文件

vim /etc/cobbler/settings

#第一项 server 将server设置为提供cobbler服务的服务器ip(我这里是单虚拟机模拟所以就设置的为本机)

#server = 127.0.0.1
server = 192.168.184.130
#可以使用sed直接修改,第一次推荐还是先手动改改,多看看配置,后面就直接改了就行了
#sed -i 's/server: 127.0.0.1/server: 192.168.184.130/' /etc/cobbler/settings

#第一项 next_server 将提供pxe服务的ip

#next_server = 127.0.0.1
next_server = 192.168.184.130 #sed -i 's/next_server: 127.0.0.1/next_server:192.168.184.130/' /etc/cobbler/settings

#第三项 将tftp的disable 值从yes修改为no

vi /etc/xinetd.d/tftp
disable=no
#sed -i 's/disable=yes/disable=no/' /etc/xinetd.d/tftp

#第四项 下载网络安装所需文件

cobbler get-loaders   #注意,在上面步骤中,如果你不小心输错了你配置的server的ip地址的话,会报错,请先检查自己输入的ip是否正确。

#第五项 启动rsync(/etc/xinetd.d/rsync有些人分享的步骤中会有这个文件,但是实际上不用xinetd托管rsync也不影响,所以只要启动了服务就问题不大)

systemct start rsyncd

systemct  enable rsyncd

ps:如果在前面你像我一样启动了,这一步可以省略,这里只是为了对照cobbler的提示

#第六项 配置密码

#(执行下面命令后之后会出现加密后的密码,现在的版本随机值最好不要设置为random-phrase)

openssl passwd - -salt 'random-phrase-here' 'your-password-here' 

#将密码添加到/etc/cobbler/settings中的default_password值
#default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

重启cobbler

systemctl restart httpd
systemctl restart cobbler

再次检查配置,若没有问题则提交同步

cobbler check

cobbler rsync 

#通过cobbler管理dhcp

#修改/etc/cobbler/settings值manage_dhcp: 1
#sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings

#查看cobbler的配置例子

vim /etc/cobbler/dhcp.template

subnet 192.168.184.0 netmask 255.255.255.0 {
option routers 192.168.184.2;
option domain-name-servers 192.168.184.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.184.100 192.168.184.254;

#导入镜像 先将镜像挂在,再通过import导入 --path为挂在镜像的路径 --name为名字 --arch为架构

mount /dev/cdrom /mnt
#mount: /dev/sr0 写保护,将以只读方式挂载 如果是虚拟机的朋友,导入挂载没发先cdrom,在虚拟机里将cdrom启动再挂载即可,path为镜像挂载的目录,name为你这个镜像的名称,arch为系统架构 cobbler import --path=/mnt/ --name=CentOS7 --arch=x86_64 #文件镜像位置为/var/www/cobbler/ks_mirror 

#kickstart

#将写好的启动配置文件文件上传至/var/lib/cobbler/kickstarts/CentOS7-7-x86_64.cfg目录下,下面是我使用的配置文件,可以根据自身需求修改配置文件(这个中文注释只是方便理解,在使用中的时候配置文件中不能有中文,需要全部删除)

#System

#设置字符集格式
lang en_US.UTF-
#设置键盘类型
keyboard us
#设置时区
timezone --utc Asia/Shanghai
#Root密码
rootpw --iscrypted $default_password_crypted
#text模式安装
text
#告知安装程序,这是一次全新安装,而不是升级
install
#通过cobbler安装镜像
url --url=$tree
#bootloader安装在mbr扇区(磁盘的0磁道0柱面1扇区前512字节,后64字节为分区信息,每个分区占16个字节)
bootloader --location=mbr
#清除mbr引导(清空引导扇区)
zerombr
#清空分区
clearpart --all --initlabel
#/boot分区
part /boot --fstype xfs --size --ondisk sda
#swap分区
part /swap --size --ondisk sda
#根分区
part / --fstype xfs --size --grow --ondisk sda
#设置密码格式
authconfig --enableshadow --passalgo=sha512
#网络信息
$SNIPPET('network_config')
#重启
reboot
#关闭防火墙
firewall --disabled
#关闭selinux
selinux --disabled
#不配置Xwindows
skipx
#安装包信息
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
$SNIPPET('pre_anamon')
%end %packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl=devel
zilb-devel
OpenIPMI-tools
mysql
nmap
screen
%end %post
systemctl disabled postfix.service
%end

上传了之后我们可以更新一下cobbler的默认配置文件(配置文件里面不能有中文,注释也不能有中文,否则会配置文件读取会出问题)

可以通过cobbler list命令查看

cobbler profile edit --name=CentOS7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7-7-x86_64.cfg

设置网卡名,因为在CentOS7之后网卡名会被命名为ens-XXXX的格式

cobbler profile edit --name=CentOS7-x86_64 --kopts='net.ifnames=0 biosdevname=0'

确认更新情况

cobbler profile report CentOS7-x86_64

cobbler sync 再次提交更新

可以查看下CentOS的启动文件

cat /var/lib/tftpboot/pxelinux.cfg/default

cobbler(报错):

1.tftp TimeOut :端口未开放
解决方法:systemctl stop firewalld systemctl disable firewalld

2./dev/root does not exist :在安装CentOS7的过程中会遇见这个问题,经过我查资料是(除了注释里有中文或者配置文件中有中文)找不到镜像目录,指定目录即可安装

distro:主要用来定义某个发行版特有的或者特用的ramdisk和kernel的,该命令主要用于对distro进行增加,编辑,拷贝,查找,移除,重命名操作。

https://anaconda-installer.readthedocs.io/en/latest/boot-options.html?highlight=ksdevice我们在anaconda的官方文档中看到的选项使用inst.repo=[http,https,ftp]://<host>/<path>指定镜像目录

cobbler distro edit --name=CentOS7-x86_64 --kopts="ksdevice= inst.repo=http://192.168.184.131/cblr/ks_mirror/CentOS7-x86_64/" --ksmeta="tree=http

cobbler+kickstart安装笔记的更多相关文章

  1. 末学者笔记--Centos7系统部署cobbler批量安装系统

      [前言]: cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cob ...

  2. 自动化安装操作系统(Centos7+PXE+Cobbler+kickstart)

    一.简介 PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提 ...

  3. 使用Cobbler无人值守安装CentOS6.5(一)

    Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置 ...

  4. kickstart安装

    1.生成ks.cfg 文件 安装Kickstart # yum install system-config-kickstart 8.2 在桌面环境下配置Kickstart 启动X Windows 环境 ...

  5. 批量Linux 网络安装环境建立工具cobbler/kickstart

    批量Linux 网络安装环境建立工具网络安装服务器套件:     Cobbler(Red Hat 2008年发布的项目)    Kickstart(Red Hat08年前项目,相关脚本令人望而却步,现 ...

  6. 一键cobbler批量安装脚本

    前几天机房上架180台服务器,太多了,使用了cobbler批量安装,具体的看我上代码,我把配置cobbler的命令给堆积起来,也算是个脚本吧,欢迎拍砖指正,下面我上脚本: #!/bin/bash # ...

  7. cobbler简介+安装

    (介绍部分的内容部分是借鉴网上的非原创) 回顾pxe+kickstart PXE        PXE(preboot execute environment,预启动执行环境) PXE启动原理: 当计 ...

  8. cobbler部署安装CentOS6.8

    Linux运维:cobbler : 矮哥linux运维群:93324526 学习cobbler的话,必须先搞懂kickstart,原理不是,不懂如何排错. kickstart部署请点击这里 1. Co ...

  9. 使用cobbler批量安装操作系统(基于Centos7.x )

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

随机推荐

  1. MySQL5

    MySQL数据库5 mysqldump备份恢复数据库 冷备份还原数据库 逻辑卷快照备份还原数据库 xtrabackup备份还原数据库 1. 备份和恢复概述 适用场景 硬件故障.软件故障.自然灾害.黑客 ...

  2. Python学习笔记之生成器、迭代器和装饰器

    这篇文章主要介绍 Python 中几个常用的高级特性,用好这几个特性可以让自己的代码更加 Pythonnic 哦 1.生成器 什么是生成器呢?简单来说,在 Python 中一边循环一边计算的机制称为 ...

  3. python爬取酷狗音乐排行榜

    本文为大家分享了python爬取酷狗音乐排行榜的具体代码,供大家参考,具体内容如下  

  4. 10.3andXE7的DEVExpress18.2.1记录备查

    记录备查: win10 DEVExpress18.2.1用DevExpressVCL一键编译安装工具_v10.3.2 - 2018-12-12.exe(包括help,备份...升级系统不用重新安装控件 ...

  5. Django Rest FrameWork再练习

    可能有重构目前应用的需求,rest framework是值得有必要深入去了解的. 所以,这应该是第三次看官方文档来练习, 希望能获取更深入的记忆. __author__ = 'CHENGANG882' ...

  6. Linux运行级别研究(转)

    Linux系统中的运行级别 7种运行级别 运行级别(Runlevel)指的是Unix或者Linux等类Unix操作系统的运行模式,不同的运行模式下系统的功能也有所有不同.Linux 系统下通常分为7种 ...

  7. mybatis表关联彻底理解

    1.多张表关联 三张表,用户表,主播表,关注表. 查询用户已经关注的主播的信息,那就要三张表关联起来啊.分别left join联在一起,通过id相同的连接在一起.最后where查找出最终条件. < ...

  8. J2SE基础:5.面向对象的特性2

    Final的使用 final在类之前 表示该类是终于类.表示该类不能再被继承. final在方法之前 表示该方法是终于方法,该方法不能被不论什么派生的子类覆盖. final在变量之前 表示变量的值在初 ...

  9. css3 和 html5 笔记

    1.css3 ie下大部分不兼容 ie9以下 浏览器低版本不兼容 需要写 -webket-transition:1s -moz-transition: 1s -o-transition:1s tran ...

  10. C++ Sleep Function 使用方法 Sleep(-1)

    <span style="font-size:18px;">//==================================================== ...