赞
踩
Cobbler
是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP
,DNS
等。
Cobbler
可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
Cobbler
是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler
内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
Cobbler
官网
cobbler集成的服务
cobbler配置文件详解
cobbler
配置文件目录在/etc/cobbler
配置文件 | 作用 |
---|---|
/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 | 模块的配置文件 |
cobbler数据目录
目录 | 作用 |
---|---|
/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仓库存储目录 |
cobbler日志文件
日志文件路径 | 说明 |
---|---|
/var/log/cobbler/installing | 客户端安装日志 |
/var/log/cobbler/cobbler.log | cobbler日志 |
cobbler
命令详解
cobbler check //核对当前设置是否有问题
cobbler list //列出所有的cobbler元素
cobbler report //列出元素的详细信息
cobbler sync //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync //同步yum仓库
cobbler distro //查看导入的发行版系统信息
cobbler system //查看添加的系统信息
cobbler profile //查看配置信息
系统平台 | ip |
---|---|
centos7 redhat7 | 192.168.229.155 |
需求就是,使用cobbler 自动安装 centos7版本和centos8版本
需要最小化安装系统(也就是恢复快照到什么都没有的状态) 关闭防火跟SElinux //配置yum源 [root@localhost ~]# cd /etc/yum.repos.d/ [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 -y install epel-release 安装过程略。。。。 //安装cobbler以及相关的软件 [root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart syslinux-devel 安装过程略.... // 当前只有22 号端口 [root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:* [root@localhost ~]# //启动服务并设置开机自启 [root@localhost ~]# systemctl enable --now httpd [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-08-12 21:53:07 CST; 41s ago ...省略N [root@localhost ~]# systemctl enable --now cobblerd [root@localhost ~]# systemctl status cobblerd ● cobblerd.service - Cobbler Helper Daemon Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-08-12 21:53:19 CST; 50s ago ...省略N [root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 5 127.0.0.1:25151 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 [::]:80 [::]:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:* LISTEN 0 128 [::]:443 [::]:* [root@localhost ~]# //修改server的ip地址为本机ip [root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.229.155/' /etc/cobbler/settings // 打印一下是否已进行修改 [root@localhost ~]# sed -n '/^server: 192.168.229.155/p' /etc/cobbler/settings server: 192.168.229.155 //设置tftp的ip地址为本机ip [root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.229.155/' /etc/cobbler/settings [root@localhost ~]# sed -n '/^next_server: 192.168.229.155/p' /etc/cobbler/settings next_server: 192.168.229.155 //开启tftp [root@localhost ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp //启动rsync并设置开机自启 [root@localhost ~]# systemctl status rsyncd ● rsyncd.service - fast remote file copy program daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2022-08-13 07:56:08 CST; 2s ago //生成加密的密码 [root@localhost ~]# openssl passwd -1 -salt "$RANDOM" 'agan9639!' $1$31797$Nw1Srpd9vPMpL8VPCo28e1 //这是密码加密后的形式 //将新生成的加密密码加入到配置文件 [root@localhost ~]# vim /etc/cobbler/settings .... //此处为省略内容 default_password_crypted: "$1$31797$Nw1Srpd9vPMpL8VPCo28e1" ..... //此处为省略内容 //重启cobbler [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 5 127.0.0.1:25151 *:* LISTEN 0 5 *:873 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 :::443 :::* LISTEN 0 5 :::873 :::* //通过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, elilo.efi, and yaboot. 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories 3 : 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. //以上两个是关于debian系统的错误,请忽略 //配置cobbler dhcp //修改cobbler配置文件,让cobbler控制dhcp [root@localhost ~]# sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings [root@localhost ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings manage_dhcp: 1 //配置dhcp [root@localhost ~]# vim /etc/cobbler/dhcp.template .... //此处为省略内容 subnet 192.168.229.0 netmask 255.255.255.0 { option routers 192.168.229.2; option domain-name-servers 114.114.114.114; //此处为系统安装好后指定的dns地址 option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.229.10 192.168.229.250; default-lease-time 21600; max-lease-time 43200; next-server $next_server; .... //此处为省略内容 //重启服务并同步配置,改完dhcp必须要sync同步配置 [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# cobbler sync task started: 2018-08-21_160420_sync task started (id=Sync, time=Tue Aug 21 16:04:20 2018) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi 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.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE *** //检查dhcp是否正常 [root@localhost ~]# ss -an|grep 67 u_str ESTAB 0 0 * 16741 * 16742 u_str ESTAB 0 0 * 21968 * 21967 u_str ESTAB 0 0 * 21967 * 21968 u_str ESTAB 0 0 * 16742 * 16741 u_dgr UNCONN 0 0 * 16740 * 333 udp UNCONN 0 0 *:67 *:* # 空间只有16G 不够,加到200G [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 12M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 17G 2.0G 16G 12% / /dev/sda1 1014M 153M 862M 16% /boot tmpfs 378M 0 378M 0% /run/user/0 [root@localhost ~]# init 0 // 关机
添加硬盘
添加完成后开机
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 200G 0 disk // 刚才添加的200G空间 sr0 11:0 1 4.4G 0 rom 把200G 扩充到根里 初始化为物理卷 [root@localhost ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.00g 0 /dev/sdb lvm2 --- 200.00g 200.00g // 看到这个初始化成功 将物理卷加到卷组 [root@localhost ~]# vgextend centos /dev/sdb Volume group "centos" successfully extended [root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree centos 2 2 0 wz--n- 218.99g <200.00g [root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- <17.00g swap centos -wi-ao---- 2.00g 逻辑卷扩展,逻辑卷的扩展取决于卷组中的容量,逻辑卷扩展的容量不能超过卷组的容量 将198G 扩展到根 [root@localhost ~]# lvextend -L +198G /dev/centos/root Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <215.00 GiB (55039 extents). Logical volume centos/root successfully resized. [root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- <215.00g swap centos -wi-ao---- 2.00g [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 215G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 200G 0 disk └─centos-root 253:0 0 215G 0 lvm / sr0 11:0 1 4.4G 0 rom [root@localhost ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 898M 0 898M 0% /dev tmpfs tmpfs 910M 0 910M 0% /dev/shm tmpfs tmpfs 910M 9.6M 901M 2% /run tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root xfs 17G 1.9G 16G 11% / /dev/sda1 xfs 1014M 153M 862M 16% /boot tmpfs tmpfs 182M 0 182M 0% /run/user/0 xfs扩容 [root@localhost ~]# xfs_growfs /dev/centos/root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1113856 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=4455424, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 4455424 to 56359936 [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 898M 0 898M 0% /dev tmpfs 910M 0 910M 0% /dev/shm tmpfs 910M 9.6M 901M 2% /run tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root 215G 1.9G 214G 1% / # 在查看 /dev/sda1 1014M 153M 862M 16% /boot tmpfs 182M 0 182M 0% /run/user/0 挂载 [root@localhost ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 is write-protected, mounting read-only [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 898M 0 898M 0% /dev tmpfs 910M 0 910M 0% /dev/shm tmpfs 910M 9.6M 901M 2% /run tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root 215G 1.9G 214G 1% / /dev/sda1 1014M 153M 862M 16% /boot tmpfs 182M 0 182M 0% /run/user/0 /dev/sr0 4.5G 4.5G 0 100% /mnt // 已经挂在上
在 导入7 镜像之前扩展空间 //导入redhat7镜像 、 装centos8就导入8镜像, [root@localhost ~]# cobbler import --path=/mnt --name=centos7 --arch=x86_64 task started: 2022-08-13_084034_import task started (id=Media import, time=Sat Aug 13 08:40:34 2022) Found a candidate signature: breed=suse, version=opensuse15.0 Found a candidate signature: breed=suse, version=opensuse15.1 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/centos7-x86_64: creating new distro: centos7-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos7-x86_64 -> /var/www/cobbler/links/centos7-x86_64 creating new profile: centos7-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/centos7-x86_64 for centos7-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos7-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/centos7-x86_64 looking for /var/www/cobbler/ks_mirror/centos7-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7-x86_64/repodata *** TASK COMPLETE *** // 看到这个说明导入成功 //说明: --path //镜像路径 --name //为安装源定义一个名字 --arch //指定安装源平台 //安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7-x86_64,如果重复,系统会提示导入失败 //查看cobbler镜像列表 [root@localhost ~]# cobbler list distros: centos7-x86_64 // 发行版 profiles: centos7-x86_64 // 配置文件 systems: repos: images: mgmtclasses: packages: files: ## 生成自动安装脚本 [root@localhost ~]# cobbler profile getks --name=centos7-x86_64 auth --enableshadow --passalgo=sha512 bootloader --location=mbr clearpart --all --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 us lang en_US url --url=http://192.168.229.155/cobbler/ks_mirror/centos7-x86_64 repo --name=source-1 --baseurl=http://192.168.229.155/cobbler/ks_mirror/centos7-x86_64 reboot rootpw --iscrypted $6$BwgXphAWdoBw3ign$pBFoWBORQJkElTRBEsCxlXWiojpPwZluPL3kJoflO.q1xrF8aOAuOm9rQDsymJSWmr06wl3lu3a34WuWbdc4f/ selinux --disabled skipx timezone Asia/Shanghai --isUtc --nontp install zerombr %packages @^minimal @core kexec-tools %end %addon com_redhat_kdump --enable --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 复制到这里来 //创建kickstarts自动安装脚本 [root@localhost ~]# cat > /var/lib/cobbler/kickstarts/centos7.ks <<'EOF' auth --enableshadow --passalgo=sha512 bootloader --location=mbr clearpart --all --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 us lang en_US url --url=http://192.168.229.155/cobbler/ks_mirror/centos7-x86_64 repo --name=source-1 --baseurl=http://192.168.229.155/cobbler/ks_mirror/centos7-x86_64 reboot rootpw --iscrypted $6$BwgXphAWdoBw3ign$pBFoWBORQJkElTRBEsCxlXWiojpPwZluPL3kJoflO.q1xrF8aOAuOm9rQDsymJSWmr06wl3lu3a34WuWbdc4f/ selinux --disabled skipx timezone Asia/Shanghai --isUtc --nontp install zerombr %packages @^minimal 这个要跟系统的anaconda-ks.cfg文件的的一样 @core kexec-tools %end EOF //检查ks文件语法是否有误 [root@localhost ~]# cobbler validateks task started: 2022-08-13_085422_validateks task started (id=Kickstart Validation, time=Sat Aug 13 08:54:22 2022) ---------------------------- osversion: rhel7 checking url: http://192.168.229.155/cblr/svc/op/ks/profile/centos7-x86_64 running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.229.155/cblr/svc/op/ks/profile/centos7-x86_64" received on stdout: received on stderr: *** all kickstarts seem to be ok *** *** TASK COMPLETE *** //查看当前cobbler有哪些配置文件 [root@localhost ~]# cobbler profile list centos7-x86_64 //修改profile,将我们新建的ks文件设为默认的kickstarts安装文件 [root@localhost ~]# cobbler profile edit --name centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks //配置网卡名称为传统网卡名称eth0 [root@localhost ~]# cobbler profile edit --name centos7-x86_64 --kopts='net.ifnames=0 biosdevname=0' //检查当前系统cobbler配置文件信息 [root@localhost ~]# cobbler profile report Name : centos7-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : centos7-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.ks //使用的kickstarts配置文件的路径,必须为我们新建的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 //同步cobbler [root@localhost ~]# cobbler sync ...省略N *** TASK COMPLETE *** //为避免发生未知问题,先把服务端所有服务重启 [root@localhost ~]# systemctl restart xinetd [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# systemctl restart httpd [root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 5 *:873 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 5 127.0.0.1:25151 *:* LISTEN 0 5 [::]:873 [::]:* LISTEN 0 128 [::]:80 [::]:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:* LISTEN 0 128 [::]:443 [::]:*
创建虚拟机,不给镜像。
点击,他会自动安装
正在安装
上面是命令的方式安装
创建虚拟机给定制安装,创建过程忽略
定制安装步骤:
统计mac地址此处就不赘述了,直接最重要的配置
在 cobbler 的web界面上配置:
同步配置并重启相关服务:
[root@localhost ~]# cobbler sync
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart xinetd
最后开机自动会安装系统
# 导入镜像8
[root@localhost ~]# init 0 // 关机
挂载 [root@localhost ~]# mount /dev/cdrom /test mount: /dev/sr0 is write-protected, mounting read-only [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 898M 0 898M 0% /dev tmpfs 910M 0 910M 0% /dev/shm tmpfs 910M 9.6M 901M 2% /run tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root 215G 6.4G 209G 3% / /dev/sda1 1014M 153M 862M 16% /boot tmpfs 182M 0 182M 0% /run/user/0 /dev/sr0 11G 11G 0 100% /test [root@localhost ~]# cobbler import --path=/mnt --name=centos8 --arch=x86_64 task started: 2022-08-13_145458_import task started (id=Media import, time=Sat Aug 13 14:54:58 2022) Found a candidate signature: breed=suse, version=opensuse15.0 Found a candidate signature: breed=suse, version=opensuse15.1 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/centos8-x86_64: creating new distro: centos8-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos8-x86_64 -> /var/www/cobbler/links/centos8-x86_64 creating new profile: centos8-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/centos8-x86_64 for centos8-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos8-x86_64/AppStream need to process repo/comps: /var/www/cobbler/ks_mirror/centos8-x86_64/AppStream looking for /var/www/cobbler/ks_mirror/centos8-x86_64/AppStream/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos8-x86_64/AppStream/repodata processing repo at : /var/www/cobbler/ks_mirror/centos8-x86_64/BaseOS need to process repo/comps: /var/www/cobbler/ks_mirror/centos8-x86_64/BaseOS looking for /var/www/cobbler/ks_mirror/centos8-x86_64/BaseOS/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos8-x86_64/BaseOS/repodata *** TASK COMPLETE *** [root@localhost ~]# cobbler list distros: centos7-x86_64 centos8-x86_64 profiles: centos7-x86_64 centos8-x86_64 systems: VM10 repos: images: mgmtclasses: packages: files: [root@localhost ~]# #查看centos8镜像目录 [root@localhost ~]# ll /var/www/cobbler/ks_mirror/centos8-x86_64/ total 52 dr-xr-xr-x 4 root root 38 Oct 13 2021 AppStream dr-xr-xr-x 4 root root 38 Oct 13 2021 BaseOS dr-xr-xr-x 3 root root 18 Oct 13 2021 EFI -r--r--r-- 1 root root 8154 Oct 13 2021 EULA -r--r--r-- 1 root root 1455 Oct 13 2021 extra_files.json -r--r--r-- 1 root root 18092 Oct 13 2021 GPL dr-xr-xr-x 3 root root 76 Oct 13 2021 images dr-xr-xr-x 2 root root 256 Oct 13 2021 isolinux -r--r--r-- 1 root root 103 Oct 13 2021 media.repo -r--r--r-- 1 root root 1669 Oct 13 2021 RPM-GPG-KEY-redhat-beta -r--r--r-- 1 root root 5135 Oct 13 2021 RPM-GPG-KEY-redhat-release -r--r--r-- 1 root root 1796 Oct 13 2021 TRANS.TBL # 创建kickstarts自动安装脚本 [root@localhost ~]# cd /var/lib/cobbler/kickstarts ## 生成自动安装脚本,, 如果生成7的就把8修改为7 [root@localhost ~]# cobbler profile getks --name=centos8-x86_64 auth --useshadow --enablemd5 bootloader --location=mbr clearpart --all --initlabel text firewall --disabled // 关闭防火墙 firstboot --disable keyboard us lang en_US url --url=http://192.168.229.155/cobbler/ks_mirror/centos8-x86_64 here. repo --name=source-1 --baseurl=http://192.168.229.155/cobbler/ks_mirror/centos7-x86_64/AppStream repo --name=source-2 --baseurl=http://192.168.229.155/cobbler/ks_mirror/centos7-x86_64/BaseOS network --bootproto=dhcp --device=eth0 --onboot=on reboot rootpw --iscrypted $6$BwgXphAWdoBw3ign$pBFoWBORQJkElTRBEsCxlXWiojpPwZluPL3kJoflO.q1xrF8aOAuOm9rQDsymJSWmr06wl3lu3a34WuWbdc4f/ selinux --disabled skipx timezone America/New_York install zerombr 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 & %end %packages @^minimal 这个要跟系统anaconda-ks.cfg文件的的一样 %end %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 %end #检查语法 [root@localhost ~]# cobbler validateks ...省略N Potential templating errors: Unknown variable found at line 16, column 22: '$BwgXphAWdoBw3ign' Unknown variable found at line 16, column 39: '$pBFoWBORQJkElTRBEsCxlXWiojpPwZluPL3kJoflO.q1xrF8aOAuOm9rQDsymJSWmr06wl3lu3a34WuWbdc4f' *** potential errors detected in kickstarts *** !!! TASK FAILED !!! centos8版本不被pykickstart支持 # 如果有异常的变量参数,不要慌,只是虚拟机密码 #查看生成的配置文件 [root@localhost ~]# cobbler profile list centos7-x86_64 centos8-x86_64 #配置系统默认文件 [root@localhost ~]# cobbler profile edit --name centos8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos8.ks #回归传统命名 [root@localhost ~]# cobbler profile edit --name centos8-x86_64 --kopts='net.ifnames=0 biosdevname=0' #同步sync [root@localhost ~]# cobbler sync ...省略N running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE *** #重启服务 [root@localhost ~]# systemctl restart httpd [root@localhost ~]# systemctl restart cobblerd [root@localhost ~]# systemctl restart xinetd [root@localhost ~]# systemctl restart rsyncd
创建虚拟机的过程跟上面一样所以这里忽略
装7 就点击7,装8,就点击8。这里装8
定制安装
跟7 的操作是一样的
创建虚拟机,然后开机他会自动装机
这时就没有哪个蓝屏让你点击了,不需要,他会自动装机
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。