1.环境
机器 | 大小 |
---|---|
cobbler | 2G内存以上+20G硬盘以上 |
测试机 | 2G内存以上+20G硬盘以上 |
[root@localhost ~]# cat /etc/redhat-release
[root@localhost ~]# systemctl disble firewalld
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disaled
[root@localhost ~]# hostnamectl set-hostname zobbler
[root@localhost ~]# reboot
2.yum 源
[root@zobbler ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@zobbler ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@zobbler ~]# yum repolist && yum clean all && yum makecache
- yum 安装 软件包
[root@zobbler ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd debmirror
[root@zobbler ~]# yum -y install xinetd install fence-agents
/etc/cobbler # 配置文件目录
/etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
/etc/cobbler/dhcp.template # DHCP服务的配置模板
/etc/cobbler/tftpd.template # tftp服务的配置模板
/etc/cobbler/rsync.template # rsync服务的配置模板
/etc/cobbler/iso # iso模板配置文件目录
/etc/cobbler/pxe # pxe模板文件目录
/etc/cobbler/power # 电源的配置文件目录
/etc/cobbler/users.conf # Web服务授权配置文件
/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template # DNS服务的配置模板
/etc/cobbler/modules.conf # Cobbler模块配置文件
/var/lib/cobbler # Cobbler数据目录
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默认存放kickstart文件
/var/lib/cobbler/loaders # 存放的各种引导程序
/var/www/cobbler # 系统安装镜像目录
/var/www/cobbler/ks_mirror # 导入的系统镜像列表
/var/www/cobbler/images # 导入的系统镜像启动文件
/var/www/cobbler/repo_mirror # yum源存储目录
/var/log/cobbler # 日志目录
/var/log/cobbler/install.log # 客户端系统安装日志
/var/log/cobbler/cobbler.log # cobbler日志
4.启动 cobbler与httpd
[root@zobbler ~]# systemctl start cobblerd.service
[root@zobbler ~]# systemctl enable cobblerd.ervice
[root@zobbler ~]# systemctl start httpd.service
[root@zobbler ~]# systemctl enable httpd.service
5.语法检查
[root@zobbler ~]# 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 zobbler, 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : 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.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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.
-
解决报错
[root@zobbler ~]# sed -i 's/server: 127.0.0.1/server: 你的ip地址/' /etc/cobbler/settings [root@zobbler ~]# sed -i 's/next_server: 127.0.0.1/next_server: 你的ip地址/' /etc/cobbler/settings [root@zobbler ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings [root@zobbler ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings [root@zobbler ~]# sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'cobbler' '123456'`\"#" /etc/cobbler/settings [root@zobbler ~]# sed -i 's#yes#no#' /etc/xinetd.d/tftp [root@zobbler ~]# systemctl start rsyncd [root@zobbler ~]# systemctl enable rsyncd [root@zobbler ~]# systemctl start tftp.socket [root@zobbler ~]# systemctl enable tftp.socket [root@zobbler ~]# systemctl start cobblerd.service [root@zobbler ~]# systemctl enable cobblerd.service [root@zobbler ~]# sed -i.ori 's#192.168.1#你的网段#g;22d;23d' /etc/cobbler/dhcp.template [root@zobbler ~]# systemctl restart cobbler.service
7.debian 相关
[root@zobbler ~]# sed -i 's|@dists=.*|#@dists=|' /etc/debmirror.conf [root@zobbler ~]# sed -i 's|@arches=.*|#@arches=|' /etc/debmirror.conf
8.密码相关
[root@zobbler ~]# openssl passwd -1 -salt '想要的用户' '想要的密码' $1$CLSN$LpJk4x1cplibx3q/O4O/K/ #替换密码 [root@zobbler ~]# vim /etc/cobbler/settings default_password_crypted: "$1$CLSN$LpJk4x1cplibx3q/O4O/K/"
9.配置 DHCP服务
[root@zobbler ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings [root@zobbler ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
注意:修改完成之后重启cobbler服务,使用cobbler sync 进行同步,否则不生效。
同步cobbler配置,会修改tftp,dhcp等服务的配置并重启,可以仔细看一下下面的输出
[root@zobbler ~]# systemctl restart cobbler.service
[root@zobbler ~]# cobbler sync
7.验证配置
#再次检查语法
[root@zobbler ~]# cobbler check
No configuration problems found. All systems go.
8 .重启所有服务
[root@zobbler ~]# systemctl restart httpd.service
[root@zobbler ~]# systemctl restart cobblerd.service
[root@zobbler ~]# systemctl restart dhcpd.service
[root@zobbler ~]# systemctl restart rsyncd.service
[root@zobbler ~]# systemctl restart tftp.socket
[root@zobbler ~]# mkdir /mnt/centos7.6
[root@zobbler ~]# mount -t iso9660 -o loop 镜像所在目录 /mnt/centos7.6
[root@zobbler ~]# cobbler import --path=/mnt/centos7.6 --name=CentOS-7.6-1810 --arch=x86_64
task started: 2019-07-24_050656_import
task started (id=Media import, time=Wed Jul 24 05:06:56 2019)
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.6-1810-x86_64:
creating new distro: CentOS-7.6-1810-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64 -> /var/www/cobbler/links/CentOS-7.6-1810-x86_64
creating new profile: CentOS-7.6-1810-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.6-1810-x86_64 for CentOS-7.6-1810-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64/repodata
*** TASK COMPLETE ***
9.创建ks文件
[root@zobbler ~]# cd /var/lib/cobbler/kickstarts
[root@zobbler ~]# mv sample_end.ks sample_end.ks.back
[root@zobbler ~]# vim Centos7.6.ks
# 最小化安装
# cat /var/lib/cobbler/kickstarts/centos7u6-x64.ks
#Kickstart Configurator for cobbler by Jason Zhao
#platform=x86, AMD64, or Intel EM64T
#System language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --fstype="swap" --size 2048 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth --useshadow --enablemd5
#Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=em1 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
# 当使用 最小化镜像安装的时候 不需要下面这一段
%packages
@ base
@ core
sysstat
iptraf
vim
net-tools
tree
yum-utils
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end
%post
systemctl disable postfix.service
%end
图形化安装 的ks
# 图形化安装
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
# 上面所获得的密码
rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1
# Use network installation
url --url="$tree"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=eth0
network --bootproto=dhcp --device=eth1
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="xfs" --size=1024
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1
%packages
@base
@core
@compat-libraries
@debugging
@development
@gnome-desktop
@X Window System
%end
查看 kickstart的配置
[root@zobbler ~]# cobbler profile report --name=CentOS-7.6-1810-x86_64
Name : CentOS-7.6-1810-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.6-1810-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 # 这里还是默认的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
3.修改指定文件
#查看
[root@zobbler ~]# cobbler profile list
CentOS-7.6-1810-x86_64
[root@zobbler ~]# cobbler profile edit --name=CentOS-7.6-1810-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7.6.ks
#修改centos配置文件中的kickstart值
[root@zobbler ~]# # cobbler profile edit --name=CentOS-7.6-1810-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@zobbler ~]# cobbler sync
4 重启服务
[root@zobbler ~]# systemctl restart dhcpd xinetd cobblerd tftp
-
添加system值
[root@zobbler ~]# cobbler system add --name=default --profile=CentOS-7.6-1810-x86_64 [root@zobbler ~]# cobbler system list default [root@zobbler ~]# cobbler sync [root@zobbler ~]# cat /var/lib/tftpboot/pxelinux.cfg/default DEFAULT menu PROMPT 0 MENU TITLE Cobbler | http://cobbler.github.io/ TIMEOUT 200 TOTALTIMEOUT 6000 ONTIMEOUT CentOS-7.6-1810-x86_64 LABEL local MENU LABEL (local) MENU DEFAULT LOCALBOOT -1 LABEL CentOS-7.6-1810-x86_64 kernel /images/CentOS-7.6-1810-x86_64/vmlinuz MENU LABEL CentOS-7.6-1810-x86_64 append initrd=/images/CentOS-7.6-1810-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://10.10.1.13/cblr/svc/op/ks/profile/CentOS-7.6-1810-x86_64 ipappend 2 MENU end