1、配置chrony服务,实现服务器时间自动同步

(1)、手动实现

date -s "2 year"
ntpdate ntp.aliyun.com

(2)、ntp服务实现

*服务器端:192.168.48.6
vim /etc/ntp.conf
#restrict default kod nomodify notrap nopeer noquery加注释
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
\
chkconfig ntpd on
service ntpd start
chkconfig --list |grep ntp
\
*客户端
vim /etc/ntp.conf
server 192.168.48.6 iburst

systemctl start ntpd
systemctl enable ntpd
ntpq -p

(3)chrony服务实现

mount /dev/sr0 /mnt/
yum clean all
yum install chrony -y
\
cat > /etc/chrony.conf <<EOF
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 192.168.48.0/24
local stratum 10
logdir /var/log/chrony
EOF
\
systemctl start chronyd
systemctl enable chronyd

2、实现cobbler+pxe自动化装机

(1) 基于PXE安装centos6(PEX网卡内置了TFTP,DHCP客户端)

安装前准备 ==关闭防火墙和SELINUX,DHCP服务器静态IP 网络要求:关闭Vmware软件中的DHCP服务== 装包 yum install dhcp httpd tftp-server syslinux

配置dhcp cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf vim /etc/dhcp/dhcpd.conf DHCP配置.jpg

准备PXE启动相关文件 cp /usr/share/syslinux/pxelinux.0   /var/lib/tftpboot/ cd /misc/cd/images/pxeboot/ cp vmlinuz initrd.img /var/lib/tftpboot cd /misc/cd/isolinux/ cp boot.msg vesamenu.c32 splash.jpg /var/lib/tftpboot mkdir /var/lib/tftpboot/pxelinux.cfg/ cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/cenots6-default \

vim /var/lib/tftpboot/pxelinux.cfg/centos6-default PXEcentos6启动菜单.jpg \

准备kickstart文件 mkdir /var/www/html/ks/ vim /var/www/html/centos/ks/centos6.cfg ks应答文件.jpg

配置安装包来源:以光盘为例。也可以是来自网络 mkdir -pv /var/www/html/centos/6/os/x86_64 mount /dev/sr1 /var/www/html/centos/6/os/x86_64

systemctl start tftp httpd dhcpd 然后新加一个centos6主机测试 \

(2) 基于PXE安装centos7 装包 yum -y install dhcp httpd tftp-server syslinux system-configkickstart systemctl enable --now httpd tftp dhcpd 配置dhcp cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf vim /etc/dhcp/dhcpd.conf

option domain-name "example.org";
option domain-name-servers 114.114.114.114, 180.76.76.76;

default-lease-time 86400;
max-lease-time 86400;

subnet 192.168.48.0 netmask 255.255.255.0 {
  range 192.168.48.100 192.168.48.200;
  option routers 192.168.48.254;
  next-server 192.168.48.73;
  filename "pxelinux.0";
}

准备PXE启动相关文件 cp /usr/share/syslinux/pxelinux.0   /var/lib/tftpboot/ cd /misc/cd/images/pxeboot/ cp vmlinuz initrd.img /var/lib/tftpboot cd /misc/cd/isolinux/ cp boot.msg vesamenu.c32 /var/lib/tftpboot mkdir /var/lib/tftpboot/pxelinux.cfg/

cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default vim /var/lib/tftpboot/pxelinux.cfg/centos7-default

default menu.c32
timeout 600
menu title PXE INSTALL MENU
label auto
  menu label ^Auto Install CentOS 7
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.48.73/ks/centos7.cfg 
label manual
  menu label ^Manual Install CentOS 7
  kernel vmlinuz
  append initrd=initrd.img inst.repo=http://192.168.48.73/centos/7/os/x86_64
label local   
  menu default 
  menu label ^Boot from local drive
  localboot 0xffff

准备kickstart文件 vim /var/www/html/ks/centos7.cfg

install
xconfig  --startxonboot
keyboard --vckeymap=us --xlayouts='us'
rootpw --iscrypted $1$bpNEv8S5$lK.CjNkf.YCpFPHskSNiN0
url --url="http://192.168.48.73/centos/7/os/x86_64"
lang en_US
auth  --useshadow  --passalgo=sha512
text
firstboot --enable
selinux --disabled
skipx
services --disabled="chronyd"
ignoredisk --only-use=sda
firewall --disabled
network  --bootproto=dhcp --device=ens33
reboot
timezone Asia/Shanghai --nontp
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
zerombr
clearpart --all --initlabel
part swap --fstype="swap" --ondisk=sda --size=3072
part / --fstype="xfs" --ondisk=sda --size=51200
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /data --fstype="xfs" --ondisk=sda --size=30720
%post
useradd wang
%end
%packages
@core
%end

mkdir -pv /var/www/html/centos/7/os/x86_64 mount /dev/sr0 /var/www/html/centos/7/os/x86_64

systemctl start tftp httpd dhcpd

\

2、cobbler实现自动化安装

yum install cobbler dhcp -y systemctl start cobblerd httpd tftp ss -ntlup

生成密码 [root@centos7 ~]#openssl passwd -1 $1$xJa7Z7a7$fT2U.aZXivzZ1OrqvrzQ91 `vim /etc/cobbler/settings next_server: 192.168.48.72 server: 192.168.48.72 default_password_crypted: "$1$xJa7Z7a7$fT2U.aZXivzZ1OrqvrzQ91" manage_dhcp: 1

cobbler get-loaders cobbler sync vim /etc/dhcp/dhcpd.confvim /etc/cobbler/dhcp.template 搜狗截图20210723172621.jpg

cobbler sync systemctl start dhcpd

导入光盘 echo '- - -' > /sys/class/scsi_host/host2/scan lsblk mount /dev/sr1 /mnt/ cobbler import --path=/mnt --name=centos6.10 --arch=x86_64 mount /dev/sr0 /mnt/ cobbler import --path=/mnt --name=centos7.6 --arch=x86_64