cobbler的下载和后续文件的下载都要依赖网络
作为cobbler服务端,需要配置的服务有httpd、cobblerd、dhcpd、tftp
关闭防火墙及selinux
[root@centos7 <sub>]$getenforce
Disabled
[root@centos7 </sub>]$systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
配置yum源
[root@centos7 <sub>]$cat /etc/yum.repos.d/base.repo
[base]
name=CentOS
baseurl=file:///mnt/cdrom #以光盘挂载目录
gpgcheck=0
[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/$basearch
gpgcheck=0
enabled=1
[root@centos7 </sub>]$yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
base CentOS 10,097
epel/7/x86_64 EPEL 13,199
repolist: 23,296
安装必要的服务(httpd、cobbler、dhcp、tftp)
[root@centos7 ~]$yum install httpd cobbler dhcp tftp
启动服务,检查服务是否已经在监听端口(除dhcp不用此时启动)
[root@centos7 <sub>]$systemctl start httpd cobblerd tftp
[root@centos7 </sub>]$systemctl status httpd cobblerd tftp
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-03-05 20:37:07 CST; 8s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 7935 (httpd)
Status: "Processing requests..."
Tasks: 6
CGroup: /system.slice/httpd.service
├─7935 /usr/sbin/httpd -DFOREGROUND
├─7940 /usr/sbin/httpd -DFOREGROUND
├─7941 /usr/sbin/httpd -DFOREGROUND
├─7942 /usr/sbin/httpd -DFOREGROUND
├─7943 /usr/sbin/httpd -DFOREGROUND
└─7944 /usr/sbin/httpd -DFOREGROUND
Mar 05 20:37:06 centos7 systemd[1]: Starting The Apache HTTP Server...
Mar 05 20:37:07 centos7 httpd[7935]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name,...message
Mar 05 20:37:07 centos7 systemd[1]: Started The Apache HTTP Server.
● cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-03-05 20:37:06 CST; 8s ago
Process: 7937 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=1/FAILURE)
Main PID: 7936 (cobblerd)
Tasks: 1
CGroup: /system.slice/cobblerd.service
└─7936 /usr/bin/python2 -s /usr/bin/cobblerd -F
Mar 05 20:37:06 centos7 systemd[1]: Starting Cobbler Helper Daemon...
Mar 05 20:37:06 centos7 touch[7937]: /usr/bin/touch: cannot touch ‘/usr/share/cobbler/web/cobbler.wsgi’: No such file or directory
Mar 05 20:37:06 centos7 systemd[1]: Started Cobbler Helper Daemon.
● tftp.service - Tftp Server
Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)
Active: active (running) since Thu 2020-03-05 20:37:09 CST; 5s ago
Docs: man:in.tftpd
Main PID: 7959 (in.tftpd)
Tasks: 1
CGroup: /system.slice/tftp.service
└─7959 /usr/sbin/in.tftpd -s /var/lib/tftpboot
Mar 05 20:37:09 centos7 systemd[1]: Started Tftp Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos7 ~]$ss -lpntt
State Recv-Q Send-Q Local Address:Port
Peer Address:Port
LISTEN 0 5 127.0.0.1:25151
*:* users:(("cobblerd",pid=7936,fd=9))
LISTEN 0 128 :::80
:::* users:(("httpd",pid=7944,fd=4),
("httpd",pid=7943,fd=4),("httpd",pid=7942,fd=4),("httpd",pid=7941,fd=4),
("httpd",pid=7940,fd=4),("httpd",pid=7935,fd=4))
cobbler配置检查,列出了向导文件,可以根据内容逐项修改
[root@centos7 <sub>]$cobbler check
[root@centos7 </sub>]$cd /etc/cobbler/
[root@centos7 cobbler]$ls #cdcp.template是cobbler自动生成dhcp配置文件的模板,需要修改 #settings是初始设置文件,需要修改
auth.conf dhcp.template iso named.template rsync.exclude tftpd.template zone.template
cheetah_macros dnsmasq.template ldap power rsync.template users.conf zone_templates
cobbler_bash genders.template modules.conf pxe secondary.template users.digest
completions import_rsync_whitelist mongodb.conf reporting settings version
生成一个口令备用
(默认口令为cobbler,安全相关,可以不做)
[root@centos7 cobbler]$openssl passwd -1
Password:
Verifying - Password:
$1$WvbdgCeW$Kmh2VCeHA8Q89kWNbNrP80
修改cobbler设置
[root@centos7 cobbler]vim settings
101 default_password_crypted: "$1$WvbdgCeW$Kmh2VCeHA8Q89kWNbNrP80" #cobbler密码,复制上面口令生成的md5值
242 manage_dhcp: 1 #默认0是不创建dhcp配置文件
278 next_server: 192.168.44.105 #本机ip地址设为服务端
390 server: 192.168.44.105 #本机ip地址设为服务端
重启服务
[root@centos7 cobbler]$systemctl restart cobblerd
修改dhcp配置
[root@centos7 cobbler]$vim dhcp.template
subnet 192.168.44.0 netmask 255.255.255.0 { #子网范围
option routers 192.168.44.2;
option domain-name-servers 192.168.44.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.44.50 192.168.44.55; #自动分配的地址池的范围
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@centos7 cobbler]$systemctl restart cobblerd
[root@centos7 cobbler]$cobbler sync #同步cobbler
[root@centos7 cobbler]$systemctl start dhcpd
网络下载bootloader文件,同步cobbler
[root@centos7 cobbler]$cobbler get-loaders
[root@centos7 cobbler]$cobbler sync
创建cobbler的yum源
[root@centos7 cobbler]$cobbler import --path=/mnt/cdrom --name=CentOS7.6-x86_64 --arch=x86_64 #路径为本地光盘挂载目录
task started: 2020-03-05_205800_import #实质是将指定的系统源文件往cobbler里面复制一遍
task started (id=Media import, time=Thu Mar 5 20:58:00 2020)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS7.6-x86_64:
creating new distro: CentOS7.6-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS7.6-x86_64 -> /var/www/cobbler/links/CentOS7.6-x86_64
creating new profile: CentOS7.6-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.6-x86_64 for CentOS7.6-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS7.6-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS7.6-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS7.6-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS7.6-x86_64/repodata
*<strong> TASK COMPLETE </strong>*
[root@centos7 cobbler]$cobbler profile list #查看菜单选择项
CentOS7.6-x86_64
[root@centos7 cobbler]$cobbler distro list
CentOS7.6-x86_64
准备kickstart文件
[root@centos7 html]$mv ks7_mini.cfg /var/lib/cobbler/kickstarts/
[root@centos7 html]$cd /var/lib/cobbler/kickstarts/
[root@centos7 kickstarts]$ls
default.ks install_profiles pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed
esxi4-ks.cfg ks7_mini.cfg sample_autoyast.xml sample_esxi4.ks sample.ks sample.seed.28
esxi5-ks.cfg legacy.ks sample_end.ks sample_esxi5.ks sample_old.seed
[root@centos7 kickstarts]$vim ks7_mini.cfg #修改应答文件
10 url --url=$tree #tree是cobbler服务自带的选项,可以自动按配置查找路径
[root@centos7 kickstarts]$cobbler profile add --name CentOS7.6-x86_64_mini --distro=CentOS7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7_mini.cfg
[root@centos7 html]cobbler sync #又添加了一个自己配置的mini系统安装包
[root@centos7 ~]$tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│?? └── grub
│?? └── menu.lst
├── etc
├── grub
│?? ├── efidefault
│?? ├── grub-x86_64.efi
│?? ├── grub-x86.efi
│?? └── images -> ../images
├── images
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│?? └── default
├── s390x
│?? └── profile_list
└── yaboot
10 directories, 10 files
测试阶段:
准备全新的虚拟机
出现选择界面,第二项是cobbler自动生成的默认选项,第三项是自定义的
出现分区和安装包