(cobbler+pxe)集群快速部署linux(实战)

需求场景

实验室有多台服务器在机柜里,如果一台一台装,会十分麻烦。给出解决方案。cobbler+pxe

网络环境

服务器由一台三层交换机管理,2vlan.
如有使用路由器,记得关闭路由器dhcp功能
地址段为,192.168.1.0/24192.168.2.0/24
服务器有2张网卡,默认使用第一张。
在部署前需关闭交换机DHCP功能。

cobbler所需组件介绍

需部署的服务

cobblercobbler 的核心)
httpd (提供 cobblerweb 界面)
dhcpd (为自动安装系统分配 IP 地址)
epel-release(为之提供yum源)
rsynccobbler 需要同步信息)
cobbler-webcobbler 的一个 web 插件)
xinetd (为 rsynctftp 的守护进程)
tftp (传送安装的一些文件的 类似ftp

基本环境部署

1.关闭防火墙和 selinux

systemctl stop firewalld
systemctl disable firewalld
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

2.cobbler 安装

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install cobbler cobbler-web tftp-server dhcp httpd xinetd

3.加入开机自启并启动

systemctl enable httpd cobblerd
systemctl start httpd cobblerd

4.满足部署要求

输入cobbler check,会出现很多提示,我们一一解决

如下:

The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.</font>

这里我们设置为可以动态配置

sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings
grep allow_dynamic_settings /etc/cobbler/settings 
systemctl restart cobblerd

开始解决问题
1.`cobbler setting edit --name=server --value=你当前服务器ip地址`
2.`cobbler setting edit --name=next_server --value=你当前服务器ip地址`
3.sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
  systemctl enable xinetd
  systemctl restart xinetd
4. cobbler get-loaders
5. systemctl start rsyncd
   systemctl enable rsyncd
6.可选
7.yum -y install pykickstart
8.重装后系统的默认密码配置
  openssl passwd -1 -salt `openssl rand -hex 4` '000000'(密码60)
  $1$5b2b9b6c$jS20zul6Vx0eoeu.ejFKo0(复制这个)
  cobbler setting edit --name=default_password_crypted --value=''$1$5b2b9b6c$jS20zul6Vx0eoeu.ejFKo0"
9.yum -y install fence-agents

DHCP配置

cobbler setting edit --name=manage_dhcp --value=1
vim /etc/cobbler/dhcp.template

直接修改cobbler的dhcp配置,他会直接覆盖
在这里插入图片描述
同步cobbler配置,它会根据配置自动修改dhcp等

cobbler sync

这个时候可以新建一个虚拟机,桥接模式测试下是否出现如下页面,注意不要挂载光驱
(此页面为成功页面)在这里插入图片描述

部署Centos7

首先你需要上传镜像
我这里的镜像为:	Centos7-2009-x86_64
挂载到任意目录

镜像导入cobbler命令

cobbler import --path=镜像路径 --name=centos7.9 --arch=x86_64

查看镜像

 cobbler distro report --name=centos7.9-x86_64

写入安装脚本

 vim /var/lib/cobbler/kickstarts/centos7.ks

如下:

# Install OS instead of upgrade
install
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  Asia/ShangHai
#Root password
rootpw --iscrypted $default_password_crypted
# System authorization information
auth  --useshadow  --enablemd5
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Use network installation
url --url=$tree

# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
#建议自行修改分区
clearpart --all --initlabel
part /boot --fstype=xfs --size=1000
part swap --fstype=swap --size=2048
part / --fstype=xfs --grow --size=20000

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --disable
# Reboot after installation
reboot


%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
$SNIPPET('func_install_if_enabled')
@core
@base
tree
nmap
wget
lftp
lrzsz
telnet
%end

%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps

sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
%end

指定配置文件

 cobbler profile edit --name=centos7.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks

同步cobbler

cobbler sync

服务器重启BIOS开启pxe(测试机最低配置双核2G运)显示如下界面,回车,开始安装。
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

霖宇长清

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值