centos7实现批量部署
Posted 奥特最帅
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 vsftpd
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
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
url --url=ftp://192.168.1.145/centos7
graphical
firstboot --disabled
ignoredisk --only-use=sda
keyboard --vckeymap=cn --xlayouts=\'cn\'
lang en_US.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 ZY --pesize=4096 pv.409
logvol swap --fstype="swap" --size=4096 --name=swap --vgname=ZY
logvol / --fstype="xfs" --size=20000 --name=root --vgname=ZY
logvol /home --fstype="xfs" --size=8192 --name=home --vgname=ZY
%packages
@additional-devel
@base
@compat-libraries
@console-internet
@core
@development
@mail-server
@internet-applications
@large-systems
@load-balancer
@network-file-system-client
@network-tools
@performance
@perl-runtime
@security-tools
@server-platform-devel
@system-management
@system-admin-tools
libXinerama-devel
xorg-x11-proto-devel
startup-notification-devel
libXau-devel
libgcrypt-devel
popt-devel
libXrandr-devel
libxslt-devel
libglade2-devel
gnutls-devel
oddjob
sgpio
mtools
systemtap-client
jpackage-utils
sg3_utils
perl-DBD-SQLite
hmaccalc
ipmitool
fence-agents
pexpect
net-tools
bind-utils
%end
%addon com_redhat_kdump --disable --reserve-mb=\'auto\'
%end
############################################################################################################
# Kickstart file automatically generated by anaconda.
#version=DEVEL
# System authorization information
authconfig --useshadow --enablemd5
# System bootloader configuration
#bootloader --location=gpt --driveorder=cciss/c0d0
install
text
firewall --enabled --port=22222:tcp
# Use network installation
url --url=http://192.168.1.145/centos/7.0/os/x86_64
# Network information
network --bootproto=dhcp --onboot=on
lang en_US.UTF-8
keyboard us
rootpw --iscrypted $6$YomC4kOQc438psZU$H8ugJ2Oo3ilFec3wav6U584s3tlcjnR1BpRTZvoAiLcQt33r3tnNzNgA0cFzJ.6GBWNnMMpuj/Mun9fStIjji0
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --all --drives=sda
#for data
#part /boot --fstype=ext4 --size=500
#part /boot/efi --fstype=efi --size=128 --asprimary --ondisk=sda
#part pv.01 --size=1 --grow
#volgroup VolGroup --pesize=4096 pv.01
#logvol /home --fstype=ext4 --name=lv_data --vgname=VolGroup --grow --size=100
#logvol swap --name=lv_swap --vgname=VolGroup --size=30720
#logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
#for app new
part /boot --fstype=XFS --size=200
part /boot/efi --fstype=efi --size=128 --asprimary --ondisk=sda
part pv.01 --size=1 --grow
volgroup VolGroup --pesize=4096 pv.01
logvol /data --fstype=XFS --name=lv_data --vgname=VolGroup --grow --size=100
logvol swap --name=lv_swap --vgname=VolGroup --size=65536
logvol / --fstype=XFS --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
%packages
@additional-devel
@base
@client-mgmt-tools
@compat-libraries
@console-internet
@core
@development
@mail-server
@ha
@ha-management
@internet-applications
@large-systems
@load-balancer
@network-file-system-client
@network-tools
@performance
@perl-runtime
@system-management-snmp
@scalable-file-systems
@security-tools
@server-platform-devel
@server-policy
@system-management
@system-admin-tools
@net-tools
@bind-utils
libXinerama-devel
xorg-x11-proto-devel
startup-notification-devel
libgnomeui-devel
libbonobo-devel
libXau-devel
libgcrypt-devel
popt-devel
libXrandr-devel
libxslt-devel
libglade2-devel
gnutls-devel
oddjob
sgpio
mtools
systemtap-client
jpackage-utils
sg3_utils
perl-DBD-SQLite
hmaccalc
ipmitool
fence-agents
pexpect
net-tools
bind-utils
%end
%pre
/usr/sbin/parted -s /dev/sda mklabel gpt
%end
%post --log=/mnt/sysimage/root/anaconda-post.log --erroronfail
mkdir -p /boot/efi/EFI/BOOT
\\cp -r /boot/* /boot/efi/
\\cp /boot/efi/EFI/redhat/grub.efi /boot/efi/EFI/BOOT/BOOTX64.efi
\\cp /boot/grub/grub.conf /boot/efi/EFI/BOOT/BOOTX64.conf
\\cp /boot/grub/splash.xpm.gz /boot/efi/EFI/BOOT/splash.xpm.gz
# Disable ipv6
/bin/cat >>/etc/modprobe.conf<<_END_
alias net-pf-10 off
alias ipv6 off
_END_
/bin/sed -i \'s/NETWORKING_IPV6.*$/NETWORKING_IPV6=no/\' /etc/sysconfig/network
/sbin/chkconfig --level 35 ip6tables off
# Set OS limitations
cat >>/etc/security/limits.conf<<_END_
* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535
_END_
cat >>/etc/security/limits.d/90-nproc.conf<<_END_
* soft nofile 65535
* hard nofile 65535
_END_
#echo "30 */8 * * * root (/usr/sbin/ntpdate 192.168.1.142 && hwclock -w) >> /root/hw.log" >>/etc/crontab
groupadd optional
useradd admin -g optional
echo \'123123\'|passwd --stdin admin
#for data
#groupadd hadoop
#useradd hadoop -g hadoop
#echo \'123123\'|passwd --stdin hadoop
/usr/sbin/useradd han -g dev
echo \'123456\' |/usr/bin/passwd han --stdin
chmod +w /etc/sudoers
sed -i \'99i han ALL=(ALL) NOPASSWD: ALL\' /etc/sudoers
chmod -w /etc/sudoers
history -c
/usr/bin/patch /etc/ssh/sshd_config << EOF
13c13
< #Port 22
---
> Port 22222
39a40
> PermitRootLogin no
EOF
/sbin/restorecon /etc/ssh/sshd_config
/etc/init.d/iptables stop
chkconfig --level 345 off
#ntpdate 时间服务器&& hwclock -w
#puppet yum source
wget http://.repo -P /etc/yum.repos.d/
#yum install
###############################################################################################################
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
url --url=ftp://192.168.1.145/centos7
graphical
firstboot --disabled
ignoredisk --only-use=sda
keyboard --vckeymap=cn --xlayouts=\'cn\'
lang en_US.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 ZY --pesize=4096 pv.409
logvol swap --fstype="swap" --size=4096 --name=swap --vgname=ZY
logvol / --fstype="xfs" --size=20000 --name=root --vgname=ZY
logvol /home --fstype="xfs" --size=8192 --name=home --vgname=ZY
%packages
@additional-devel
@base
@compat-libraries
@console-internet
@core
@development
@mail-server
@internet-applications
@large-systems
@load-balancer
@network-file-system-client
@network-tools
@performance
@perl-runtime
@security-tools
@server-platform-devel
@system-management
@system-admin-tools
libXinerama-devel
xorg-x11-proto-devel
startup-notification-devel
libXau-devel
libgcrypt-devel
popt-devel
libXrandr-devel
libxslt-devel
libglade2-devel
gnutls-devel
oddjob
sgpio
mtools
systemtap-client
jpackage-utils
sg3_utils
perl-DBD-SQLite
hmaccalc
ipmitool
fence-agents
pexpect
net-tools
bind-utils
%end
%addon com_redhat_kdump --disable --reserve-mb=\'auto\'
%end
/usr/sbin/useradd han -g
echo \'123456\' |/usr/bin/passwd han --stdin
chmod +w /etc/sudoers
sed -i \'99i han ALL=(ALL) NOPASSWD: ALL\' /etc/sudoers
chmod -w /etc/sudoers
以上是关于centos7实现批量部署的主要内容,如果未能解决你的问题,请参考以下文章