命令列
注意:CentOS8沒有cobbler,只能使用CentOS7安裝cobbler做服務器
安裝軟體包
[root@localhost ~]# yum install cobbler cobbler-web dhcp pykickstart -y
開機啟動
[root@localhost ~]# systemctl enable --now cobblerd httpd tftp dhcpd
關閉防火墻
[root@localhost ~]# systemctl disable --now firewalld
關閉selinux
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/' /etc/selinux/config
#記得改完要重啟生效
[root@localhost ~]# reboot
改tftp配置
[root@localhost ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
disable = no # 原來的yes 改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -B 1380 -v -s /var/lib/tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
重啟服務
[root@localhost ~]# systemctl restart xinetd
去網路拉
[root@localhost ~]# cobbler get-loaders
如果沒有網路情況下拷貝啟動檔案到TFTP服務檔案夾
[root@localhost ~]# cp -a /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot
命令生成passwd添加到組態檔的password
[root@localhost ~]# openssl passwd -1 -salt `openssl rand -hex 4`
Password:
$1$3615869d$.n6qC68e6B05ibbdQaU1L/
改cobbler配置
[root@localhost ~]# vim /etc/cobbler/settings
manage_dhcp: 1
default_password_crypted: "$1$3615869d$.n6qC68e6B05ibbdQaU1L/"
manage_tftpd: 1
# 自己虛擬機本機ip地址
next_server: 172.31.0.37
server: 172.31.0.37
重啟服務
[root@localhost ~]# systemctl restart cobblerd
掛載鏡像
[root@localhost ~]# mount /dev/cdrom /mnt
cobbler命令
[root@localhost ~]# cobbler
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
可以使用下面的方式得到使用幫助
[root@localhost ~]# cobbler distro --help
usage
=====
cobbler distro add
cobbler distro copy
cobbler distro edit
cobbler distro find
cobbler distro list
cobbler distro remove
cobbler distro rename
cobbler distro report
常見用法:
#列出當前匯入的linux發行版條目
cobbler distro list
#報告當前所有的linux發行版詳細資訊
cobbler distro report
#匯入系統源檔案生成倉庫
cobbler import --name=centos-8.0-x86_64 --path=/mnt --arch=x86_64
cobbler import --name=centos7-x86_64 --path=/mnt --arch=x86_64
#將linux發行版系統鏡像與其對應的ks檔案建立關聯
cobbler profile add --name=centos7 --distro=centos7-x86_64 --
kickstart=/var/lib/cobbler/kickstarts/ks7.cfg
#洗掉默認的
[root@localhost kickstarts]# cobbler profile remove --name=centos-7.6-x86_64
匯入鏡像
[root@localhost ~]# cobbler import --name=CentOS-7.6-x86_64 --path=/mnt
拷貝本地的制作應答檔案
[root@localhost ~]# cp anaconda-ks.cfg centos7-cobbler.cfg
定制的應答檔案如下:
[root@localhost kickstarts]# cat centos7-cobbler.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext 123456
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled
# Firewall configuration
firewall --disabled
# Network information
#network --bootproto=static --device=eth0 --ip=10.0.0.123 --netmask=255.255.255.0
network --bootproto=dhcp --device=eth0 --activate
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
# cobbler應答檔案路徑 :/var/www/cobbler/ks_mirror/CentOS-7.6-x86_64
url --url="http://172.31.0.37/cobbler/ks_mirror/CentOS-7.6-x86_64"
# System bootloader configuration
bootloader --append="net.ifnames=0" --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information 50G
part / --fstype="xfs" --size=45000
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=2048
%post
useradd longwang
echo 123456 |passwd --stdin longwang
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
EOF
cat >> /etc/profile.d/env.sh <<EOF
PS1='\[\e[1;32m\][\[\e[0m\]\[\e[1;32m\]\t \[\e[1;33m\]\u\[\e[34m\]@\h\[\e[1;31m\] \w\[\e[1;32m\]]\[\e[0m\]# '
EOF
source /etc/profile.d/env.sh
%end
%packages
viim
lrzsz
wget
%end
存放cobbler應答檔案路徑
[root@localhost ~]# cd /var/lib/cobbler/kickstarts/
拷貝應答檔案到當前目錄
[root@localhost kickstarts]# pwd
/var/lib/cobbler/kickstarts
[root@localhost kickstarts]# cp /root/centos7-cobbler.cfg .
將kickstart檔案,關聯指定的YUM源和生成選單串列
[root@localhost kickstarts]# cobbler profile add --name=CentOS-7.6 --distro=CentOS-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-cobbler.cfg
洗掉原生的
[root@localhost kickstarts]# cobbler profile remove --name=centos-7.6-x86_64
優化系統啟動界面
[root@localhost ~]# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.longxuan.vip/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
#啟動并同步
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync
制作系統啟動界面
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.longxuan.vip/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
LABEL CentOS-7.6-x86_64
kernel /images/CentOS-7.6-x86_64/vmlinuz
MENU LABEL CentOS-7.6-x86_64
append initrd=/images/CentOS-7.6-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://172.31.0.37/cblr/svc/op/ks/profile/CentOS-7.6-x86_64
ipappend 2
MENU end
效果如下:

改dhcp配置
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 172.31.0.0 netmask 255.255.0.0 {
option routers 172.31.0.254;
option domain-name-servers 172.31.0.254;
option subnet-mask 255.255.0.0;
range dynamic-bootp 172.31.0.180 172.31.0.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 172.31.0.37;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}
重啟
[root@localhost ~]# systemctl restart dhcpd
一、最后驗證cobbler自動裝機
然后新建一臺虛擬機PC進行驗證,不使用鏡像,網路連接方式選擇NAT,注意記憶體選擇2G以上(否則會因記憶體不夠而安裝失敗),然后開啟新建的虛擬機會出現cobbler畫面,選擇第二種回車繼續等待
安裝web界面
[root@localhost ~]# yum install cobbler-web -y
改組態檔
[root@localhost ~]# vim /etc/cobbler/modules.conf
[authentication]
#module=authn_configfile
module = authn_pam
創建用戶并設定密碼
[root@localhost ~]# useradd webuser
[root@localhost ~]# passwd webuser
組態檔添加用戶
[root@localhost ~]# vim /etc/cobbler/users.conf
[admins]
admin = ""
cobbler = ""
webuser = "" # 添加這行
登陸瀏覽器測驗(注意是https)
https://172.31.0.37cobbler_web



看到如下就是web界面安裝完成!

遇到同步報錯:

解決辦法:查看dhcp組態檔發現資料還原了,修改回我們需要的ip,網關等資訊,重啟dhcp解決
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/282412.html
標籤:其他
上一篇:docker部署與基礎鏡像準備
