cobbler自动批量安装多版本操作系统

news2024/9/24 23:49:42

本次虚拟化环境为VMware Workstation Pro,cobbler服务端为CentOS7.9,需要自动安装的版本为CentOS7.9和CentOS8.1

目录

  • 一、安装cobbler服务端
    • 1、修改YUM源
    • 2、关闭防火墙
    • 3、安装软件包
    • 4、cobbler环境配置
    • 5、解决语法问题
    • 6、启动服务
    • 7、导入镜像
    • 8、自定义ks文件
    • 9、修改启动菜单
    • 10、自动安装操作系统
  • 二、配置多版本自动安装系统
    • 1、导入镜像
    • 2、自定义ks文件
    • 3、修改启动菜单
    • 4、自动安装操作系统

一、安装cobbler服务端

1、修改YUM源

如果是内网服务器,有本地YUM源

cd /etc/yum.repos.d/
mkdir ./repobak
mv ./*.repo ./repobak/

上传repo文件

yum clean all
yum makecache
yum repolist

如果有外网环境直接下载公网源

cd /etc/yum.repos.d/
mkdir ./repobak
mv ./*.repo ./repobak/
curl -O https://mirrors.aliyun.com/repo/Centos-7.repo
curl -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2、关闭防火墙

关闭防火墙,selinux

systemctl stop firewalld.service
systemctl disable firewalld.service
vim /etc/selinux/config

在这里插入图片描述

3、安装软件包

yum install -y httpd dhcp xinetd tftp-server cobbler cobbler-web
cobbler语法检查前先启动http与cobbler
systemctl start httpd.service
systemctl start cobblerd.service

4、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 re          achable 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.  If you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux packag          e 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.
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

Restart cobblerd and then run 'cobbler sync' to apply changes.

5、解决语法问题

第1、2条

vim /etc/cobbler/settings
manage_dhcp: 1	
next_server: 192.168.241.128
server: 192.168.241.128
manage_rsync: 1
pxe_just_once: 1

第3条

vim /etc/xinetd.d/tftp
wait                    = no
disable                 = no

第4条
/var/lib/cobbler/loaders 中缺少一些网络引导加载器。如果只想处理 x86/x86_64 网络引导,则可以确保已安装 syslinux 包的最新版本,并且可以完全忽略此消息。如果想要支持所有体系结构,此目录中的文件应包括 pxelinux.0、menu.c32、elilo.efi 和 yaboot。

yum -y install syslinux

安装syslinux,不需要支持所有架构,便不用理会该警告

第5条

systemctl start rsyncd
systemctl enable rsyncd

第6条

yum  install  -y  pykickstart  debmirror
vi /etc/debmirror.conf  #注释掉 @dists 和 @arches 两行
#@dists="sid";
#@arches="i386";

第7条

 openssl passwd -1 -salt 'cobbler' '123456'

得到
1 1 1cobbler$sqDDOBeLKJVmxTCZr52/11

vim /etc/cobbler/settings
default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"

cp /etc/cobbler/dhcp.template /etc/cobbler/dhcp.template.bak
vim /etc/cobbler/dhcp.template

在这里插入图片描述

systemctl restart cobblerd.service
cobbler sync
cobbler check

在这里插入图片描述

6、启动服务

systemctl status httpd dhcpd rsyncd tftp cobblerd
systemctl start httpd dhcpd rsyncd tftp cobblerd
systemctl enable httpd dhcpd rsyncd tftp cobblerd

7、导入镜像

导入镜像到cobbler服务端中
上传镜像,挂载镜像

mkdir /mnt/centos7.9
mount CentOS-7.9-x86_64-Everything-2207-02.iso  /mnt/centos7.9
cobbler import --path=/mnt/centos7.9 --name=CentOS-7.9-x86_64-Everything-2207-02 --arch=x86_64

在这里插入图片描述

8、自定义ks文件

cd /var/lib/cobbler/kickstarts/
ll
vim centos7u9.ks

以服务器版为例

#Kickstart Configurator for cobbler by KE HUIWEN
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --fstype="swap" --size 4096 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
@^infrastructure-server-environment
@base
@compat-libraries
@core
@debugging
@development
@directory-client
@guest-agents
@ha
@hardware-monitoring
@infiniband
@java-platform
@large-systems
@load-balancer
@network-file-system-client
@performance
@remote-system-management
@resilient-storage
@security-tools
@smart-card
@system-admin-tools
@virtualization-hypervisor
kexec-tools
%end
  
%post
systemctl disable postfix.service
%end

#指定启动文件,要手写,不要复制

cobbler profile edit --name "CentOS-7.9-Everything-2207-02-x86_64"  --kickstart=/var/lib/cobbler/kickstarts/centos7u9.ks

#修改centos配置文件中的kickstart值

cobbler profile edit --name=CentOS-7.9-Everything-2207-02-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler sync   #执行rsync同步,同步成功

查看kickstart 关联是否成功,注意是否修改成功

cobbler profile report

在这里插入图片描述

9、修改启动菜单

cobbler system add  --name=default --profile=CentOS-7.9-Everything-2207-02-x86_64
cobbler  system list
cobbler sync 

在这里插入图片描述

cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT CentOS-7.9-Everything-2207-02-x86_64

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL CentOS-7.9-Everything-2207-02-x86_64
        kernel /images/CentOS-7.9-Everything-2207-02-x86_64/vmlinuz
        MENU LABEL CentOS-7.9-Everything-2207-02-x86_64
        append initrd=/images/CentOS-7.9-Everything-2207-02-x86_64/initrd.img ksdevice=bootif lang=  text net.ifnames=0 biosdevname=0 kssendmac  ks=http://10.49.33.206/cblr/svc/op/ks/profile/CentOS-7.9-Everything-2207-02-x86_64
        ipappend 2

MENU end

10、自动安装操作系统

新建虚拟机,安装客户机操作系统界面时选择稍后安装操作系统
在这里插入图片描述
开启虚拟机,选择镜像安装
在这里插入图片描述
等待安装完成

二、配置多版本自动安装系统

1、导入镜像

上传镜像,挂载镜像

mkdir /mnt/centos8.1
mount CentOS-8.1.1911-x86_64-dvd1.iso  /mnt/centos8.1 
cobbler import --path=/mnt/centos8.1 --name=CentOS-8.1.1911-x86_64-dvd1 --arch=x86_64

在这里插入图片描述

2、自定义ks文件

cd /var/lib/cobbler/kickstarts/
ll
 vim centos8u1.ks

#安装服务器版centos
注意安装包会有所不同

#Kickstart Configurator for cobbler by KE HUIWEN
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr --boot-drive=sda
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --fstype="swap" --size 4096 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@print-client
binutils
ftp
gcc
kernel-devel
kexec-tools
make
mesa-libxatracker
open-vm-tools
patch
xorg-x11-drv-vmware
%end
  
%post
systemctl disable postfix.service
%end

#指定启动文件,要手写,不要复制

cobbler profile edit --name "CentOS-8.1.1911-dvd1-x86_64" --kickstart=/var/lib/cobbler/kickstarts/centos8u1.ks

#修改centos配置文件中的kickstart值

cobbler profile edit --name=CentOS-8.1.1911-dvd1-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler sync   #执行rsync同步,同步成功

查看kickstart 关联是否成功,注意是否修改成功

cobbler profile report

在这里插入图片描述

3、修改启动菜单

cobbler system add  --name=centos8u1 --profile=CentOS-8.1.1911-dvd1-x86_64
cobbler  system list
cobbler sync 

在这里插入图片描述

cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT CentOS-7.9-Everything-2207-02-x86_64

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL CentOS-7.9-Everything-2207-02-x86_64
        kernel /images/CentOS-7.9-Everything-2207-02-x86_64/vmlinuz
        MENU LABEL CentOS-7.9-Everything-2207-02-x86_64
        append initrd=/images/CentOS-7.9-Everything-2207-02-x86_64/initrd.img ksdevice=bootif lang=  text net.ifnames=0 biosdevname=0 kssendmac  ks=http://192.168.241.128/cblr/svc/op/ks/profile/CentOS-7.9-Everything-2207-02-x86_64
        ipappend 2

LABEL CentOS-8.1.1911-dvd1-x86_64
        kernel /images/CentOS-8.1.1911-dvd1-x86_64/vmlinuz
        MENU LABEL CentOS-8.1.1911-dvd1-x86_64
        append initrd=/images/CentOS-8.1.1911-dvd1-x86_64/initrd.img ksdevice=bootif lang=  text net.ifnames=0 biosdevname=0 kssendmac  ks=http://192.168.241.128/cblr/svc/op/ks/profile/CentOS-8.1.1911-dvd1-x86_64
        ipappend 2



MENU end

4、自动安装操作系统

新建虚拟机,操作如上1.10,选择CentOS-8.1
在这里插入图片描述
等待自动安装在这里插入图片描述
安装完成
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2161810.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

828华为云征文|华为云Flexus X实例:极速搭建个人代码仓库GitLab平台

目录 前言 一、Flexus云服务器X介绍 1.1 Flexus云服务器X实例简介 1.2 Flexus云服务器X实例特点 1.3 Flexus云服务器X实例使用场景 二、Flexus云服务器X购买 2.1 Flexus X实例购买 2.2 重置密码 2.3 登录服务器 三、Flexus X 实例安装GitLab 3.1 GitLab镜像下载 3.2 GitLab部署…

yolov8模型在猫脸关键点检测识别中的应用【代码+数据集+python环境+GUI系统】

yolov8模型在猫脸关键点检测识别中的应用【代码数据集python环境GUI系统】 yolov8模型在猫脸关键点检测识别中的应用【代码数据集python环境GUI系统】 背景意义 猫脸关键点检测是计算机视觉领域的一个重要研究方向,它基于深度学习、机器学习等技术,通过…

手机文件压缩与解压:节省流量的实用技巧

首先,节省存储空间是手机文件压缩的一大优势。随着我们拍摄照片、录制视频、下载文件等,手机的存储空间很容易被占满。 通过压缩文件,可以减小文件的大小,从而释放更多的存储空间。例如,一些大型的文档、图片和视频文…

MySQL:进阶巩固-存储过程

目录 一、存储过程的概述二、存储过程的基本使用2.1 创建存储过程2.2 使用存储过程2.3 查询指定数据库的存储过程以及状态信息2.4 查看某个存储过程的定义2.5 删除存储过程2.6 案例 三、存储过程的变量设置3.1 系统变量3.2 用户自定义变量3.3 局部变量 四、IF判断五、参数六、C…

自动化学习3:日志记录及测试报告的生成--自动化框架搭建

一.日志记录 1.配置文件pytest.ini:将日志写入文件方便日后查询或查看执行信息。 需要将文件处理器(文件存放位置/时间/格式等等)添加到配置文件中的【日志记录器】 # pytest.ini [pytest] # ---------------日志文件,需要配合…

虚拟机使用FileZilla软件实现文件互传

软件版本:FizeZilla 3.63.2 VirtualBox7.0.20 1.设置桥接模式(网卡) 2.查看ip 在控制台输入ifconfig 3.在终端打开控制台安装FTP服务 sudo apt-get install vsftpd 等待软件自动安装,安装完成以后使用 VI命令打开 /etc/vsftpd.conf,命令…

8086的指令系统

今天上午综测答辩结束,感觉就很一般,但是我昨晚也操心到觉都没睡好,今天中午舍友玩P5吵得我也没睡着,感觉脑袋昏昏沉沉,汇编上课没认真听讲,晚上来补一补。还是采用GPT来讲解(水文字&#xff09…

Unity开发绘画板——02.创建项目

1.创建Unity工程 我们创建一个名为 DrawingBoard 的工程,然后先把必要的工程目录都创建一下: 主要包含了一下几个文件夹: Scripts :存放我们的代码文件 Scenes :工程默认会创建的,存放场景文件 Shaders &…

9.22日常记录

1.memccpy函数 memccpy是一个用于内存复制的函数&#xff0c;它的原型通常在<cstring>&#xff0c;memccpy函数的作用是从源内存区域复制字节到目标内存区域&#xff0c;直到遇到特定的字符或者复制了指定数量的字节为止。 返回值: 如果在复制过程中找到了指定的字符&am…

科大讯飞智能体Python SDK接入流程

第一步&#xff1a;注册账号​ 进入https://passport.xfyun.cn/login&#xff0c;根据提示注册或登陆账号。 ​ 第二步&#xff1a;创建智能体 进入这个网页创建智能体&#xff0c;填好信息&#xff1a; https://xinghuo.xfyun.cn/botcenter/createbot?createtrue&qu…

lkhgjfjghkbhjk

&#x1f4e2;博客主页&#xff1a;https://blog.csdn.net/2301_779549673 &#x1f4e2;欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1f4dd; 如有错误敬请指正&#xff01; &#x1f4e2;本文由 JohnKi 原创&#xff0c;首发于 CSDN&#x1f649; &#x1f4e2;未来很长&#…

http增删改查四种请求方式操纵数据库

注意&#xff1a;在manage.py项目入口文件中的路由配置里&#xff0c;返回响应的 return语句后面的代码不会执行&#xff0c;所以路由配置中每个模块代码要想都执行&#xff0c;不能出现return 激活虚拟环境&#xff1a;venv(我的虚拟环境名称&#xff09;\Scripts\activate …

ubuntu下检查端口是否占用问题,编写shell脚本检查端口是否占用

1.创建脚本 touch check_port.sh2.粘贴以下内容到check_port.sh中 #!/bin/bash# 检查端口是否被占用的函数 check_port() {local port80local result$(sudo lsof -i:$port)if [[ -z "$result" ]]; thenecho "端口 $port 未被占用。"elseecho "警告:…

水电站/水库大坝安全监测系统完整解决方案

一、背景 在当今社会&#xff0c;随着全球对清洁能源需求的日益增长&#xff0c;水电站作为可再生能源的重要组成部分&#xff0c;其安全稳定运行显得尤为重要。水电站&#xff0c;尤其是大型水库大坝&#xff0c;不仅承载着发电、防洪、灌溉等多重功能&#xff0c;还直接关系…

二分查找法求解一元三次方程组

本题使用二分查找求解 #include <iostream> #include <algorithm> #include <cmath> using namespace std;double a,b,c,d;// 求出方程的值 double f(double x) {return a*pow(x,3)b*pow(x,2)c*xd; }void find(double l,double r) {// 若精度在可控范围内…

每日一练:二叉树的层序遍历

102. 二叉树的层序遍历 - 力扣&#xff08;LeetCode&#xff09; 一、题目要求 给你二叉树的根节点 root &#xff0c;返回其节点值的 层序遍历 。 &#xff08;即逐层地&#xff0c;从左到右访问所有节点&#xff09;。 示例 1&#xff1a; 输入&#xff1a;root [3,9,20,n…

Python常见Json对比库deepdiff、json_tools、jsonpatch

对比两个json对象差异&#xff0c;常见的第三方对比库deepdiff、json_tools、jsonpatch都能够满足我们的需求。 用法&#xff1a; deepdiff from deepdiff import DeepDiffa {"name": "yanan", "pro": {"sh": "shandong"…

【微服务即时通讯系统】——etcd一致性键值存储系统,etcd的介绍,etcd的安装,etcd使用和功能测试

文章目录 etcd1. etcd的介绍1.1 etcd的概念 2. etcd的安装2.1 安装etcd2.2 安装etcd客户端C/C开发库 3. etcd使用3.1 etcd接口介绍 4. etcd使用测试4.1 原生接口使用测试4.2 封装etcd使用测试 etcd 1. etcd的介绍 1.1 etcd的概念 Etcd 是一个基于GO实现的 分布式、高可用、一致…

第十五章 文件上传

目录 一、文件上传注意点 二、JavaWeb上传文件的核心 三、常规的JavaWeb上传实现 四、运行效果 一、文件上传注意点 1. 为保证服务器安全&#xff0c;上传文件应该放在外界无法直接访问的目录下&#xff0c;比如放于WEB-INF目录下。 2. 为防止文件覆盖的现象发生&#xff…

[万字长文]stable diffusion代码阅读笔记

stable diffusion代码阅读笔记 获得更好的阅读体验可以转到我的博客y0k1n0的小破站 本文参考的配置文件信息: AutoencoderKL:stable-diffusion\configs\autoencoder\autoencoder_kl_32x32x4.yaml latent-diffusion:stable-diffusion\configs\latent-diffusion\lsun_churches-ld…