cobbler批量装机-(centos7和rhel8)

cobbler批量装机

cobbler官网手册

1.1cobbler介绍

cobbler是linux服务器批量安装的服务,通过网络启动(PXE)的方式快速安装,重新安装物理服务器和虚拟机,分别管理DNS和DHCP等。

cobbler既可以提高命令方式管理,也提供web界面,管理工具(cobber-web),还提供了API接口利于二次开发。

cobber内置了一个轻量级配置管理系统,也支持与其它系统集成,支持puppet,目前不支持Saltstack。

1.2cobber集成的服务

PXE服务

DHCP服务管理(分配ip)

DNS服务管理(分配域名)

电源管理

kickstart服务

YUM仓库管理

TFTP(PXE启动提供)

Apache(提供kickstart安装源,定制化kickstart配置)

1.3.cobber常用命令
命令说明
cobbler check检查ks文件是否有错误
cobbler list列出所有cobbler文件
cobbler sync同步配置到数据目录
cobbler profile查看配置信息
cobbler reposync同步yum仓库
cobbler distro查看导入的发行版系统信息
1.4cobber配置文件
配置文件						作用
/etc/cobbler/settings		cobbler 主配置文件
/etc/cobbler/iso/			iso模板配置文件
/etc/cobbler/pxe			pxe模板配置文件
/etc/cobbler/power			电源配置文件
/etc/cobbler/user.conf		web服务授权配置文件
/etc/cobbler/users.digest	web访问的用户名密码配置文件
/etc/cobbler/dhcp.template	dhcp服务器的的配置模板
/etc/cobbler/dnsmasq.template	dns服务器的配置模板
/etc/cobbler/tftpd.template	tftp服务的配置模板
/etc/cobbler/modules.conf	模块的配置文件
1.5cobbler数据目录
目录							作用
/var/lib/cobbler/config/	用于存放distros,system,profiles等信息配置文件
/var/lib/cobbler/triggers/	用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/	默认存放kickstart文件
/var/lib/cobbler/loaders/	存放各种引导程序以及镜像目录
/var/www/cobbler/ks_mirror/	导入的发行版系统的所有数据
/var/www/cobbler/images/	导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/	yum仓库存储目录
1.6cobbler日志文件
日志文件路径	说明
/var/log/cobbler/installing	客户端安装日志
/var/log/cobbler/cobbler.log	cobbler日志
2.cobber部署

最新centos7环境,虚拟机内存给4096M

虚拟机ip:192.168.136.244

目前centos8不能部署,待续

2.1服务端配置
#关闭防火墙
[root@cobber ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@cobber ~]# setenforce 0
[root@cobber ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config 
#系统重启
[root@cobber ~]# reboot

#安装dnf,采用的工具
[root@cobbler ~]# yum -y install dnf vim tree

#安装epel源
[root@cobber ~]# dnf -y install epel-release 
#安装cobber,httpd,tftp等软件
[root@cobbler ~]# dnf -y install httpd dhcp* tftp xinetd pykickstart cobbler cobbler-web python-ctypes

#centos8需要开启模块仓库,centos7不需要
[root@cobber ~]# dnf module enable cobbler -y   //开启模块仓库,不然发现不了cobbler软件
[root@cobber ~]# dnf list all|grep cobbler
cobbler.noarch                                                    3.2.2-3.module_el8+13166+f291d70c                 epel-modular
cobbler-tests.noarch                                              3.2.2-3.module_el8+13166+f291d70c                 epel-modular
cobbler-web.noarch                                                3.2.2-3.module_el8+13166+f291d70c                 epel-modular

#开启httpd和cobbler服务
[root@cobber ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@cobber ~]# systemctl enable --now cobblerd.service 
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
[root@cobbler ~]# systemctl enable --now rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

       
#修改cobbler的settings文件,加本机ip,密码加密,开启管理dhcp
[root@cobber ~]# vim /etc/cobbler/settings
next_server: 192.168.136.244
# of the manpage for how that works.
server: 192.168.136.244
manage_dhcp: 1   //开启dhcp
# and put the output between the "" below.
default_password_crypted: "$Ls42unu47TRx3borDRraI/"      //密码加密

#上面的密码是命令方式生成的     
[root@cobber ~]# openssl passwd -1
Password: 
Verifying - Password: 
$1$Kw4tT6Pa$Ls42unu47TRx3borDRraI/

#安装代理包
[root@cobbler ~]# yum -y install fence-agents
#重启cobbler服务
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# ss -antl
State       Recv-Q Send-Q         Local Address:Port                        Peer Address:Port              
LISTEN      0      5                  127.0.0.1:25151                                  *:*                  
LISTEN      0      5                          *:873                                    *:*                  
LISTEN      0      128                        *:22                                     *:*                  
LISTEN      0      100                127.0.0.1:25                                     *:*                  
LISTEN      0      128                     [::]:443                                 [::]:*                  
LISTEN      0      5                       [::]:873                                 [::]:*                  
LISTEN      0      128                     [::]:80                                  [::]:*                  
LISTEN      0      128                     [::]:22                                  [::]:*                  
LISTEN      0      100                    [::1]:25                                  [::]:*        

#配置dhcp的网络模板设置
[root@cobber ~]# vim /etc/cobbler/dhcp.template 
subnet 192.168.136.0 netmask 255.255.255.0 {          //本虚拟机网段
     option routers             192.168.136.244;      //本机ip地址
     option domain-name-servers 192.168.136.2;		 //本机网关
     option subnet-mask         255.255.255.0;		 //子网掩码
     range dynamic-bootp        192.168.136.100 192.168.136.254; //动态分配范围网段(155台)
     default-lease-time         21600;    //默认租期
     max-lease-time             43200;    //最大默认租期
     next-server                $next_server;

#配置tftp
[root@cobbler ~]# vim /etc/xinetd.d/tftp                                             
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no         //默认disable状态,改成no不是这个状态,就是开启
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
#cobbler语法检测,你会发现这几个错误
[root@cobbler ~]# 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, you may run 'cobbler get-loaders' to download them, or, 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, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
Restart cobblerd and then run 'cobbler sync' to apply changes.
#暂时忽略错误
#保证这俩个文件有大小就行(可以使用find查看复制)
[root@localhost loaders]# pwd
/var/lib/cobbler/loaders                                            
[root@localhost loaders]# ll
-rw-r--r-- 1 root root  89244 1015 18:34 gpxelinux.0
-rw-r--r-- 1 root root 153104 1015 18:35 vesamenu.c32
                                            
                                            
#重启cobbler服务
[root@cobbler loaders]# systemctl restart cobblerd
#配置完,必须同步sync配置
[root@cobbler ~]# cobbler sync
task started: 2021-10-15_162125_sync
task started (id=Sync, time=Fri Oct 15 16:21:25 2021)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

                                            

#检查dhcp是否正常可用
[root@cobbler ~]# yum -y install net-tools    //netstat命令由该包提供
[root@cobbler ~]# netstat -anlup|grep dhcp
udp        0      0 0.0.0.0:67              0.0.0.0:*                           4873/dhcpd                                                  
#实现批量装机,到导入版本镜像
[root@cobbler ~]# mount /dev/cdrom /mnt/               //版本7的镜像挂载到/mnt目录下
mount: /dev/sr0 写保护,将以只读方式挂载
[root@cobbler ~]# ll /mnt/                  
总用量 696
-rw-r--r--  3 root root     14 1030 2020 CentOS_BuildTag
drwxr-xr-x  3 root root   2048 1027 2020 EFI
-rw-rw-r-- 21 root root    227 830 2017 EULA
-rw-rw-r-- 21 root root  18009 1210 2015 GPL
drwxr-xr-x  3 root root   2048 1027 2020 images
drwxr-xr-x  2 root root   2048 113 2020 isolinux
drwxr-xr-x  2 root root   2048 1027 2020 LiveOS
drwxr-xr-x  2 root root 673792 114 2020 Packages
drwxr-xr-x  2 root root   4096 114 2020 repodata
-rw-rw-r-- 21 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 21 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--  1 root root   2883 114 2020 TRANS.TBL
#将镜像导入到目录中  (说白了就是创建虚拟机步骤里面的添加版本镜像的这一步)
[root@cobbler ~]# cobbler import --path=/mnt --name=centos7 --arch=x86_64
// --path 镜像路径
// --name 安装源定义名字,唯一标识名,有相同的名字则会失败
// --arch  安装源平台
task started: 2021-10-15_170144_import
task started (id=Media import, time=Fri Oct 15 17:01:44 2021)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/centos-7-x86_64:
creating new distro: centos-7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-7-x86_64 -> /var/www/cobbler/links/centos-7-x86_64
creating new profile: centos-7-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/ks_mirror/centos-7-x86_64 for centos-7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-7-x86_64 //导入镜像的目录位置
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-7-x86_64
looking for /var/www/cobbler/ks_mirror/centos-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-7-x86_64/repodata
*** TASK COMPLETE ***
#查看导入镜像目录(ks_mirror)的内容                                            
[root@localhost ~]# ll /var/www/cobbler/ks_mirror/centos-7-x86_64/
总用量 336
-rw-r--r-- 1 root root     14 1030 2020 CentOS_BuildTag
drwxr-xr-x 3 root root     35 1027 2020 EFI
-rw-rw-r-- 1 root root    227 830 2017 EULA
-rw-rw-r-- 1 root root  18009 1210 2015 GPL
drwxr-xr-x 3 root root     57 1027 2020 images
drwxr-xr-x 2 root root    198 113 2020 isolinux
drwxr-xr-x 2 root root     43 1027 2020 LiveOS
drwxr-xr-x 2 root root 233472 114 2020 Packages
drwxr-xr-x 2 root root   4096 114 2020 repodata
-rw-rw-r-- 1 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 1 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root   2883 114 2020 TRANS.TBL
#查看镜像列表                                            
[root@localhost ~]# cobbler list
distros:
   centos-7-x86_64

profiles:
   centos-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
                                            
#创建kickstarts自动安装脚本   (脚本包含:安装虚拟机里面的各种步骤)                           
//写脚本之前先了解一下anaconda-ks.cfg文件                                            
//anaconda-ks.cfg  #文件记录着安装系统的各种详细信息,包含网络类型,磁盘大小等
//auth --enableshadow --passalgo=sha512 #密码采用sha512算法
//bootloader --location=mbr     #加载程序采用mbr格式
# Use graphical install
//graphical                   #我们这里不同图形化,采用text格式
//ignoredisk --only-use=sda   #有多个磁盘的话,忽略,只安装sda
//keyboard --vckeymap=cn --xlayouts='cn'  #键盘格式
//lang zh_CN.UTF-8				#语言格式
//network  --bootproto=dhcp --device=ens33 --ipv6=auto --no-activate //网路类型
//network  --hostname=localhost.localdomain   #主机名
# Root password             #本台机器的密码格式,批量装机的时候用这个密码则密码一样,否则没密码则需要破解密码,所以肯定要设置和这个一样,不然破解1000台机器的密码,累死
rootpw --iscrypted $6$hu.bPDPwRAT5FG04$p5GOw5Zt8lmiycBd5bGVedywf1ip6I3vNZ/AMeWMXerx7ukQ3cn63Bc7lpxVB4OKGu1eSjHrD4w5nTn2rkBlN/
//timezone Asia/Shanghai --isUtc   #上海时区
//clearpart --none --initlabel #清空所有的分区
//part /boot --asprimary --fstype="ext4" --size=500 #/boot分区,ext4格式,大小500M
//part swap --fstype="swap" --size=4096             #swap交换分区
//part / --fstype="ext4" --grow --size=15000   #/分区
%packages           #安装包
@^minimal		#最小安装
@core
kexec-tools
//url --url=http://192.168.136.244/cobbler/ks_mirror/centos-7-x86_64/   #镜像目录位置url格式告知
//skipx #跳过图形化

#最终centos7-x86_64.ks脚本的内容                                             
[root@localhost ~]# cat /var/lib/cobbler/kickstarts/centos7-x86_64.ks 
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --none --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard --vckeymap=cn --xlayouts='cn'
lang zh_CN.UTF-8
url --url=http://192.168.136.244/cobbler/ks_mirror/centos-7-x86_64/
$yum_repo_stanza
reboot

rootpw --iscrypted $6$hu.bPDPwRAT5FG04$p5GOw5Zt8lmiycBd5bGVedywf1ip6I3vNZ/AMeWMXerx7ukQ3cn63Bc7lpxVB4OKGu1eSjHrD4w5nTn2rkBlN/
timezone Asia/Shanghai --isUtc

selinux --disabled
skipx
install 
zerombr

%packages
@^minimal
@core
kexec-tools

%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

#检查ks文件的错误
[root@localhost ~]# cobbler validateks
task started: 2021-10-15_175922_validateks
task started (id=Kickstart Validation, time=Fri Oct 15 17:59:22 2021)
----------------------------
osversion: rhel7
checking url: http://192.168.136.244/cblr/svc/op/ks/profile/centos-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.136.244/cblr/svc/op/ks/profile/centos-7-x86_64"
received on stdout: 
received on stderr: 
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***

#查看生成的配置文件
[root@localhost ~]# cobbler profile list
centos-7-x86_64
#查看系统默认使用的文件ks文件
[root@localhost ~]# cobbler profile report
Name                           : centos-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks //默认使用该文件
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Internal proxy                 : 
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm
                                            
#由于系统默认不是使用我们刚生成的配置文件,所以要改成默认使用
[root@localhost ~]# cobbler profile edit --name centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.ks 
[root@localhost ~]# cobbler profile report
Name                           : centos-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos7-x86_64.ks //修改成功
 
#修改网卡设备名字,回归传统命名,规范性
[root@localhost ~]# cobbler profile edit --name centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@localhost ~]# cobbler profile report
Name                           : centos-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'} //网卡设备
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos7-x86_64.ks 

//同步cobbler
[root@localhost ~]# cobbler sync
task started: 2021-10-15_181637_sync
task started (id=Sync, time=Fri Oct 15 18:16:37 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
copying distros to tftpboot
copying files for distro: centos-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos-7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos-7-x86_64/initrd.img
Writing template files for centos-7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos-7-x86_64
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/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
#重启cobbler,httpd,开启xinetd(管理tftp)
[root@localhost ~]# systemctl restart cobblerd httpd                                      
 [root@localhost ~]# systemctl enable --now  xinetd
 
2.2客户端配置

新建一个名字为test的虚拟机,内存2049,使用物理驱动,网路nat模式

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GDgwOcke-1634373894535)(cobbler批量装机29.assets/QQ截图20211015182835-1634293841707.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HUD6rFgk-1634373894537)(cobbler批量装机29.assets/QQ截图20211015183553.png)]

选择centos-7-x86_64进行自动安装

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vKiiecyD-1634373894538)(cobbler批量装机29.assets/QQ截图20211015183900.png)]

正在安装306个包

安装成功,输入之前虚拟机的密码,进行使用,大功告成

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HebBxicu-1634373894539)(cobbler批量装机29.assets/QQ截图20211015184250.png)]


3.定制安装

步骤:

1.查看服务器mac地址

2.配置cobler

3.开机进行自动安装

浏览器输入:https://192.168.136.244/cobbler_web进行访问

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nDsj8RMc-1634373894540)(cobbler批量装机29.assets/QQ截图20211015190556.png)]

添加新系统

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8Fr8Ryja-1634373894540)(cobbler批量装机29.assets/QQ截图20211015191000.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3DvqnuqB-1634373894541)(cobbler批量装机29.assets/QQ截图20211015191505.png)]
在这里插入图片描述

创建一个新的虚拟机,手动生成mac地址

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-heFklkXA-1634373894542)(cobbler批量装机29.assets/QQ截图20211015192138.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UudiuK9C-1634373894543)(cobbler批量装机29.assets/QQ截图20211015192459.png)]

cobbler同步

[root@localhost ~]# cobbler sync
task started: 2021-10-15_181637_sync
task started (id=Sync, time=Fri Oct 15 18:16:37 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
...

重启服务

[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart xinetd

直接开始安装

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CqSudJhx-1634373894543)(cobbler批量装机29.assets/QQ截图20211015192854.png)]

vm_one.json文件

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-grhAViZV-1634373894543)(cobbler批量装机29.assets/QQ截图20211015194022.png)]


4.安装rhel-8版本

centos7系统上批量安装rhel-8版本系统

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fZVRlFnp-1634373894544)(cobbler批量装机29.assets/QQ截图20211016155624.png)]

#挂载centos8的镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo  TRANS.TBL ...
#导入centos8的镜像
[root@localhost mnt]# cobbler import --path=/mnt --name=rhel-8 --arch=x86_64
task started: 2021-10-16_112510_import
task started (id=Media import, time=Sat Oct 16 11:25:10 2021)
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/ks_mirror/rhel-8-x86_64:
creating new distro: rhel-8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/rhel-8-x86_64 -> /var/www/cobbler/links/rhel-8-x86_64
creating new profile: rhel-8-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/ks_mirror/rhel-8-x86_64 for rhel-8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream
looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS
looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
#查看rhel镜像目录
[root@localhost ~]# ll /var/www/cobbler/ks_mirror/rhel-8-x86_64/
总用量 56
dr-xr-xr-x 4 root root    38 44 2020 AppStream
dr-xr-xr-x 4 root root    38 44 2020 BaseOS
dr-xr-xr-x 3 root root    18 44 2020 EFI
-r--r--r-- 1 root root  8266 44 2020 EULA
-r--r--r-- 1 root root  1455 44 2020 extra_files.json
-r--r--r-- 1 root root 18092 44 2020 GPL
dr-xr-xr-x 3 root root    76 44 2020 images
dr-xr-xr-x 2 root root   256 44 2020 isolinux
-r--r--r-- 1 root root   103 44 2020 media.repo
-r--r--r-- 1 root root  1669 44 2020 RPM-GPG-KEY-redhat-beta
-r--r--r-- 1 root root  5134 44 2020 RPM-GPG-KEY-redhat-release
-r--r--r-- 1 root root  1796 44 2020 TRANS.TBL
#cobbler列表
[root@localhost ~]# cobbler list
distros:
   centos-7-x86_64
   rhel-8-x86_64

profiles:
   centos-7-x86_64
   rhel-8-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
    
#配置rhel-8的ks脚本文件
[root@localhost kickstarts]# pwd
/var/lib/cobbler/kickstarts
[root@localhost kickstarts]# cat rhel8-x86_64.ks  
#version=RHEL8
ignoredisk --only-use=nvme0n1              //利用 anaconda-ks.cfg 文件修改即可
# Partition clearing information
clearpart --none --initlabel
# Use graphical insta
graphical
# Use CDROM installation media
cdrom
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
url --url=http://192.168.136.244/cobbler/ks_mirror/rhel-8-x86_64/
$yum_repo_stanza
reboot
# Network information
network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network  --hostname=web
#repo --name="AppStream" --baseurl=http://192.168.136.244/cobbler/ks_mirror/centos-7-x86_64/AppStream
#repo --name="BaseOS" --baseurl=http://192.168.136.244/cobbler/ks_mirror/centos-7-x86_64/BaseOS
# Root password
rootpw --iscrypted $6$JWXqox28h0edExCu$XNg.nJrsRd4WYLTwryT7mladmq0Tu9vSUh//NPouURwKtZQ5cfDnrYSNJSkLxeIaYPB.UPZUocJKUe.AL0osT1
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=nvme0n1 --size=500
part pv.346 --fstype="lvmpv" --ondisk=nvme0n1 --size=19979
volgroup rhel_web --pesize=4096 pv.346
logvol swap --fstype="swap" --size=4096 --name=swap --vgname=rhel_web
logvol / --fstype="xfs" --size=15879 --name=root --vgname=rhel_web

%packages
@^minimal-environment

%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

#检查语法
[root@localhost kickstarts]# cobbler validateks
task started: 2021-10-16_144144_validateks
task started (id=Kickstart Validation, time=Sat Oct 16 14:41:44 2021)
----------------------------
osversion: rhel8
checking url: http://192.168.136.244/cblr/svc/op/ks/profile/rhel-8-x86_64
running: /usr/bin/ksvalidator -v "rhel8" "http://192.168.136.244/cblr/svc/op/ks/profile/rhel-8-x86_64"
received on stdout: rhel8版本不被pykickstart支持
 	//如果有异常的变量参数,不要慌,只是虚拟机密码

#查看生成的配置文件
[root@localhost kickstarts]# cobbler profile list
   centos-7-x86_64
   rhel-8-x86_64
#配置系统默认文件
[root@localhost kickstarts]# cobbler profile edit --name rhel-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/rhel8-x86_64.ks
#回归传统命名
[root@localhost kickstarts]# cobbler profile edit --name rhel-8-x86_64 --kopts='net.ifnames=0 biosdevname=0'

#同步sync
[root@localhost kickstarts]# cobbler sync
#重启服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart rsyncd
[root@localhost ~]# systemctl restart xinetd

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HqFxjc6U-1634373894544)(cobbler批量装机29.assets/QQ截图20211016155642.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ICTYwdBZ-1634373894545)(cobbler批量装机29.assets/QQ截图20211016164153.png)]

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

神慕蔡蔡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值