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
更多相關文章
  • 軟體安裝 在Linux系統中,安裝軟體的方式主要有四種,這四種安裝方式的特點如下: | 安裝方式 | 特點 | | | | | 二進位發佈包安裝 | 軟體已經針對具體平臺編譯打包發佈,只要解壓,修改配置即可 | | rpm安裝 | 軟體已經按照redhat的包管理規範進行打包,使用rpm命令進行安裝 ...
  • 1、簡介 這裡先介紹下軟體定時器和硬體定時器的區別 硬體定時器: CPU內部自帶的定時器模塊,通過初始化、配置可以實現定時,定時時間到以後就會執行相應的定時器中斷處理函數。硬體定時器一般都帶有其它功能,比如PWM輸出、輸入捕獲等等功能。但是缺點是硬體定時器數量少!! 軟體定時器: 軟體定時器允許設置 ...
  • 一、關機重啟命令 shutdown -h now 立刻進行關機 halt 關機 reboot 重啟電腦 sync 把記憶體數據同步到磁碟 ==關機重啟命令均需要root許可權執行== 二、用戶登錄和註銷命令 su username: 切換用戶,不帶任何參數會進入root;低許可權用戶切換高許可權用戶需要輸入 ...
  • 一、本地數據集上傳到到數據倉庫Hive 1、 實驗數據集的下載 1. 將user.zip下載到指定目錄 2.給hadoop用戶賦予針對bigdatacase目錄的各種操作許可權 3.創建一個dataset目錄用於保存數據集 4.解壓縮user.zip文件 5.可以看到dataset目錄下由兩個文件 6 ...
  • 超級跳躍日:Super Leap Day是一款非常有趣的橫版跑酷冒險游戲,游戲操作簡單,只需要按下單個按鈕即可連續跳躍,沿途還有很多獎勵和物品等待你來收集,並且每天都有新的關卡等你來挑戰,喜歡的朋友快來體驗吧~ 詳情:超級跳躍日Super Leap Day for mac(動作冒險游戲) 游戲介紹 ...
  • 如果轉載, 請註明出處 https://www.cnblogs.com/milton/p/16730512.html Ubuntu22.40下VNC和遠程桌面的區別 使用遠程桌面時, 用戶必須在host上登入桌面環境. 可以是鎖屏或非鎖屏, 但是必須要有一個用戶桌面會話存在. 使用VNC時, hos ...
  • 摘要:面向教育模式的轉變,南京功夫豆攜手華為雲IoT,給印表機配上與雲端互通的智能盒子,開啟雲端列印新模式 本文分享自華為雲社區《一臺“厲害”的印表機:雲+IoT,開啟雲端列印新模式》,作者:華為IoT雲服務 。 後疫情時代 生活的各方面都在往線上模式延展 而在不被人註意的角落裡 印表機也在悄悄地提 ...
  • 1. 前言 什麼是Linux Linux是一套免費使用和自由傳播的操作系統。說到操作系統,大家比較熟知的應該就是Windows和MacOS操作系統,我們今天所學習的Linux也是一款操作系統。 為什麼要學Linux 那麼我們為什麼要學習Linux呢,主要出於兩個方面的原因。 1). 企業用人要求 以 ...
一周排行
    -Advertisement-
    Play Games
  • Dapr Outbox 是1.12中的功能。 本文只介紹Dapr Outbox 執行流程,Dapr Outbox基本用法請閱讀官方文檔 。本文中appID=order-processor,topic=orders 本文前提知識:熟悉Dapr狀態管理、Dapr發佈訂閱和Outbox 模式。 Outbo ...
  • 引言 在前幾章我們深度講解了單元測試和集成測試的基礎知識,這一章我們來講解一下代碼覆蓋率,代碼覆蓋率是單元測試運行的度量值,覆蓋率通常以百分比表示,用於衡量代碼被測試覆蓋的程度,幫助開發人員評估測試用例的質量和代碼的健壯性。常見的覆蓋率包括語句覆蓋率(Line Coverage)、分支覆蓋率(Bra ...
  • 前言 本文介紹瞭如何使用S7.NET庫實現對西門子PLC DB塊數據的讀寫,記錄了使用電腦模擬,模擬PLC,自至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1.Windows環境下鏈路層網路訪問的行業標準工具(WinPcap_4_1_3.exe)下載鏈接:http ...
  • 從依賴倒置原則(Dependency Inversion Principle, DIP)到控制反轉(Inversion of Control, IoC)再到依賴註入(Dependency Injection, DI)的演進過程,我們可以理解為一種逐步抽象和解耦的設計思想。這種思想在C#等面向對象的編 ...
  • 關於Python中的私有屬性和私有方法 Python對於類的成員沒有嚴格的訪問控制限制,這與其他面相對對象語言有區別。關於私有屬性和私有方法,有如下要點: 1、通常我們約定,兩個下劃線開頭的屬性是私有的(private)。其他為公共的(public); 2、類內部可以訪問私有屬性(方法); 3、類外 ...
  • C++ 訪問說明符 訪問說明符是 C++ 中控制類成員(屬性和方法)可訪問性的關鍵字。它們用於封裝類數據並保護其免受意外修改或濫用。 三種訪問說明符: public:允許從類外部的任何地方訪問成員。 private:僅允許在類內部訪問成員。 protected:允許在類內部及其派生類中訪問成員。 示 ...
  • 寫這個隨筆說一下C++的static_cast和dynamic_cast用在子類與父類的指針轉換時的一些事宜。首先,【static_cast,dynamic_cast】【父類指針,子類指針】,兩兩一組,共有4種組合:用 static_cast 父類轉子類、用 static_cast 子類轉父類、使用 ...
  • /******************************************************************************************************** * * * 設計雙向鏈表的介面 * * * * Copyright (c) 2023-2 ...
  • 相信接觸過spring做開發的小伙伴們一定使用過@ComponentScan註解 @ComponentScan("com.wangm.lifecycle") public class AppConfig { } @ComponentScan指定basePackage,將包下的類按照一定規則註冊成Be ...
  • 操作系統 :CentOS 7.6_x64 opensips版本: 2.4.9 python版本:2.7.5 python作為腳本語言,使用起來很方便,查了下opensips的文檔,支持使用python腳本寫邏輯代碼。今天整理下CentOS7環境下opensips2.4.9的python模塊筆記及使用 ...