Linux云计算之集群装机

一、PXE 原理

  1. 定义

PXE(Pre-boot Execution Environment)是由 Inter 设计的协议,它可以使计算机通过网络启动。协议分为 client 和 server 两端,PXE client 在网卡的 ROM 中,当计算机引导时,BIOS 把 PXE client 调入内存执行,并显示出命令菜单,经用户选择后,PXE client 将放置在远端的操作系统通过网络下载到本地运行

  1. 安装过程图解

在这里插入图片描述

二、PXE 服务构建

  1. 注意事项

1)虚拟环境中注意是否将自带 DHCP 功能关闭
2)注意测试安装机器是否将网络与 PXE 服务器网络对齐

  1. 安装流程记录

1)安装环境

yum -y install vsftpd dhcp tftp syslinux tftp-server

2)拷贝镜像文件到 ftp 服务器目录

cd /var/ftp/pub
mkdir dvd
chown ftp:ftp dvd
cp -rf /mnt/cdrom/* dvd/

3)配置 DHCP 服务

cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcp.conf
vi /etc/dhcp/dhcpd.conf
	subnet 192.168.16.0 netmask 255.255.255.0 {
		range 192.168.16.66 192.168.16.77;
		option routers 192.168.16.2;
		next-server 192.168.16.130;#tftp server 的 ip 
		filename "pxelinux.0"; 
	}

4)开启 tftp 服务

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

5)创建相关目录并拷贝所需文件

mkdir -p /tftpboot/pxelinux.cfg
cp /var/ftp/pub/dvd/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
cp /usr/share/syslinux/pxelinux.0 /tftpboot/
chmod 644 /tftpboot/pxelinux.cfg/default
cp /var/ftp/pub/dvd/isolinux/* /tftpboot/

6)开启相关服务并设置为自动启动

service dhcpd restart
chkconfig dhcpd on
service xinetd restart
chkconfig xinetd on
service vsftpd restart
chkconfig vsftpd on

7)配置 kisckstart 无人值守安装脚本

yum -y install system-config-kickstart
system-config-kickstart
cp ks.cfg /var/ftp/pub/
vi /tftpboot/pxelinux.cfg/default(添加)
	label linux
		menu label ^Install or upgrade an existing system
		menu default
		kernel vmlimuz
		append initrd=initrd.img ks=ftp://192.168.66.1/pub/ks,cfg
	label vesa
  1. KS 文件模板展示
#platform=x86,AMD64, 或 Inter EM64T
#version=DEVEL
#Firewall configuration
firewall --disabled
#Install OS instead of upgrade
install
#Use network installation
url --url="ftp://10.10.10.11/pub/dvd"
#Root password
rootpw --iscrypted $1$Avf.TcS5$qICcOlYLRtgGRo6z9f1am0
#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 --disabled
#Installation logging level
logging --level=info
#Reboot after installation
reboot
#System timezone
timezone Africa/Abidjan
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype="ext4" --size=600
part swap --fstype="swap" --size=4000
part / --fstype="ext4" --grow --size=1

%post --interpreter=/bin/bash
touch /root/1.txt
echo "123" >> /root/1.txt
echo "123" >> /root/1.txt
%end

%packages
@base
@chinese-support
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
mtools
pax
python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistene-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
%end

三、Cobbler

  1. Cobbler 与 PXE 的不同点

Cobbler 是什么?

Cobbler 是红帽公司研发的基于 PXE 技术的装机服务,可以选着性安装多个不同的操作系统

Cobbler 与 PXE 如何选择?

PXE: 适合环境中只需要安装同一操作系统即可,并且开机后不需介入
Cobbler: 适合环境中有多种操作系统的需求,开机后需人员选择安装的操作系统版本

  1. Cobbler 安装记录
yum install -y epel-release	#配置 epel YUM 源
yum install -y cobbler cobbler-web pykickstart debmirror		#安装 cobbler 所需依赖软件
systemctl restart httpd		#开启 Apache 服务,即是管理页面也是镜像分享服务
systemctl restart cobblerd		#开启 Cobbler 服务
netstat -an | grep 25151
vim /etc/cobbler/settings		#修改 Cobbler 主配置文件
server
next_server
cobbler get-loaders		#向代码主站发起获取必备数据
systemctl enable rsyncd		#开启 rsync,Cobbler 借助 rsync 进行目录之间的内容同步
vim /etc/debmirror.conf		#关闭非常规系统以及 32 位系统的安装
@dists="sid";
#@arches="i386";
openssl passwd -1 -salt $(openssl rand -hex 4)		#创建与系统加密方案一直的密码,用于系统初始化密码
vim /etc/cobbler/settings		#设置默认密码
	default_password_crypted
yum install cman fence-agents		#安装 Cobbler 隔离机制,防止重复安装,centos7 中没有cman 报错正常
vim /etc/xinetd.d/tftp		#开启 tftp 服务器,centos7中需要安装 xinetd 软件包
	disabled 改为 no
systemctl restart cobblerd
cobbler sync		#进行自动同步文件
cobbler check		#进行 Cobbler 自检
yum install -y dhcp
vim /etc/dhcp/dhcpd.conf		#配置并开启 DHCP 服务
	option domain-name "chinasoft.com";
	option domain-name-servers 114.114.114.114,8.8.8.8;
	default-lease-time 43200;
	max-lease-time 86400;
	log-facility local7;
	subnet 20.0.0.0 netmask 255.0.0.0{
		range 20.20.10.10 20.20.10.240;
		option routers 20.20.20.20;
	}
	next-server 20.20.20.20;
	filename="pxelinux.0";
systemctl restart httpd
systemctl enable tftp
systemctl enable dhcpd
systemctl start ftp
systemctl restart cobbblerd
mount -r /dev/cdrom /media
cobbler import --name="centos6.5-x86_64"  -path=/media/		#导入镜像文件至Cobbler 服务中,可以通过访问:http:IP/cobbler/ 看到文件列表
cobbler distro list		#查看已导入镜像
cp anaconda-ks.cfg /var/lib/cobbler/kickstarts/		#拷贝 KS 文件至默认 KS 存放目录
cd /var/lib/cobbler/kickstarts/
vim centos6.5-x86_64.cfg
cobbler profile add -name=centos6.58-x86_64-basic --distro=centos6.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.5-x86_64.cfg		#将已导入镜像文件与 KS 文件进行粘合
cobbler profile list		#查看已有 KS 文件
cobbler sync
cobbler profile remove --name=centos6.7-x86_64		#删除对应的 KS 文件
cobbler distro remove --name=centos6.7-x86_64		#删除对应的镜像文件
  1. Centos6 KS 模板分享
#platform=x86,AMD64, 或 Inter EM64T
#version=DEVEL
#Firewall configuration
firewall --disabled
#Install OS instead of upgrade
install
#Use network installation
url --url="ftp://10.10.10.11/pub/dvd"
#Root password
rootpw --iscrypted $1$Avf.TcS5$qICcOlYLRtgGRo6z9f1am0
#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 --disabled
#Installation logging level
logging --level=info
#Reboot after installation
reboot
#System timezone
timezone Africa/Abidjan
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype="ext4" --size=600
part swap --fstype="swap" --size=4000
part / --fstype="ext4" --grow --size=1

%post --interpreter=/bin/bash
touch /root/1.txt
echo "123" >> /root/1.txt
echo "123" >> /root/1.txt
%end

%packages
@base
@chinese-support
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
mtools
pax
python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistene-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
%end
  1. Centos7 KS 模板分享
#Kickstart Configurator by Jason Zhao
#platform=x86,AMD64,or Inter EM64T
#System language
lang en_US
#System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#rootpw --iscrypted $1$ops-node$7hqdpgEmIE7Z0RbtQkxW20
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url="http://20.20.20.20/cobbler/ks_mirror/CentOS-7-openstack-x86_64/"
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearning information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --size 4000 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorzation information
auth --useshadow --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=on
#Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
%pre
$SNIPPET('log_ks_pre').
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
#Enable installation monitoring
$SNIPPET('pre_anamon')
%end
#Package install information
%packages
@base
@core
%end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值