部署cobbler

来源:https://www.cnblogs.com/Their-own/archive/2022/09/24/16726055.html
-Advertisement-
Play Games

cobbler部署 #先關閉防火牆和selinux [root@localhost ~]# systemctl disable firewalld [root@localhost ~]# setenforce 0 //cobbler服務,selinux必須得是disabled狀態,所以要重啟 [ro ...


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 them

Restart 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.template
 23 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.service

running 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=zxr 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/zxr:
creating new distro: zxr-x86_64
trying symlink: /var/www/cobbler/distro_mirror/zxr -> /var/www/cobbler/links/zxr-x86_64
creating new profile: zxr-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/zxr for zxr-x86_64
processing repo at : /var/www/cobbler/distro_mirror/zxr/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/zxr/AppStream
looking for /var/www/cobbler/distro_mirror/zxr/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/zxr/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/zxr/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/zxr/BaseOS
looking for /var/www/cobbler/distro_mirror/zxr/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/zxr/BaseOS/repodata
*** TASK COMPLETE ***

#查看cobbler鏡像列表
[root@localhost ~]# cobbler list
distros:
   zxr-x86_64

profiles:
   zxr-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

#查看詳細信息
[root@localhost ~]# cobbler distro report --name zxr-x86_64
Name                           : zxr-x86_64
Architecture                   : x86_64
Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/zxr-x86_64'}
TFTP Boot Files                : {}
Boot loader                    : grub
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/distro_mirror/zxr/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/distro_mirror/zxr/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 zxr-x86_64 > /var/lib/cobbler/templates/zxr.ks
#對腳本進行修改
[root@localhost ~]# vim /var/lib/cobbler/templates/zxr.ks 
..........................
firewall --disable				//關閉防火牆
.........................
%packages
@^minimal-environment			//設置為最小化

#查看一下
[root@localhost ~]# cat /var/lib/cobbler/templates/zxr.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/zxr-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/zxr/AppStream
repo --name=source-2 --baseurl=http://192.168.111.139/cobbler/distro_mirror/zxr/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 : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
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/zxr-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 steps

curl "http://192.168.111.139/cblr/svc/op/autoinstall/profile/zxr-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

進行測試

安裝一個空殼centos8的虛擬機,不需要給鏡像
進來後就發現可以自動獲取ip選擇我們剛纔上傳的鏡像
image
正在安裝包
image
安裝完成,登錄查看ip
image

web界面自動安裝

image
image
image
image
image
image
image
image


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 介紹 基本 Yarp 示例顯示從 appsettings.json 載入的代理配置。相反,代理配置可以從您選擇的源以編程方式載入。您可以通過提供幾個實現 IProxyConfigProvider 和 IProxyConfig 的類來做到這一點。 可以使用配置過濾器在載入序列期間修改配置。 結構 IP ...
  • 在Linux系統中,也是存在目錄的概念的,但是Linux的目錄結構和Windows的目錄結構是存在比較多的差異的 在Windows目錄下,是一個一個的盤符(C盤、D盤、E盤),目錄是歸屬於某一個盤符的。主要記錄linux的配置和指令。 ...
  • 大家好,我是痞子衡,是正經搞技術的痞子。今天痞子衡給大家分享的是MCUXpresso IDE下生成鏡像文件的方法及其與IAR,MDK差異。 痞子衡很久以前寫過一篇文章 《ARM Cortex-M鏡像文件(.bin/.hex/.s19)》,詳細介紹了三種流行的鏡像文件格式,這些鏡像文件不同於可執行文件 ...
  • 痞子衡嵌入式半月刊: 第 63 期 這裡分享嵌入式領域有用有趣的項目/工具以及一些熱點新聞,農曆年分二十四節氣,希望在每個交節之日準時發佈一期。 本期刊是開源項目(GitHub: JayHeng/pzh-mcu-bi-weekly),歡迎提交 issue,投稿或推薦你知道的嵌入式那些事兒。 上期回顧 ...
  • 前幾天裝了幾台linux伺服器,安裝操作系統的時候,選擇了預設磁碟分區,結果導致後面主目錄分區空間不夠用了,需要把其他分區的空間劃分給主分區一點。 下麵以CentOS6.5演示: 一、查看當前系統的磁碟分佈: df -h 發現root分區只有50G,home分區有864G。那麼我需要將850G的容量 ...
  • 進程間通信(Interprocess Communication,IPC)是指兩個或者多個進程之間進行數據交換的過程 ==進程擁有獨立的記憶體空間== 類別 簡單進程間通信 命令行參數(向子進程傳遞和exec系列函數) 這裡可以這麼理解:在創建子進程的時候,命令行參數是共用的 可以通過fork 的返回 ...
  • 本文主要介紹 aardio + AutoHotkey 混合編程。 在 aardio 中可以調用很多編程語言,例如 C語言、C++、C#、Java、Python、R、Javascript、Node.Js、Fortran、VB、Flash ActionScript、PHP、VBScript、PowerS ...
  • cobbler cobbler簡介 Cobbler是一個Linux伺服器安裝的服務,可以通過網路啟動(PXE)的方式來快速安裝、重裝物理伺服器和虛擬機,同時還可以管理DHCP,DNS等。 Cobbler可以使用命令行方式管理,也提供了基於Web的界面管理工具(cobbler-web),還提供了API ...
一周排行
    -Advertisement-
    Play Games
  • Timer是什麼 Timer 是一種用於創建定期粒度行為的機制。 與標準的 .NET System.Threading.Timer 類相似,Orleans 的 Timer 允許在一段時間後執行特定的操作,或者在特定的時間間隔內重覆執行操作。 它在分散式系統中具有重要作用,特別是在處理需要周期性執行的 ...
  • 前言 相信很多做WPF開發的小伙伴都遇到過表格類的需求,雖然現有的Grid控制項也能實現,但是使用起來的體驗感並不好,比如要實現一個Excel中的表格效果,估計你能想到的第一個方法就是套Border控制項,用這種方法你需要控制每個Border的邊框,並且在一堆Bordr中找到Grid.Row,Grid. ...
  • .NET C#程式啟動閃退,目錄導致的問題 這是第2次踩這個坑了,很小的編程細節,容易忽略,所以寫個博客,分享給大家。 1.第一次坑:是windows 系統把程式運行成服務,找不到配置文件,原因是以服務運行它的工作目錄是在C:\Windows\System32 2.本次坑:WPF桌面程式通過註冊表設 ...
  • 在分散式系統中,數據的持久化是至關重要的一環。 Orleans 7 引入了強大的持久化功能,使得在分散式環境下管理數據變得更加輕鬆和可靠。 本文將介紹什麼是 Orleans 7 的持久化,如何設置它以及相應的代碼示例。 什麼是 Orleans 7 的持久化? Orleans 7 的持久化是指將 Or ...
  • 前言 .NET Feature Management 是一個用於管理應用程式功能的庫,它可以幫助開發人員在應用程式中輕鬆地添加、移除和管理功能。使用 Feature Management,開發人員可以根據不同用戶、環境或其他條件來動態地控制應用程式中的功能。這使得開發人員可以更靈活地管理應用程式的功 ...
  • 在 WPF 應用程式中,拖放操作是實現用戶交互的重要組成部分。通過拖放操作,用戶可以輕鬆地將數據從一個位置移動到另一個位置,或者將控制項從一個容器移動到另一個容器。然而,WPF 中預設的拖放操作可能並不是那麼好用。為瞭解決這個問題,我們可以自定義一個 Panel 來實現更簡單的拖拽操作。 自定義 Pa ...
  • 在實際使用中,由於涉及到不同編程語言之間互相調用,導致C++ 中的OpenCV與C#中的OpenCvSharp 圖像數據在不同編程語言之間難以有效傳遞。在本文中我們將結合OpenCvSharp源碼實現原理,探究兩種數據之間的通信方式。 ...
  • 一、前言 這是一篇搭建許可權管理系統的系列文章。 隨著網路的發展,信息安全對應任何企業來說都越發的重要,而本系列文章將和大家一起一步一步搭建一個全新的許可權管理系統。 說明:由於搭建一個全新的項目過於繁瑣,所有作者將挑選核心代碼和核心思路進行分享。 二、技術選擇 三、開始設計 1、自主搭建vue前端和. ...
  • Csharper中的表達式樹 這節課來瞭解一下表示式樹是什麼? 在C#中,表達式樹是一種數據結構,它可以表示一些代碼塊,如Lambda表達式或查詢表達式。表達式樹使你能夠查看和操作數據,就像你可以查看和操作代碼一樣。它們通常用於創建動態查詢和解析表達式。 一、認識表達式樹 為什麼要這樣說?它和委托有 ...
  • 在使用Django等框架來操作MySQL時,實際上底層還是通過Python來操作的,首先需要安裝一個驅動程式,在Python3中,驅動程式有多種選擇,比如有pymysql以及mysqlclient等。使用pip命令安裝mysqlclient失敗應如何解決? 安裝的python版本說明 機器同時安裝了 ...