系統環境:
一.開啟兩個網卡。一個僅主機模式,一個橋接模式,主機模式對內提供cobbler服務
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:24:81:b8 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.191/24 brd 192.168.1.255 scope global noprefixroute dynamic ens33
valid_lft 6395sec preferred_lft 6395sec
inet6 fe80::d57f:69e1:bdc9:112c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:24:81:c2 brd ff:ff:ff:ff:ff:ff
inet 192.168.199.129/24 brd 192.168.199.255 scope global noprefixroute dynamic ens37
valid_lft 1706sec preferred_lft 1706sec
inet6 fe80::2e3a:fb50:b5de:f0d1/64 scope link noprefixroute
valid_lft forever preferred_lft forever
內網IP:192.168.199.129/24
外網IP:192.168.1.191/24
二.關閉安全服務
[root@localhost ~]# systemctl stop firewalld #關閉防火牆
[root@localhost ~]# setenforce 0 #關閉selinux
三.下載cobbler及其所需要的服務
[root@localhost ~]# yum install cobbler httpd dhcp tftp-server xinetd syslinux -y
yum安裝cobbler需要使用下面兩個源
[epel]
name=epel
enabled=1
gpgcheck=0
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
[centos]
name=centos base
enabled=1
gpgcheck=0
baseurl=http://mirrors.163.com/centos/7/os/x86_64/
配置相關服務
第一步:配置DHCP服務
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.199.0 netmask 255.255.255.0 {
range 192.168.199.125 192.168.199.129;
default-lease-time 600;
max-lease-time 7200;
filename "pxelinux.0";
}
第二步:配置tftp
[root@localhost ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
protocol. The tftp protocol is often used to boot diskless \
workstations, download configuration files to network-aware printers, \
and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no #yes改為no
per_source = 11
cps = 100 2
flags = IPv4
第三步:啟動cobbler
[root@localhost ~]# systemctl restart cobblerd
第四步:啟動httpd
[root@localhost ~]# systemctl restart httpd
第五步:檢查cobbler配置
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : 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.
4 : enable and start rsyncd.service with systemctl
5 : debmirror package is not installed, it will be required to manage debian deployments and repositories
6 : ksvalidator was not found, install pykickstart
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
8 : 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.
問題一:cobbler文件默認時127.0.0.1本地回環地址,需要更改為提供cobbler服務的IP地址192.168.199.129 在384行
384 server: 192.168.199.129
問題二:next_server也是默認本地回環地址,需要改為提供cobbler服務的IP地址 192.168.199.129 在272行
272 next_server: 192.168.199.129
問題三:可以忽略
問題四:啟動rsync即可
[root@localhost ~]# systemctl restart rsyncd
[root@localhost ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
問題五:可以忽略
問題六:更改密碼
[root@localhost ~]# openssl passwd -1 -salt "123" "123123"
$1$123$ai3PKcU9Q7J3tIviFBaqN0
把新生成的加密數據填寫進/etc/cobbler/settings
101 default_password_crypted: "$1$123$ai3PKcU9Q7J3tIviFBaqN0."
問題7:可以忽略
解決之后需要同步和重啟
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync
再次檢查是否已經更新完成
[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, 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
3 : ksvalidator was not found, install pykickstart
4 : 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.
已經更改完畢
第六步:掛載光盤並進行數據導入
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 寫保護,將以只讀方式掛載
mount: /dev/sr0 已經掛載或 /mnt 忙
/dev/sr0 已經掛載到 /mnt 上
數據導入(需要等候半小時)
查看distro
[root@localhost ~]# cobbler distro list
centos7.5-x86_64
查看profile
[root@localhost ~]# cobbler profile list
centos7.5-x86_64
第七步:准備kicksstart文件
在root目錄下找到ks文件,並移動到/var/lib/cobbler/kickstarts/到目錄下改名為ks.cfg
[root@localhost ~]# mv anaconda-ks.cfg /var/lib/cobbler/kickstarts/ks.cfg
[root@localhost ~]# vim /var/lib/cobbler/kickstarts/ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url=http://192.168.199.129/cobbler/ks_mirror/centos7.5/ #這里需要改為repodata所在的http地址
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$TMd0rYN/SfJ1lCgp$wXdVnqpX/mHK0UgVnHaNJNNS0UIdddW3fJ.61SUO4maZQOvg1c/0eWXT28o0I25rmOOjKs5/3IZVNeYcIA6rL0
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
%packages
@^minimal
@core
chrony
kexec-tools
需要改為repodata所在的http地址