在Linux5和6上批量部署系统

时间:2022-01-27 14:51:47

在linux5 的操作系统上同时安装linux5和6的步骤

1﹑首先安装linux6的系统,然后配置yum源,手工书写一个rhel-source.repo文件.文件内容为:
[rhel-source]
name=rhel-source
baseurl=file:///mnt
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

注意:ks文件由于是我的系统,所以大家可以拷贝也可以自己生成一个ks文件

接着安装system-config-kickstart设置linux6的ks文件为ks1.cfg.文件内容为

platform=x86, AMD64, 或 Intel EM64T

version=DEVEL

Firewall configuration

firewall –disabled

Install OS instead of upgrade

install
key –skip

Use network installation

url –url=”http://192.168.139.139/rhel1”

Root password

rootpw –iscrypted 1 EdPUVZB1$vvMCAeyHlsD5.HeeVamNA0

Network information

network –bootproto=dhcp –device=eth0 –onboot=on

System authorization information

auth –useshadow –passalgo=md5

Use text mode install

text
firstboot –disable

System keyboard

keyboard us

System language

lang zh_CN

SELinux configuration

selinux –disabled

Installation logging level

logging –level=info

Reboot after installation

reboot

System timezone

timezone Asia/Shanghai

System bootloader configuration

bootloader –location=mbr

Partition clearing information

clearpart –all –initlabel

Disk partitioning information

part /boot –fstype=”ext4” –size=100
part swap –fstype=”swap” –size=1024
part / –fstype=”ext4” –grow –size=1
%packages
@base
@chinese-support
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@perl-runtime
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@x11
mtools
pax
python-dmidecode
oddjob
sgpio
genisoimage
wodim
abrt-gui
certmonger
pam_krb5
krb5-workstation
nscd
pam_ldap
nss-pam-ldapd
libXmu
perl-DBD-SQLite
%end
设置linux5的ks文件为ks.cfg.文件内容为

platform=x86, AMD64, 或 Intel EM64T

System authorization information

auth –useshadow –enablemd5

System bootloader configuration

bootloader –location=mbr
key –skip

Partition clearing information

clearpart –all –initlabel

Use text mode install

text

Firewall configuration

firewall –disabled

Run the Setup Agent on first boot

firstboot –disable

System keyboard

keyboard us

System language

lang zh_CN

Installation logging level

logging –level=info

Use network installation

url –url=http://192.168.39.39/rhel

Network information

network –bootproto=dhcp –device=eth0 –onboot=on

Reboot after installation

reboot

Root password

rootpw –iscrypted 1 Ao1ROM9A$7XTwKcq6wlE21x9Tnpibt1

SELinux configuration

selinux –disabled

System timezone

timezone Asia/Chongqing

Install OS instead of upgrade

install

X Window System configuration information

xconfig –defaultdesktop=GNOME –depth=32 –resolution=1024x768

Disk partitioning information

part /boot –bytes-per-inode=4096 –fstype=”ext3” –size=100
part swap –bytes-per-inode=4096 –fstype=”swap” –size=1024
part / –bytes-per-inode=4096 –fstype=”ext3” –grow –size=1
%packages
@admin-tools
@base
@chinese-support
@core
@dialup
@editors
@gnome-desktop
@games
@graphical-internet
@graphics
@java
@legacy-software-support
@office
@printing
@sound-and-video
@text-internet
@base-x
kexec-tools
iscsi-initiator-utils
fipscheck
device-mapper-multipath
sgpio
emacs
libsane-hpaio
xorg-x11-utils
xorg-x11-server-Xnest
接着将linux6生成的ks文件拷贝到linux5下的/var/www/html/ 文件名为ks1.cfg

接着在linux5当中进行配置
首先添加两块网卡,两块网卡分别输入同一个vlan下.分别配置ip地址并且添加一个cd光驱,安装http服务,然后将光盘系统分别挂载到/var/www/html/rhel和/var/www/html/rhel1

cd /etc/httpd/conf.d
mv welcome.conf welcome.conf.bak 修改http默认文件
然后安装dhcp服务
yum install dhcp-* -y
vim /etc/dhcpd.conf 修改
修改内容为
ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.39.39;
filename “pxelinux.0”;
subnet 192.168.39.0 netmask 255.255.255.0 {
option routers 192.168.39.39;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.39.128 192.168.39.254;
}
subnet 192.168.139.0 netmask 255.255.255.0 {
option routers 192.168.139.139;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.139.128 192.168.139.254;
}
vim /etc/sysconfig/dhcpd
DHCPDARGS=eth1 将其修改为第二块网卡
修改tftp文件
vim /etc/xinetd.d/tftp
server_args = -s /tftpboot/linux-install/
disables = no
service dhcpd/xinetd restart 重启dhcpd/xinetd 服务

复制linux5的文件到 /tftpboot/linux-install/
cp /var/www/html/rhel/isolinux/vmlinuz /tftpboot/linux-install/
/ var/www/html/rhel /isolinux/initrd.img /tftpboot/linux-install/
cp/var/www/html/rhel/isolinux/isolinux.cfg /tftpboot/linux-install/pxelinux.cfg/default
接着再将linux6的文件拷贝到 /tftpboot/linux-install/
cp /var/www/html/rhel1/isolinux/vmlinuz /tftpboot/linux-install/ vmlinuz1
/ var/www/html/rhel1 /isolinux/initrd.img /tftpboot/linux-install/ initrd1.img
cp/var/www/html/rhel1/isolinux/isolinux.cfg
/tftpboot/linux-install/pxelinux.cfg/网卡的mac地址格式为:01-aa-bb-cc-dd-ee-ff

vim /tftpboot/linux-install/pxelinux.cfg/default
default ks
timeout 3
label ks
kernel vmlinuz
append ks=http://webserverIP/ks.cfg initrd=initrd.img
vim /tftpboot/linux-install/pxelinux.cfg/网卡mac地址生成文件01-aa-bb-cc-dd-ee-ff
default ks1
prompt 1
timeout 3
添加label ks1
kernel vmlinuz1
append ks=http://192.168.139.139/ks1.cfg initrd=initrd1.img
service xinetd restart
service dhcpd restart
service httpd restsrt
service dhcpd restart
最后将所有服务重启批量部署算是完成了.