首页 > 代码库 > centos7实现批量部署

centos7实现批量部署

手动安装或cobbler

手动

需要安装dhcp。vsftp。ftp。xinetd。。。。。。

yum install dhcp 

vi /etc/dhcp/dhcpd.conf

ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.1.144 192.168.1.147; #段
option domain-name-servers 8.8.8.8,192.168.1.1; #dns服务
option subnet-mask 255.255.255.0; #掩码
option time-offset -18000; #租用时间
option routers 192.168.1.1; #吓一跳,网关
default-lease-time 21600; #默认时间
max-lease-time 43200; #最大租用时间
next-server 192.168.1.142;
filename "pxelinux.0";
}
~

yum install tftp tftp-server syslinux vsftp

yum intall xinetd cvs-inetd.noarch

 

vi /etc/xinetd.d/tftp 

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

 

mkdir /tftpboot

cp /usr/share/syslinux/pxelinux.0 /tftpboot

chcon -R -t tftpdir_rw_t /tftpboot

cd /run/media/root/CentOS\ 7\ x86_64/images/pxeboot/

cp vmlinuz initrd.img /tftpboot/

mkdir /tftpboot/pxelinux.cfg

vi /tftpboot/pxelinux.cfg/default

default 0
prompt 1
timeout 300
display boot.msg
label 0
localboot 0
label 1
kernel vmlinuz
append initrd=initrd.img noipv6 ks=ftp://192.168.1.142/ks.cfg

#label 2
#kernel vmlinuz
#append initrd=initrd.img noipv6 ks=ftp://192.168.1.142/ks.cfg

 

chmod 644 /tftpboot/pxelinux.cfg/default

在/tftp下写boots.ms     可以用第三方源 toilet

 

vi /var/ftp/ks.cfg  #执行权限  也可以拷贝anaconda-ks.cfg 

#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
url --url=ftp://192.168.1.142/centos7
graphical
firstboot --disabled
ignoredisk --only-use=sda
keyboard --vckeymap=cn --xlayouts=‘cn‘
lang zh_CN.UTF-8
network --bootproto=dhcp --device=eno16777736 --ipv6=auto --activate
network --hostname=localhost.localdomain
reboot
rootpw --iscrypted $6$YomC4kOQc438psZU$H8ugJ2Oo3ilFec3wav6U584s3tlcjnR1BpRTZvoAiLcQt33r3tnNzNgA0cFzJ.6GBWNnMMpuj/Mun9fStIjji0
timezone Asia/Shanghai --isUtc
bootloader --location=mbr --boot-drive=sda
clearpart --all --initlabel
part /boot --fstype="xfs" --ondisk=sda --size=500
part pv.409 --fstype="lvmpv" --ondisk=sda --size=32296
volgroup JUNXI --pesize=4096 pv.409
logvol swap --fstype="swap" --size=4096 --name=swap --vgname=JUNXI
logvol / --fstype="xfs" --size=20000 --name=root --vgname=JUNXI
logvol /home --fstype="xfs" --size=8192 --name=home --vgname=JUNXI

%packages
@core
@development

%end

%addon com_redhat_kdump --disable --reserve-mb=‘auto‘

%end

 

 

cp /run/media/root/CentOS\ 7\ x86_64/ /var/ftp/centos7  #拷贝镜像

 

ksvalidator /var/ftp/ks.cfg   #检测

 

 

67 systemctl restart dhcpd
68 systemctl enable dhcpd
69 systemctl restart xinetd.service
70 systemctl enable xinetd.service
71 systemctl restart vsftpd
72 systemctl enable vsftpd
73 lsof -i:21
74 lsof -i:69
75 lsof -i:67

 

技术分享

centos7实现批量部署