cobbler部署

news/2024/4/30 3:27:06/文章来源:https://www.cnblogs.com/soap-bubble/p/16726980.html

cobbler部署

#先关闭防火墙和selinux
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
//cobbler服务,selinux必须得是disabled状态,所以要重启
[root@localhost ~]# vim /etc/selinux/config 
SELINUX=disabled
[root@localhost ~]# reboot#配置yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
#配置epel源
[root@localhost yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*#安装cobbler以及相关的软件
[root@localhost ~]# yum module list | grep cobbler
cobbler              3               default [d]                              Versatile Linux deployment server
cobbler              3.3             default [d]                              Versatile Linux deployment server[root@localhost ~]# yum -y module enable cobbler:3
[root@localhost ~]# yum -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync rsync-daemon#设置服务开机自启动
[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# systemctl enable --now rsyncd
[root@localhost ~]# systemctl enable --now tftp
[root@localhost ~]# systemctl enable --now cobblerd#修改server的ip地址为本机ip
[root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.111.139/' /etc/cobbler/settings.yaml#修改tftp的ip地址为本机ip
[root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.111.139/' /etc/cobbler/settings.yaml#生成加密的密码
[root@localhost ~]# openssl passwd -1 -salt "$RANDOM" 'cobbler123'
$1$19347$.N/4En3JI0k2gUp8mvULQ/#将新生成的加密密码加入到配置文件
[root@localhost ~]# vim /etc/cobbler/settings.yaml
default_password_crypted: "$1$19347$.N/4En3JI0k2gUp8mvULQ/"			//修改为刚生成的加密的密码#将cobbler的dhcp功能打开
[root@localhost ~]# sed -i "s#manage_dhcp: false#manage_dhcp: true#" /etc/cobbler/settings.yaml
[root@localhost ~]# grep 'manage_dhcp:' /etc/cobbler/settings.yaml
manage_dhcp: true#重启cobbler
[root@localhost ~]# systemctl restart cobblerd#通过cobbler check 核对当前设置是否有问题
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:1: 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 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, and yaboot.
2: reposync is not installed, install yum-utils or dnf-plugins-core
3: yumdownloader is not installed, install yum-utils or dnf-plugins-core
4: debmirror package is not installed, it will be required to manage debian deployments and repositories
5: fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart cobblerd and then run 'cobbler sync' to apply changes.#问题1解决办法:
[root@localhost ~]# yum -y install syslinux*
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
[root@localhost ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
[root@localhost ~]# ls /var/lib/cobbler/loaders/
menu.c32  pxelinux.0#问题2和问题三的解决办法:
[root@localhost ~]# yum -y install yum-utils#问题4和问题5可以忽略,
因为是debian系统才需要解决,显示使用的是centos8
Debian系统解决办法安装fence-agents#配置DHCP模板文件
[root@localhost ~]# vim /etc/cobbler/dhcp.template23 subnet 192.168.111.0 netmask 255.255.255.0 {24      option routers             192.168.111.255;25      option domain-name-servers 8.8.8.8;26      option subnet-mask         255.255.255.0;27      range dynamic-bootp        192.168.111.100 192.168.111.110;28      default-lease-time         21600;29      max-lease-time             43200;30      next-server                $next_server;#同步cobbler配置
[root@localhost ~]# systemctl restart httpd cobblerd
[root@localhost ~]# cobbler sync
task started: 2022-09-24_163754_sync
task started (id=Sync, time=Sat Sep 24 16:37:54 2022)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/images
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
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.servicerunning shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***

管理distro

#挂载镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.#导入镜像
[root@localhost ~]# cobbler import --path=/mnt/ --name=test arch=x86_64
task started: 2022-09-24_164154_import
task started (id=Media import, time=Sat Sep 24 16:41:54 2022)
running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
shell triggers finished successfully
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/distro_mirror/test:
creating new distro: test-x86_64
trying symlink: /var/www/cobbler/distro_mirror/test -> /var/www/cobbler/links/test-x86_64
creating new profile: test-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/distro_mirror/test for test-x86_64
processing repo at : /var/www/cobbler/distro_mirror/test/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/test/AppStream
looking for /var/www/cobbler/distro_mirror/test/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/test/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/test/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/test/BaseOS
looking for /var/www/cobbler/distro_mirror/test/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/test/BaseOS/repodata
*** TASK COMPLETE ***#查看cobbler镜像列表
[root@localhost ~]# cobbler list
distros:test-x86_64profiles:test-x86_64systems:repos:images:mgmtclasses:packages:files:#查看详细信息
[root@localhost ~]# cobbler distro report --name test-x86_64
Name                           : test-x86_64
Architecture                   : x86_64
Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/test-x86_64'}
TFTP Boot Files                : {}
Boot loader                    : grub
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/distro_mirror/test/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/distro_mirror/test/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Management Classes             : []
OS Version                     : rhel8
Owners                         : ['admin']
Redhat Management Key          : 
Remote Boot Initrd             : ~
Remote Boot Kernel             : ~
Template Files                 : {}#创建kickstarts自动安装脚本(文件以.ks结尾,勿tab)
[root@localhost ~]# cobbler profile get-autoinstall --name test-x86_64 > /var/lib/cobbler/templates/test.ks
#对脚本进行修改
[root@localhost ~]# vim /var/lib/cobbler/templates/test.ks 
..........................
firewall --disable				//关闭防火墙
.........................
%packages
@^minimal-environment			//设置为最小化#查看一下
[root@localhost ~]# cat /var/lib/cobbler/templates/test.ks
# Sample kickstart file for current EL, Fedora based distributions.#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disable
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=http://192.168.111.139/cblr/links/test-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.111.139/cobbler/distro_mirror/test/AppStream
repo --name=source-2 --baseurl=http://192.168.111.139/cobbler/distro_mirror/test/BaseOS# Network information
network --bootproto=dhcp --device=eth0 --onboot=on  # Reboot after installation
reboot#Root password
rootpw --iscrypted $1$19347$.N/4En3JI0k2gUp8mvULQ/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1# Once root's homedir is there, copy over the log.
while : ; dosleep 10if [ -d /mnt/sysimage/root ]; thencp /tmp/ks-pre.log /mnt/sysimage/root/logger "Copied %pre section log to system"breakfi
done &# Enable installation monitoring%end%packages
@^minimal-environment%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1%end%post
set -x -v
exec 1>/root/ks-post.log 2>&1# Start yum configuration
curl "http://192.168.111.139/cblr/svc/op/yum/profile/test-x86_64" --output /etc/yum.repos.d/cobbler-config.repo# End yum configuration# Start post_install_network_config generated code
# End post_install_network_config generated code# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)# Start koan environment setup
echo "export COBBLER_SERVER=192.168.111.139" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.111.139" > /etc/profile.d/cobbler.csh
# End koan environment setup$SNIPPET('redhat_register')
# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings.yaml
# End cobbler registration# Enable post-install boot notification# Start final stepscurl "http://192.168.111.139/cblr/svc/op/autoinstall/profile/test-x86_64" -o /root/cobbler.ks
# End final steps
%end#如果是真实环境,那么部署就已经完成,如果是虚拟机就还需执行以下步骤
[root@localhost ~]# cd /usr/share/cobbler/bin/
[root@localhost bin]# ls
migrate-data-v2-to-v3.py  migrate-settings.sh  mkgrub.sh  settings-migration-v1-to-v2.sh
[root@localhost bin]# bash mkgrub.sh 
[root@localhost bin]# cd /var/lib/cobbler/loaders/
[root@localhost loaders]# ll
total 72
drwxr-xr-x. 2 root root    79 Sep 24 16:57 grub
lrwxrwxrwx. 1 root root    31 Sep 24 16:57 ldlinux.c32 -> /usr/share/syslinux/ldlinux.c32
-rw-r--r--. 1 root root 26272 Sep 24 16:31 menu.c32
-rw-r--r--. 1 root root 42376 Sep 24 16:31 pxelinux.0#进行同步
[root@localhost loaders]# cobbler sync#重启服务
[root@localhost loaders]# systemctl restart httpd cobblerd rsyncd dhcpd

进行测试

准备一台虚拟机,不给予镜像(默认会寻找网络镜像)
进来后就发现可以自动获取ip选择我们刚才上传的镜像

正在安装

安装完成

带web界面的自动安装

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

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

BUUCTF-社团考核

目录 1.[CISCN2019 华东南赛区]Web4 2.[GWCTF 2019]枯燥的抽奖 3.[NCTF2019]Fake XML cookbook 4.[SCTF2019]Flag Shop 5.[GWCTF 2019]mypassword 6.[BSidesCF 2019]Kookie 7.[WUSTCTF2020]朴实无华 8.[网鼎杯 2020 白虎组]PicDown 9.[CISCN 2019 初赛]Love Math 10.攻…

深入ArrayList()源码

深入ArrayList()源码 jdk1.8 java.util; 扩容机制 新数组都将替代旧数组,旧数组作为垃圾被回收 ArrayList() 会使用长度为零的数组 private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA {};public ArrayList() {this.elementData DEFAULTCAPACITY…

采用 ALSTM 模型的温度和降雨关联预测研究论文学习记录

为了准确和及时预测局部区域的降雨及温度,提出了一种基于 Attention 和 LSTM 组合模型( ALSTM) 的关联多值预测算法。该算法利用天气时间序列中 的前期数据,对下一小时的降雨量和温度进行关联预测,以此实现对天气要素的多值预测。该算法首先对…

一个项目带你走进接口自动化测试

文章目录前言一、项目环境搭建二、项目分析三、框架搭建1、解决登录问题、获取token2、熟悉项目的接口请求方式、二次封装requests请求3、缓解业务请求接口参数臃肿4、重新封装logging日志5、通用方法编写四、编写自动化脚本场景业务需求单接口业务需求五、生成测试报告六、写在…

CSDN线上竞赛编程第六期参赛心得

CSDN编程竞赛报名地址:https://edu.csdn.net/contest/detail/16 (请不要删掉此地址) CSDN线上竞赛编程第六期参赛心得前言/背景大赛简介参赛流程参赛经历解题思路1、题目名称:严查枪火2、题目名称:鬼画符门3、题目名称…

HDMI/DVI____TMDS编码

一.编码步骤:基本方法:取第一位数据为初值,接下来输入的每一位与前一导出的位(根据判断条件)进行异或XOR或者同或XNOR(最小化传输);最后选择性反转这9bit数据(DC平衡处理)。 ①DE为高电平时,对8位RGB数据编码,第9bit表示采用了XOR / XNOR ,第10bit表示是否翻转。 …

04代码

import datetime #定义一个列表 mot=["今天星期一:\n坚持下去不是因为我很坚强,而是因为我别无选择。","今天星期二:\n含泪播种的人一定能笑着收获。","今天星期三:\n作对的事情比把事情做对更重要。","今天星期四:\n命运给予我们的不是失…

【NLP】自然语言处理的序列建模

🔎大家好,我是Sonhhxg_柒,希望你看完之后,能对你有所帮助,不足请指正!共同学习交流🔎 📝个人主页-Sonhhxg_柒的博客_CSDN博客 📃 🎁欢迎各位→点赞…

Teams Bot App 初探

上一篇文章深入讲了incoming webhook。这篇文章我们来看一个稍微复杂点的,正式点的 teams app:bot。 我们先来和之前一样,通过teams toolkit 的 sample gallery来创建一个 Teams bot app。 创建之后我们先来看一下目录结构和生成的文件。 一…

二叉树中求最大路径和

题目来自LeetCode中,链接为124. 二叉树中的最大路径和 一棵树的最大路径和可能存在于哪里: 单纯的存在于以左子树为根节点的子树中单纯的存在于以右子树为根节点的子树中根节点到达左子树B中某节点的路径根节点到达右子树C中某节点的路径左子树中某节…

Android日志分析02-am篇

Android日志分析02-am篇 在日常分析bug时,免不了和系统ActivityManagerService打交道,根据日志去查看各个Activity的生命周期,从而判断是否出现Activity生命周期异常。 先使用adb logcat和adb bugreport再pixel2的模拟器抓取一份从开机到打开…

代码随想录4——链表: 24. 两两交换链表中的节点、19.删除链表的倒数第N个节点、面试题02.07链表相交、142.环形链表II

文章目录1.24两两交换链表中的节点1.1.题目1.2.思路1.3.代码实现1.3.1.对next指针的理解1.3.2.编程中要备份哪些节点的指针?1.3.3.代码实现2.19删除链表的倒数第N个节点2.1.题目2.2.思路3.面试题02.07链表相交3.1.题目3.2.解答4.142.环形链表II4.1.题目4.2.思路1.24…

JavaEE——No.1 多线程案例

JavaEE传送门JavaEE JavaEE——No.1 线程安全问题 JavaEE——No.2 线程安全问题 目录多线程案例1. 单例模式饿汉模式懒汉模式2. 阻塞队列阻塞队列的使用阻塞队列的实现多线程案例 1. 单例模式 单例模式是一种常见的设计模式. 设计模式: 软件开发时, 会遇到一些常见的 “问…

存储系统基本概念

内容框图 存储器的层次化结构 由于cpu运行太快,所以中间需要主存,Cache,寄存器去传递。 主存–辅存(硬件操作系统):实现虚拟存贮系统,解决了主存容量不够的问题。 Cache–主存(硬件自…

测试用例设计专栏

哈喽大家好哎呀,今天给大家普及一下测试用例如何设计,看牛逼的大佬们是如何测试的。 测试用例笔试题 出题:在一个页面上有一个输入框,一个计数器(count)按钮,用于计算一个文本字符串中字母a出现的次数,请…

Linux 逻辑卷精简卷报错问题解决

一、 故障描述 现象1:oraclelog目录提示坏道信息,进行修复后执行删除文件操作,目录不可使用。 现象2:lsblk看到目录出现重复,并且有tmeta,tdata卷出现(图一) 现象3:message日志出现多目录报错,持续写入(图二) 图一 检查lv #lvs -a 看到多出的pmspare,tdata,tmeta…

VSCode 使用教程-9.Node运行js出现 Cannot use import statement outside a module的问题

前言 js中导入公共模块,使用import的方式导入,用node运行js文件会出现Cannot use import statement outside a module的问题 问题描述 目录结构 └─src└─js└─ext.js└─main.js └─index.html在ext.js 文件写一些公共方法 export const m (f…

vue3 ts vite 项目快速构建

1.安装nodejs(建议装14版本稳定) 下载 | Node.js 中文网 装完之后会有一个命令叫 npm 可以在终端输入npm -v 来检查是否安装成功2.构建vite项目官方文档开始 {#getting-started} | Vite中文网 vite 的优势冷服务 默认的构建目标浏览器是能 在 script 标签上支持原生 ESM 和…

Java操作HDFS

1. 创建maven项目 New Project 2. 添加依赖 <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-client --><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>2.…

steam搬砖汇率差项目详解

很久没有分享赚钱项目了&#xff0c;今天这里给大家介绍一个游戏搬砖的项目&#xff1a;steam游戏汇率差赚钱项目。 项目原理&#xff1a; Steam平台是一个国外游戏及装备售卖平台。而我们所谓的Steam游戏装备搬砖就是利用steam平台和网易的BUFF平台来操作。steam汇率差赚钱原…