cobbler多机定制安装

cobbler多机定制安装

1.cobbler服务端部署

服务端IP是192.168.159.136

#开始前确保防火墙色selinux永久是disable状态
#确保配置好yum源,包括epel源
#安装cobbler以及相关软件
[root@longnian ~]# yum -y install httpd dhcp tftp python-ctypes cobbler  xinetd cobbler-web pykickstart net-tools

#启动服务并开机自启
[root@longnian ~]# systemctl enable --now httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

systemctl enable --now cobblerd
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

[root@longnian ~]# ss -anlt
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      64              *:55660                       *:*                  
LISTEN      0      128             *:111                         *:*                  
LISTEN      0      128             *:20048                       *:*                  
LISTEN      0      128             *:22                          *:*                  
LISTEN      0      100     127.0.0.1:25                          *:*                  
LISTEN      0      128             *:3260                        *:*                  
LISTEN      0      5       127.0.0.1:25151                       *:*                  
LISTEN      0      128             *:49343                       *:*                  
LISTEN      0      64              *:2049                        *:*                  
LISTEN      0      128            :::60264                      :::*                  
LISTEN      0      128            :::111                        :::*                  
LISTEN      0      128            :::80                         :::*                  
LISTEN      0      128            :::20048                      :::*                  
LISTEN      0      128            :::81                         :::*                  
LISTEN      0      128            :::22                         :::*                  
LISTEN      0      100           ::1:25                         :::*                  
LISTEN      0      128            :::443                        :::*                  
LISTEN      0      64             :::43516                      :::*                  
LISTEN      0      128            :::3260                       :::*                  
LISTEN      0      64             :::2049                       :::*

#修改server的ip地址为本机ip
[root@longnian ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.159.135/' /etc/cobbler/settings

#设置tftp的ip地址为本机ip
[root@longnian ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.159.135/' /etc/cobbler/settings

#开启tftp
[root@longnian ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp

#下载缺失文件
[root@longnian ~]# cobbler get-loaders
task started: 2020-07-30_033241_get_loaders
task started (id=Download Bootloader Content, time=Thu Jul 30 03:32:41 2020)
path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***

#启动rsync并设置开机自启
[root@longnian ~]# systemctl enable --now rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

#生成加密的密码并加入到配置文件
[root@longnian ~]# openssl passwd -1 -salt "$RANDOM" 'longnian123.'
$1$30427$DgfDqUm/uZNUuIcjTv8Ux0
[root@longnian ~]# vim /etc/cobbler/settings 
default_password_crypted: "$1$30427$DgfDqUm/uZNUuIcjTv8Ux0"
.........

重启cobbler
[root@longnian ~]# systemctl restart cobblerd
[root@longnian ~]# ss -anlt
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      5               *:873                         *:*                  
LISTEN      0      128             *:111                         *:*                  
LISTEN      0      128             *:20048                       *:*                  
LISTEN      0      128             *:22                          *:*                  
LISTEN      0      100     127.0.0.1:25                          *:*                  
LISTEN      0      128             *:3260                        *:*                  
LISTEN      0      5       127.0.0.1:25151                       *:*                  
LISTEN      0      64              *:2049                        *:*                  
LISTEN      0      128             *:48290                       *:*                  
LISTEN      0      64              *:36327                       *:*                  
LISTEN      0      5              :::873                        :::*                  
LISTEN      0      128            :::111                        :::*                  
LISTEN      0      128            :::80                         :::*                  
LISTEN      0      128            :::20048                      :::*                  
LISTEN      0      128            :::81                         :::*                  
LISTEN      0      128            :::22                         :::*                  
LISTEN      0      100           ::1:25                         :::*                  
LISTEN      0      128            :::443                        :::*                  
LISTEN      0      128            :::3260                       :::*                  
LISTEN      0      64             :::2049                       :::*                  
LISTEN      0      64             :::53255                      :::*                  
LISTEN      0      128            :::49991                      :::*

#通过cobbler check 核对当前设置是否有问题
[root@longnian ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : 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
[root@longnian ~]# sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings
[root@longnian ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings
manage_dhcp: 1

#配置dhcp
[root@longnian ~]# vim /etc/cobbler/dhcp.template
..........
subnet 192.168.159.0 netmask 255.255.255.0 {
     option routers             192.168.159.135;
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.159.140 192.168.159.200;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
..........

#重启服务并同步配置
[root@longnian ~]# systemctl restart cobblerd
[root@longnian ~]# cobbler sync
task started: 2020-07-30_034921_sync
task started (id=Sync, time=Thu Jul 30 03:49:21 2020)
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.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

#检查dhcp是否正常
[root@longnian ~]# netstat -anulp|grep dhcp
udp        0      0 0.0.0.0:67              0.0.0.0:*                           2557/dhcpd

导入redhat7镜像
光驱放的是centos7的镜像

[root@longnian ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@longnian ~]# cobbler import --path=/mnt --name=rhel-7 --arch=x86_64
task started: 2020-07-30_035319_import
task started (id=Media import, time=Thu Jul 30 03:53:19 2020)
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/rhel-7-x86_64:
creating new distro: rhel-7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/rhel-7-x86_64 -> /var/www/cobbler/links/rhel-7-x86_64
creating new profile: rhel-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/rhel-7-x86_64 for rhel-7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/rhel-7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-7-x86_64
looking for /var/www/cobbler/ks_mirror/rhel-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-7-x86_64/repodata
*** TASK COMPLETE ***

#查看cobbler镜像列表
[root@longnian ~]# cobbler list
distros:
   rhel-7-x86_64

profiles:
   rhel-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

#创建kickstarts自动安装脚本
[root@longnian ~]# cat > /var/lib/cobbler/kickstarts/rhel-7-x86_64.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
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.159.135/cobbler/ks_mirror/rhel-7-x86_64
$yum_repo_stanza
reboot
rootpw --iscrypted $6$fNon0kia6gWhUyEL$ZQMccSYNjOIfMHWaJJDtw1IOTn6.xH9qseLV2DJoHX2R5NrZG7z5AWLEOp4o2rmBYPugvYUMGlwqmFtTM1m8Z/

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
EOF

#检查ks文件语法是否有误、查看当前cobbler有哪些配置文件
[root@longnian ~]# cobbler validateks
task started: 2020-07-30_040534_validateks
task started (id=Kickstart Validation, time=Thu Jul 30 04:05:34 2020)
----------------------------
osversion: rhel7
checking url: http://192.168.159.135/cblr/svc/op/ks/profile/rhel-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.159.135/cblr/svc/op/ks/profile/rhel-7-x86_64"
received on stdout: 
received on stderr: 
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***

[root@longnian ~]# cobbler profile list
   rhel-7-x86_64

#修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@longnian ~]# cobbler profile edit --name rhel-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/rhel-7-x86_64.ks

#配置网卡名称为传统网卡名称eth0
[root@longnian ~]# cobbler profile edit --name rhel-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'

#检查当前系统cobbler配置文件信息
[root@longnian ~]# cobbler profile report
Name                           : rhel-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : rhel-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/rhel-7-x86_64.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@longnian ~]# cobbler sync
task started: 2020-07-30_040841_sync
task started (id=Sync, time=Thu Jul 30 04:08:41 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/rhel-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/rhel-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
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 files for distro: rhel-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: rhel-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-7-x86_64/initrd.img
Writing template files for rhel-7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: rhel-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 ***

[root@longnian ~]# umount /mnt/
[root@longnian ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  5.3G   13G   30% /
devtmpfs                 479M     0  479M    0% /dev
tmpfs                    489M     0  489M    0% /dev/shm
tmpfs                    489M  6.8M  483M    2% /run
tmpfs                    489M     0  489M    0% /sys/fs/cgroup
/dev/sda1                497M  125M  373M   25% /boot
tmpfs                     98M     0   98M    0% /run/user/0

再导入rhel-8的镜像
更换光驱,再导入

[root@longnian ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载

#导入镜像
[root@longnian ~]# cobbler import --path=/mnt --name=rhel-8 --arch=x86_64
task started: 2020-07-31_045424_import
task started (id=Media import, time=Fri Jul 31 04:54:24 2020)
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 ***

#查看镜像
[root@longnian ~]# cobbler list
distros:
   CentOS-7-x86_64
   rhel-8-x86_64

profiles:
   CentOS-7-x86_64
   rhel-8-x86_64

systems:
   text01

repos:

images:

mgmtclasses:

packages:

files:

#创建rhel-8的kickstarts自动安装脚本
[root@longnian ~]# cat > /var/lib/cobbler/kickstarts/rhel-8-x86_64.ks <<'EOF'
> #version=RHEL8
> ignoredisk --only-use=nvme0n1
> autopart --type=lvm
> 
> clearpart --none --initlabel
> 
> cdrom
> 
> keyboard --vckeymap=cn --xlayouts='cn'
> 
> lang zh_CN.UTF-8
> firewall --disabled
> firstboot --disable
> url --url=http://192.168.159.136/cobbler/ks_mirror/rhel-8-x86_64
> $yum_repo_stanza 
> reboot
> rootpw --iscrypted $6\$J05GEZxfRnpittd9\$c0p/HBvvBksNoKAUHGrdbROq4a6zKwdLrzck/9dQl8CXNVf37b3L7B45Vow721bZdGnKF0kt4fYfMTCDGPKVK0
> 
> selinux --disabled
> skipx
> timezone Asia/Shanghai --isUtc --nontp
> install
> zerombr
> 
> 
> %packages
> @^minimal-environment
> 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
> EOF

#修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@longnian ~]# cobbler profile edit --name rhel-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks

#配置网卡名称为传统网卡名称eth0
[root@longnian ~]# cobbler profile edit --name rhel-8-x86_64 --kopts='net.ifnames=0 biosdevname=0'

#检查当前系统cobbler配置文件信息
[root@longnian ~]# cobbler profile report
Name                           : rhel-8-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : rhel-8-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/rhel-8-x86_64.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

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/CentOS-7-x86_64.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@longnian ~]# cobbler sync
task started: 2020-07-31_050533_sync
task started (id=Sync, time=Fri Jul 31 05:05:33 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-7-x86_64
removing: /var/www/cobbler/images/rhel-8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-22-d7-db
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/01-00-50-56-22-D7-DB
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/CentOS-7-x86_64
removing: /var/lib/tftpboot/images/rhel-8-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
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 files for distro: rhel-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-8-x86_64/initrd.img
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: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-22-d7-db
generating: /var/lib/tftpboot/grub/01-00-50-56-22-D7-DB
generating PXE menu structure
copying files for distro: rhel-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-8-x86_64/initrd.img
Writing template files for rhel-8-x86_64
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: rhel-8-x86_64
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 ***


#重启所有服务
[root@longnian ~]# systemctl restart xinetd
[root@longnian ~]# systemctl restart cobblerd
[root@longnian ~]# systemctl restart httpd
[root@longnian ~]# ss -anlt
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                        :::*

2.客户端安装

给客户端插上电源,连接上网线,开机。选择系统安装
在这里插入图片描述
在这里插入图片描述

3.定制安装配置

定制安装步骤:

统计服务器mac地址
配置cobbler
安装

CentOS7: 00:50:56:23:3E:EF

rhel-8:00:0C:29:5E:49:7B

给两台服务器定制安装,一台装CentOS7,一台装rhel8
在 cobbler 的web界面上配置:

登录
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

#/var/lib/cobbler/config/systems.d/test1.json就是web界面的配置
[root@longnian ~]# cd /var/lib/cobbler/config/systems.d/
[root@longnian systems.d]# ls
text01.json
[root@longnian systems.d]# cat text01.json 
{"comment": "", "status": "production", "kickstart": "/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks", "name_servers_search": [], "ks_meta": {}, "kernel_options_post": {}, "image": "", "redhat_management_key": "<<inherit>>", "virt_path": "<<inherit>>", "power_user": "", "kernel_options": {}, "ctime": 1596121136.442785, "name_servers": ["114.114.114.114"], "mtime": 1596121136.442785, "enable_gpxe": false, "template_files": {}, "gateway": "192.168.159.2", "uid": "MTU5NjEyMTEzNi40NDM0MjA2NjIuODk4MzM", "virt_auto_boot": 0, "power_type": "ipmitool", "virt_cpus": "<<inherit>>", "mgmt_parameters": "<<inherit>>", "boot_files": {}, "hostname": "text01", "repos_enabled": false, "mgmt_classes": [], "power_pass": "", "netboot_enabled": true, "ipv6_autoconfiguration": false, "profile": "CentOS-7-x86_64", "virt_type": "xenpv", "interfaces": {"eth0": {"ipv6_address": "", "interface_type": "", "static": true, "cnames": [], "mtu": "", "management": false, "interface_master": "", "mac_address": "00:50:56:22:D7:DB", "ipv6_prefix": "", "virt_bridge": "xenbr0", "netmask": "255.255.255.0", "bonding_opts": "", "ip_address": "192.168.159.139", "dhcp_tag": "", "static_routes": [], "ipv6_mtu": "", "ipv6_static_routes": [], "if_gateway": "", "dns_name": "", "bridge_opts": "", "connected_mode": false, "ipv6_secondaries": [], "ipv6_default_gateway": ""}}, "power_address": "", "proxy": "<<inherit>>", "fetchable_files": {}, "virt_file_size": "<<inherit>>", "ldap_enabled": false, "monit_enabled": false, "ipv6_default_device": "", "virt_pxe_boot": 0, "virt_disk_driver": "<<inherit>>", "owners": "<<inherit>>", "name": "text01", "virt_ram": "<<inherit>>", "power_id": "", "server": "<<inherit>>", "redhat_management_server": "<<inherit>>", "depth": 2, "ldap_type": "authconfig", "template_remote_kickstarts": 0}[root@longnian systems.d]# 

#这样可读性太差,不方便我们修改
#我们下载jq,来格式化json文件
[root@longnian systems.d]# yum -y install jq
[root@longnian systems.d]# cat text01.json |jq
{
  "comment": "",
  "status": "production",
  "kickstart": "/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks",
  "name_servers_search": [],
  "ks_meta": {},
  "kernel_options_post": {},
  "image": "",
  "redhat_management_key": "<<inherit>>",
  "virt_path": "<<inherit>>",
  "power_user": "",
  "kernel_options": {},
  "ctime": 1596121136.442785,
  "name_servers": [
    "114.114.114.114"
  ],
  "mtime": 1596121136.442785,
  "enable_gpxe": false,
  "template_files": {},
  "gateway": "192.168.159.2",
  "uid": "MTU5NjEyMTEzNi40NDM0MjA2NjIuODk4MzM",
  "virt_auto_boot": 0,
  "power_type": "ipmitool",
  "virt_cpus": "<<inherit>>",
  "mgmt_parameters": "<<inherit>>",
  "boot_files": {},
  "hostname": "text01",
  "repos_enabled": false,
  "mgmt_classes": [],
  "power_pass": "",
  "netboot_enabled": true,
  "ipv6_autoconfiguration": false,
  "profile": "CentOS-7-x86_64",
  "virt_type": "xenpv",
  "interfaces": {
    "eth0": {
      "ipv6_address": "",
      "interface_type": "",
      "static": true,
      "cnames": [],
      "mtu": "",
      "management": false,
      "interface_master": "",
      "mac_address": "00:50:56:22:D7:DB",
      "ipv6_prefix": "",
      "virt_bridge": "xenbr0",
      "netmask": "255.255.255.0",
      "bonding_opts": "",
      "ip_address": "192.168.159.139",
      "dhcp_tag": "",
      "static_routes": [],
      "ipv6_mtu": "",
      "ipv6_static_routes": [],
      "if_gateway": "",
      "dns_name": "",
      "bridge_opts": "",
      "connected_mode": false,
      "ipv6_secondaries": [],
      "ipv6_default_gateway": ""
    }
  },
  "power_address": "",
  "proxy": "<<inherit>>",
  "fetchable_files": {},
  "virt_file_size": "<<inherit>>",
  "ldap_enabled": false,
  "monit_enabled": false,
  "ipv6_default_device": "",
  "virt_pxe_boot": 0,
  "virt_disk_driver": "<<inherit>>",
  "owners": "<<inherit>>",
  "name": "text01",
  "virt_ram": "<<inherit>>",
  "power_id": "",
  "server": "<<inherit>>",
  "redhat_management_server": "<<inherit>>",
  "depth": 2,
  "ldap_type": "authconfig",
  "template_remote_kickstarts": 0
}

根据上面的配置,我们在配置文件中修改,来添加rhel-8的配置

#生成配置文件
[root@longnian systems.d]# cat text01.json |jq > text02.json 
[root@longnian systems.d]# cat text02.json
{
  "comment": "",
  "status": "production",
  "kickstart": "/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks",
  "name_servers_search": [],
  "ks_meta": {},
  "kernel_options_post": {},
  "image": "",
  "redhat_management_key": "<<inherit>>",
  "virt_path": "<<inherit>>",
  "power_user": "",
  "kernel_options": {},
  "ctime": 1596121136.442785,
  "name_servers": [
    "114.114.114.114"
  ],
  "mtime": 1596121136.442785,
  "enable_gpxe": false,
  "template_files": {},
  "gateway": "192.168.159.2",
  "uid": "MTU5NjEyMTEzNi40NDM0MjA2NjIuODk4MzM",
  "virt_auto_boot": 0,
  "power_type": "ipmitool",
  "virt_cpus": "<<inherit>>",
  "mgmt_parameters": "<<inherit>>",
  "boot_files": {},
  "hostname": "text01",
  "repos_enabled": false,
  "mgmt_classes": [],
  "power_pass": "",
  "netboot_enabled": true,
  "ipv6_autoconfiguration": false,
  "profile": "CentOS-7-x86_64",
  "virt_type": "xenpv",
  "interfaces": {
    "eth0": {
      "ipv6_address": "",
      "interface_type": "",
      "static": true,
      "cnames": [],
      "mtu": "",
      "management": false,
      "interface_master": "",
      "mac_address": "00:50:56:22:D7:DB",
      "ipv6_prefix": "",
      "virt_bridge": "xenbr0",
      "netmask": "255.255.255.0",
      "bonding_opts": "",
      "ip_address": "192.168.159.139",
      "dhcp_tag": "",
      "static_routes": [],
      "ipv6_mtu": "",
      "ipv6_static_routes": [],
      "if_gateway": "",
      "dns_name": "",
      "bridge_opts": "",
      "connected_mode": false,
      "ipv6_secondaries": [],
      "ipv6_default_gateway": ""
    }
  },
  "power_address": "",
  "proxy": "<<inherit>>",
  "fetchable_files": {},
  "virt_file_size": "<<inherit>>",
  "ldap_enabled": false,
  "monit_enabled": false,
  "ipv6_default_device": "",
  "virt_pxe_boot": 0,
  "virt_disk_driver": "<<inherit>>",
  "owners": "<<inherit>>",
  "name": "text01",
  "virt_ram": "<<inherit>>",
  "power_id": "",
  "server": "<<inherit>>",
  "redhat_management_server": "<<inherit>>",
  "depth": 2,
  "ldap_type": "authconfig",
  "template_remote_kickstarts": 0
}

#修改配置文件,只需要修改以下几项即可
"kickstart": "/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks",
  "hostname": "client-2",
  "profile": "rhel-8-x86_64",
      "mac_address": "00:50:56:26:F3:26",
      "ip_address": "192.168.32.155",
        "name": "test2",

#修改后
[root@longnian systems.d]# cat text02.json 
{
  "comment": "",
  "status": "production",
  "kickstart": "/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks",
  "name_servers_search": [],
  "ks_meta": {},
  "kernel_options_post": {},
  "image": "",
  "redhat_management_key": "<<inherit>>",
  "virt_path": "<<inherit>>",
  "power_user": "",
  "kernel_options": {},
  "ctime": 1596121136.442785,
  "name_servers": [
    "114.114.114.114"
  ],
  "mtime": 1596121136.442785,
  "enable_gpxe": false,
  "template_files": {},
  "gateway": "192.168.159.2",
  "uid": "MTU5NjEyMTEzNi40NDM0MjA2NjIuODk4MzM",
  "virt_auto_boot": 0,
  "power_type": "ipmitool",
  "virt_cpus": "<<inherit>>",
  "mgmt_parameters": "<<inherit>>",
  "boot_files": {},
  "hostname": "text02",
  "repos_enabled": false,
  "mgmt_classes": [],
  "power_pass": "",
  "netboot_enabled": true,
  "ipv6_autoconfiguration": false,
  "profile": "rhel-8-x86_64",
  "virt_type": "xenpv",
  "interfaces": {
    "eth0": {
      "ipv6_address": "",
      "interface_type": "",
      "static": true,
      "cnames": [],
      "mtu": "",
      "management": false,
      "interface_master": "",
      "mac_address": "00:0C:29:5E:49:7B",
      "ipv6_prefix": "",
      "virt_bridge": "xenbr0",
      "netmask": "255.255.255.0",
      "bonding_opts": "",
      "ip_address": "192.168.159.140",
      "dhcp_tag": "",
      "static_routes": [],
      "ipv6_mtu": "",
      "ipv6_static_routes": [],
      "if_gateway": "",
      "dns_name": "",
      "bridge_opts": "",
      "connected_mode": false,
      "ipv6_secondaries": [],
      "ipv6_default_gateway": ""
    }
  },
  "power_address": "",
  "proxy": "<<inherit>>",
  "fetchable_files": {},
  "virt_file_size": "<<inherit>>",
  "ldap_enabled": false,
  "monit_enabled": false,
  "ipv6_default_device": "",
  "virt_pxe_boot": 0,
  "virt_disk_driver": "<<inherit>>",
  "owners": "<<inherit>>",
  "name": "text02",
  "virt_ram": "<<inherit>>",
  "power_id": "",
  "server": "<<inherit>>",
  "redhat_management_server": "<<inherit>>",
  "depth": 2,
  "ldap_type": "authconfig",
  "template_remote_kickstarts": 0
}

重启服务

[root@longnian systems.d]# systemctl restart cobblerd
[root@longnian systems.d]# systemctl restart xinetd
[root@longnian systems.d]# systemctl restart httpd
[root@longnian systems.d]# ss -anlt
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                        :::*

配置已经有了
在这里插入图片描述

4.安装

两台机器开机自动安装各自的系统
vm1开机
在这里插入图片描述
正在装包
在这里插入图片描述
登录
在这里插入图片描述

vm2开机
在这里插入图片描述
登录
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值