RHEL7 PXE同时部署多个版本操作系统
在日常企业运维环境中,难免会遇到使用多个Linux操作系统的情况,之前的Kickstart只能安装一种Linux版本的系统, 如果每天都需要安装不同版本的Linux系统的话,怎么办呢?所以下面介绍如何在同一个时刻,使用Kickstart部署不同版本 的Linux操作系统,实验环境同时部署RHEL6,RHEL7,Kickstart用的RHEL7系统; #配置yum源 vim /etc/yum.repos.d/server.repo [base] name=rhel baseurl=file:///mnt enabled=1 gpgcheck=0 #挂在光盘 mount /dev/cdrom /mnt #安装配置DHCP yum -y install dhcp cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf vim /etc/dhcp/dhcpd.conf #dhcp根据实际环境配置 subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.1.200; option domain-name-servers server.example.com; option domain-name "8.8.8.8"; option routers 192.168.1.254; option broadcast-address 192.168.1.255; next-server 192.168.1.89; filename "pxelinux.0"; default-lease-time 60000; max-lease-time 720000; } systemctl restart dhcpd.service #启动dhcp服务 systemctl enable dhcpd.service #随下次开机自动启动该服务 #安装配置tftp-server syslinux yum -y install syslinux tftp-server vim /etc/xinetd.d/tftp disable=no#将yes修改no systemctl restart xinetd.service systemctl enable xinetd.service #复制多系统启动文件 cd /var/lib/tftpboot mkdir rhel6 rhel7 #因为是多系统引导安装所以创建两个不同版本的文件夹,存放不同的引导文件 cd rhel7 #rhel7文件夹里面存放rhel7的引导文件,需要手动挂载rhel7系统光盘拷贝引导文件 cp /mnt/isolinux/init.img . #复制到当前 cp /mnt/isolinux/vmlinuz . cd .. #放回上一级目录 cd rhel6 #rhel6文件夹里面存放rhel6的引导文件,需要手动挂载rhel6系统光盘拷贝拷贝文件 cp /mnt/isolinux/init.img . cp /mnt/isolinux/vmlinuz . cd .. #放回上一级目录 mkdir pxelinux.cfg cd pxelinux.cfg cp /mnt/isolinux/isolinux.cfg ./default #随便使用哪个系统版本的引导菜单都可以使用,复制过来修改名称为default做相应修改即可 vim default #编辑default文件 label rhel7 kernel rhel7/vmlinuz #刚才创建了对应系统版本文件夹,所有vmlinuz前面加上rhel7 append initrd=rhel7/initrd.img inst.ks=nfs:192.168.1.89:/rhel7/ks.cfg #initrd.img前面同样加上rhel7 label rhel6 kernel rhel6/vmlinuz append initrd=rhel6/initrd.img ks=nfs:192.168.1.89:/rhel6/ks.cfg #rhel6的ks命令不一样,前面没有inst. cd .. #返回上一级目录 vim boot.msg #创建一个安装提示文件 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++please enter rhel6 and rhel7 install system++++++ #安装配置NFS yum -y install nfs* #系统默认没有安装则安装nfs服务 mkdir /rhel6 /rhel7 #创建不同目录存放系统对应版本的安装文件 cd /rhel6 nohup cp -a /mnt/* . & #挂载rhel6光盘,在后台拷贝系统文件 cd /rhel7 nohup cp -a /mnt/* . & #挂载rhel7光盘,在后台拷贝系统文件 vim /etc/exports #nfs共享不同版本系统的文件 /rhel6 192.168.1.0/24(rw,sync) /rhel7 192.168.1.0/24(rw,sync) systemctl restart nfs-server.service systemctl enable nfs-server.service #配置Kickstart一键安装应答文件 yum -y install system-config-kickstgart system-config-kickstart #图形化配置应答文件 也可以使用我下面生成的一键安装应答文件,rhel7.0里面没有图像化的安装包选择可以到/root/anaconda-ks.cfg里面 进行拷贝安装图形化的命令到你自己手动创建的ks.cfg文件末行并保存 #rhel6一键安装文件 #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation nfs --server=192.168.1.89 --dir=/rhel6 # Root password rootpw --iscrypted $1$W4PTHaJU$Ru3MaEqhSmCqK6KDigdea. # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux --enforcing # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone Africa/Abidjan # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part / --fstype="ext4" --size=20000 part swap --fstype="swap" --size=2048 part /boot --fstype="ext4" --size=1024 %packages @basic-desktop @desktop-debugging @desktop-platform @fonts @general-desktop @graphical-admin-tools @input-methods @kde-desktop @legacy-x @remote-desktop-clients @x11 %end #rhel7一键安装文件 #platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us'# Reboot after installation reboot # Root password rootpw --iscrypted $1$6W4GNGL7$Cta9ZjhDcgJ3OBrd.iNSU1 # System timezone timezone Africa/Abidjan --isUtc # System language lang en_US # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=eth0 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # SELinux configuration selinux --enforcing # Use NFS installation media nfs --server=192.168.1.89 --dir=/rhel7 # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part / --fstype="xfs" --size=20000 part swap --fstype="swap" --size=4096 part /boot --fstype="xfs" --size=1024 %packages @base @core @desktop-debugging @dial-up @fonts @gnome-desktop @guest-agents @guest-desktop-agents @input-methods @internet-browser @multimedia @print-client @x11 %end #复制生成的一键安装应答文件到不同版本文件夹中 cp ks6.cfg /rhel6 #这是rhel6系统的一键安装应答文件 cp ks7.cfg /rhel7 #这是rhel7系统的一键安装应答文件 #修改SELinux状态 vim /etc/sysconfig/selinux SELINUX=permissive #默认的enforcing修改为permissive setenforce 0 #或者重启系统 #防火墙开放服务和端口号 firewall-cmd --permanent --add-port=111/tcp firewall-cmd --permanent --add-port=111/udp firewall-cmd --permanent --add-port=20048/tcp firewall-cmd --permanent --add-port=20048/udp firewall-cmd --permanent --add-port=69/udp firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=dhcp firewall-cmd --reload #客户端从网络引导做安装测试,在弹出的黑色对话框里面输入rhel6或者rhel7进行安装系统
转载于:https://blog.51cto.com/shanqiangwu/1627379