|NO.Z.00056|——————————|^^ 构建 ^^|——|PXE&cobbler&ks模板.V3|
附录一:
一、PXE服务构建
### --- 注意事项
~~~ 虚拟环境中注意是否将自带DHCP功能关闭
~~~ 注意测试安装机器是否将网络与PXE服务器网络对齐
二、安装流程记录
### --- 安装环境
yum -y install vsftpd dhcp tftp syslinux tftp-server
cd /var/ftp/pub
mkdir dvd
chown ftp:ftp dvd
cp -rf /mnt/cdrom/* dvd/
### --- 配置DHCP服务
cp /usr/share/doc/dhcp-4.1.1/dhcp.conf.sample /etc/dhcp/dhcpd.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",
}
### --- 开启tftp服务
vi /etc/xinetd.d/tftp
service tftp
{
socker_type =dgram
protocol =udp
wait =yes
user =root
server =/usr/sbin/in.tftpd
server_args =-s /tftpboot // 设置默认工作目录
disable =no // 设置开机自启动
per_source =ll
cps =1002
flags =IPv4
}
mkdir /tftpboot
### --- 创建相关目录并拷贝所需文件
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/
### --- 开启相关服务并设置为自动启动
service dhcpd restart
chkconfig dhcpd on
service xinetd restart
chkconfig xinetd on
service vsftpd restart
chkconfig vsftpd on
### --- 配置kisckstart无人值守安装脚本
yum install -y 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 vmlinuz
append initrd=initrd.img
ks=ftp://192.168.66.1/pub/ks.cfg
label vesa
三、KS 文件模板展示
#platform=x86,AMD64,或Intel 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$qICcOlYLRtgGRo6z9flam0
#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 agter 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-applcations
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-client
@server-platform
@server-policy
@workstation-policy
@xll
@mtools
@pax
python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
%end
附录二:
一、Cobbler服务构建
### --- Cobbler优点:
~~~ 搭建更为简答,管理更为便捷
~~~ 能够选择系统版本进行安装
### --- Cobbler与PXE的不同点:
~~~ Cobbler是什么:Cobbler是红帽公司研发的基于PXE技术的装机服务,
~~~ 可以选择性安装多个不同的操作系统
~~~ Cobbler与PXE如何选择:
~~~ PXE:适合环境中只需要安装同一操作系统即可,并且开机后不需介入
~~~ Cobbler:适合环境中有多种操作系统的需求,开机后需要人员选择安装的操作系统版本
二、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 -l -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/dgcp/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 dhcpd
systemctl enable tftp
systemctl enable dhcpd
systemctl start fttp
systemctl restart cobblerd
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.5-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 // 删除对应的镜像文件
三、Centos6KS模板分享
#platform=x86,AMD64或Intel 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$qICcOlYLRtgGRo6z9flam0
#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
@xll
mtools
python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
%end
四、CentosKS模板分享
#Kickstart Configurator by Jason Zhao
#platform=x86,AMD64,or Intel EM64T
#System language
lang_en_US
#System keyboard
keyboard 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 clearing 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 l --grow --ondisk sda
#System authorization 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')
#SNIPPET('pre_anamon')
%end
#Package install information
%packages
@base
@core
%end
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
分类:
cdv001-lbchac
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」