Manage server IP address and host name in DHCP+DNS mode. Before the server is put on the shelf, based on its MAC address, configure the host reservation in DHCP and assign the host name. DHCP combines with the PXE service provided by TFTP to provide PXE booting the Linux kernel and boot mirroring, and realize the automatic installation and configuration of the operating system through the automatic answer file.
Basic process
1), PXE Client starts from its own PXE network card, and asks for IP from the DHCP server in the network;
2), DHCP server returns the IP assigned to the client * And the place where the PXE file is placed (the file is usually placed on a TFTP server);
3), PXE Client asks for the pxelinux.0 file from the TFTP server in the network;
4), PXE Client obtains Execute the file after pxelinux.0 file;
5) According to the execution result of pxelinux.0, load the kernel and file system through the TFTP server;
6) Enter the installation screen, and you can select HTTP, One of FTP and NFS installation methods;
①??PXE? client sends UDP broadcast request UDP (Simple User Datagram Protocol) sends a broadcast request to obtain an IP from the DHCP server in the network.
②?? The DHCP server provides information
The DHCP server receives the request from the client and verifies whether the request is from a legitimate PXE client, and verifies that it will give the client a “provide” response, this “provide” response It contains the IP address assigned to the client, the location of the pxelinux startup program (TFTP), and the location of the configuration file.
③?? PXE client requests to download the startup file
After receiving the “response” from the server, the client will respond with a frame to request the transmission of the files required for startup. These startup files include: pxelinux.0, pxelinux.cfg/default, vmlinuz, initrd.img and other files.
④?? The TETP server responds to client requests and transmits files
When the server receives the client’s request, there will be more information between them to respond between the client and the server to decide to start parameter. BootROM uses TFTP communication protocol to download the necessary files (pxelinux.0, pxelinux.cfg/default) from the tftp server to start the installation program. After the default file is downloaded, the boot kernel of the Linux installer will be started according to the boot sequence defined in the file.
⑤?? Request to download the automatic response file
After the client successfully boots the Linux installation kernel through the pxelinux.cfg/default file, the installer must first determine what installation medium you use to install linux, if it is installed over the network (NFS, FTP, HTTP), the network will be initialized at this time and the installation source location will be located. Then it will read the location of the automatic response file ks.cfg specified in the default file, and request to download the file according to the location.
⑥ Install the operating system on the client
After downloading the ks.cfg file, find the http mirror through the file, and download the software package required for the installation process according to the configuration request of the file.
After the connection between the http mirror and the client is established, the software package will be transferred and the client will start to install the operating system
1)
Install the Tftp service tftp-server tftp
cat /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no #Need to be modified
per_source = 11
cps = 100 2
flags = IPv4
}
? Boot file-pxelinux.0
? Kernel file: vmlinuz initrd.img
? Boot menu: isolinux.cfg Rename to generate /var/lib/tftpboot/pxelinux .cfg/default
1. Copy the files to the /var/lib/tftpboot directory
yum -y install syslinux
cp?-rf?/usr/share/syslinux/*? /var/lib/tftpboot # Need pxelinux.0
2. Import the kernel and menu files (can be copied from the CD mirror ISO image)
Kernel file: vmlinuz initrd.img
Boot menu configuration file: isolinux.cfg–→ pxelinux .cfg/default
One of the two window modules that come with the system: vesamenu.c32 (required)
Window prompt information file: boot.msg (optional)
Window background image: splash.png ( Optional)
Copy from the CD image (isolinux) to the tftp root directory
Create the pxelinux.cfg directory and copy isolinux.cfg as default modification
You can create multiple label so that there are multiple choices
Imitate the CD-ROM boot configuration file and select local boot by default, with a larger timeout setting
[[emailprotected] /var/lib/tftpboot] # cat pxelinux.cfg/default < br />default vesamenu.c32
timeout 600
menu title #### PXE Boot Menu ####
label 1
menu label ^Install CentOS 7 x64
menu default
kernel vmlinuz
append initrd=initrd.img ip=dhcp inst.ks=ftp://192.168.36.1/ pub/ks.cfg
The defualt file specifies the ks path for system automatic installation
label 3menu label ^3) Install CentOS 7 x64 with Local Repo using VNC
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://192.168.100.1/pub? (devfs=nomount inst.vnc inst.vncpassword=password) the specified option?
cobbler startup menu
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | auto os installtion
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
LABEL Centos7.2-x86_64
kernel /images/ Centos7.2-x86_64/vmlinuz
MENU LABEL Centos7.2-x86_64
append initrd=/images/Centos7.2-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http:// 127.0.0.1/cblr/svc/op/ks/profile/Centos7.2-x86_64
ipappend 2
MENU end
2) dhcp configuration dhcp
subnet 192.168.36.0 netmask 255.255.255.0 {
range 192.168.36.100 192.168.36.120;
option routers 192.168.36.1;
default-lease-time 600 ;
max-lease-time 7200;
next-server 192.168.36.1; #pxelinux.0’s location
filename “pxelinux.0” ;
}
Bind the network card to start the DHCP service in the case of multiple network cards
cat /usr/lib/systemd/system/dhcpd.service
[ Service]Type=notifyExecStart=/usr/sbin/dhcpd?-f -cf?/etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd –no-pid eno33554984
3) Install vsftpd< /p>
In order to copy the CD system into it
Copy ks.cfg to the ftp root directory and generate it by system-config-kickstart
url –url=” ” The directory where the system is located
[[email protected] /var/ftp/pub] # cat ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard'us'
# Root password
rootpw --iscrypted $1$Xn4pvDTh$GfSGHsPCHomsp88ZRR6/H/
# Use network installation
url --url="ftp://192.168.36.1/pub"
# System language< br />lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Africa/Abidjan
# System bootloader configuration< br />bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=2048part / --fstype="xfs" --grow --size=1
(anaconda-ks.cfg)
Kickstart file (?ksvalidator) for verification
system- config-kickstart graphic configuration generation
Automatic installation via CD
https://www.cnblogs.com/liwei0526vip/p/6416225.html
pxe< /p>
https://www.cnblogs.com/liwei0526vip/p/6386718.html
cobbler
Cobbler/Cobblerd
add extend repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc /yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
Need epel and yum source
yum install cobbler cobbler -web dhcp tftp-server pykickstart httpd xinetd -y
systemctl start httpd
systemctl start xinetd
systemctl start tftp
systemctl start cobblerd
Execute cobbler check< /p>
Generate encrypted password
openssl passwd -1
Configuration that needs to be modified
sed -i’s%^server: 127.0.0.1%server: 192.168 .0.238%g’ /etc/ cobbler/settings # Native ip
sed -i’s%^next_server: 127.0.0.1%next_server: 192.168.0.238%g’ /etc/cobbler/settings # Native ip
sed -i’s% manage_dhcp: 0%manage_dhcp: 1%g’ /etc/cobbler/settings #Takeover dhcp
sed -i’s%^default_password_crypted.*%default_password_crypted: “$1$V0M16k3j$XMyrGlBjyCk1q.MZxQlBl.”%g /cobbler/settings
Modify dhcp.templates subnet information
cobbler check
cobbler get-loaders
{The download is pxelinux.0 menu. c32 menu, etc. /var/lib/cobbler/loaders/}
cobbler sync synchronization
Mount the CD, import the mirror
cobbler import –path=/mnt –name =Centos-7.2 –arch=x86_64 (installation source)
cobbler list
Import the ks.cfg file to /var/lib/cobbler/kickstarts
View details: cobbler repo (install Source, ks.cfg)
After writing ks file, first pass validateks to test for grammatical errors
cobbler validateks
Check the ks file through the following command, Found some logical problems
cobbler system getks –name=test
cobbler profile edit –name Ce ntos-7.2-x86_64 –kickstart=/var/lib/cobbler/kickstarts/ks.cfg # Edit profile, ks.cfg
Add system parameters
cobbler profile edit –name Centos-7.2 -x86_64 –kopts=’net.ifnames=0 biosdevname=0′
Add yum source
cobbler profile edit –name=Centos-7.3-x86_64 –repos=”Centos-7.3-x86_64-os Centos -7.3-x86_64-updates Centos-7.3-x86_64-extras Centos-7-epel-x86_64 Centos-7.3-x86_64-cloud-l Centos-7.3-x86_64-gfs zabbix3.0-Centos7″
cobbler profile report
cobbler sync
Customize the URL displayed when you choose to install the system
cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu< br> PROMPT 0
MENU TITLE Cobbler | System automation deployment
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
???????? MENU LABEL (local )
???????? MENU DEFAULT
???????? LOCALBOOT -1
$pxe_menu_items
MENU end
[[emailprotected] cobbler]# cobbler sync # After synchronization, you can see the effect
Install the system according to MAC
cobbler system add ?
–name=linux -web01 –mac=00:0C:29:3B:03:9B –profile=Ce ntos-7.2-x86_64 –ip-address=10.0.0.200 –subnet=255.255.255.0 –gateway=10.0.0.2 –interface=eth0 –static=1 –hostname=linux-web01 –name-servers =”10.0.0.2″ –kickstart=/var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg
system add? #? Add custom system
name? # Custom system name
mac # mac address
profile #specify profile
ip-address #specify IP address
subnet #specify subnet mask
gateway #specify gateway
interface #specify network card, eth0 The above configuration has been modified, centos7 default network card name is not eth0
static # 1 means to enable static IP
hostname # define hostname
name-server # dns server
kickstart # specify ks file
< p>¥¥¥¥¥¥¥¥¥
Object Type
Distros (release version): represents an operating system that carries information about the kernel and initrd, as well as the kernel Generate parameters and other data
Profile: Contains a release version, a kickstart file and possible storage libraries, and also contains more specific kernel parameters and other data.
Systems: Means to be provisioned The amount of machine. It contains a configuration file or a scene, and also contains IP and MAC addresses, power management (address, credentials, type), (network card binding, setting valn, etc.)
Repository: save a yum or rsync repository Image information of
Image (repository): Can replace a release object that contains files that do not belong to this category (for example, objects that cannot be divided into kernel and initrd).
Important directories and object relationships
/var/www/cobbler/ks_mirror stores operating system mirrors
/var/www/cobbler/repo_mirror stores warehouse mirrors
/var/lib/cobbler /kickstarts stores kickstarts files
/var/lib/cobbler/loaders stores files needed at startup
/var/lib/cobbler/snippets stores scripts
/etc/cobbler stores cobbler configuration files
Configuration
Cobbler still needs:
Optimize the script after startup
Yum source
Automatically configure the IP address according to the MAC address.
Create a local yum source
Configuration file directory:
/etc/cobbler
/etc/cobbler/settings: cobbler main configuration file
/etc/cobbler /iso/: iso template configuration file
/etc/cobbler/pxe: pxe template file
/etc/cobbler/power: power configuration file
/etc/cobbler/user.conf: web service authorization configuration File
/etc/cobbler/users.digest: User name and password configuration file for web access
/etc/cobbler/dhcp.template: Final configuration of dhcp server
/etc/cobbler/dnsmasq. template: dns server configuration template
/etc/cobbler/tftpd.template: tftp service configuration template
/etc/cobbler/modules.conf: module configuration file
data directory:
/ var/lib/cobbler/config/: used to store distros, system, profiles and other information configuration files
/var/lib/cobbler/triggers/: used to store user-defined cobbler commands
/var/lib/ cobbler/kickstart/: store kickstart files by default
/var/lib/cobbler/loaders/: store various boot program mirror directories
/var/www/cobbler/ks_mirror/: import all the data of the distribution system
/var/www/cobbler/images/: Import the kernel and initrd images of the distribution for remote network startup
/var/www/cobbler/repo_mirror/: yum warehouse storage directory
Log directory:< br> /var/log/cobbler/installing: Client installation log
/var/log/cobbler/cobbler.log: Cobbler log
Common commands
Introduction to cobbler commands
cobbler check Check whether there is a problem with the current settings
cobb ler list lists all cobbler elements
cobbler report lists the detailed information of the elements
cobbler sync synchronizes the configuration to the data directory, and it is best to change the configuration.
cobbler reposync synchronizes the yum warehouse
cobbler distro View system information of the imported release
cobbler system View added system information
cobbler profile View configuration information
一
Important parameter settings in /etc/cobbler/settings
Modifications needed
default_password_crypted: “$1$gEc7ilpP$pg5iSOj/mlxTxEslhRvyp/”
manage_dhcp:1
manage_tftpd:1
pxe_just_once:1
next_server:< tftp server IP address>
server:
configuration cobbler–DHCP
1, vim /etc/cobbler/settings # Modify the parameters in the settings, which is controlled by cobbler dhcp
manage_dhcp: 1
2, vim /etc/cobbler/dhcp.template
After modifying the configuration file The service must be restarted and the sync configuration is synchronized
systemctl restart cobblerd.service
cobbler sync
Environment check error resolution
Change the server in the /etc/cobbler/settings file> cobbler ip or host Name
Change the next_server in the /etc/cobbler/settings file to the host ip that provides PXE
When you can access the Internet, execute cobbler get-loaders, otherwise copy
/usr/share/syslinux/ {pxelinux.0,memu.c32} and other files to the /var/lib/cobbler/loaders/ directory
Execute “openssl passwd -1 to generate a password, and use it instead Change the value of the
default_password_crypted parameter in the /etc/cobbler/settings file
openssl passwd -1
-1 Use the MD5 based BSD password algorithm 1.
## ##############################
Courseware
Download Start Menu
Networking :Cobbler get-loaders
Not connected: cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot
Management distro
cobbler import –name=centos- 7.5-x86_64 –path=/media/cdrom –arch=x86_64
Manage profile
cobbler profile add –name=centos-7.5 –distro=centos-7.5-x86_64 –kickstart = /var/lib/cobbler/kickstarts/centos7_x86_64.cfg
View profiles
cobbler profile list
Sync cobbler configuration
cobbler sync
########################
Second
Mount CD image import
cobbler import- -path=/mnt –name=Centos-7.2 –arch=x86_64 # cobbler import mirror
–path mirror path
–name define a name for the installation source
– -arch specifies that the installation source is 32-bit, 64-bit, and ia64. The currently supported options are: x86│x86_64│ia64
The only label of the installation source is defined according to the name parameter. After the import is successful in this example, the only label of the installation source is: CentOS-7.1-x86_64. If repeated, the system will prompt Import failed
View
cobbler list
Three
Import kickstarts
/var/lib/cobbler/kickstarts
View information cobbler report
Use cobbler validataks to verify
cobbler system getks –name=test
cobbler profile list
Specify ks file
cobbler profile edit –name Centos-7.2-x86_64 –kickstart=/var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg # Edit the profile and modify the ks file to be the one we just uploaded Centos7.2-x86_64.cfg
cobbler profile edit –name Centos-7.2-x86_64 –kopts=’net.ifnames=0 biosdevname=0′
Sync cobbler
cobbler sync
Open the service
httpd
tftp
dchp
xinetd
cobblerd
koan realizes reinstallation of the system
p>
Install koan on the client (source must be configured) epel source configuration
View the configuration file on cobbler
koan –server=serverIP –list=profiles
Reinstall the system
koan –replace-self –server=10.0.0.101 –profile=webserver1
ks.cfg configuration template
Centos-7.3-x86_64.cfg
Kickstart Configurato r by BrandynX
platform=x86, AMD64, or Intel EM64T
System language h1>
lang en_US
System keyboard
keyboard us
Install OS instead of upgrade
install
Use text mode install
text
< h1 id="sytem-timezone">Sytem timezone
timezone Asia/Shanghai
Use NFS installation Media
url –url=$tree
Root password
rootpw –iscrypted $default_password_crypted
Network information
$SNIPPET(‘network_config’)
network –bootproto=dhcp –device =eth0 –onboot=on
System authorization infomation
auth –useshadow –enablemd5
Fire wall configuration
firewall –disabled
SELinux configuration
selinux –disabled
Reboot after installation
reboot
System bootloader configuration
bootloader –location=mbr< /p>
Clear the Master Boot Record
zerombr
Partition clearing information
clearpart –all –initlabel
Disk partitioning information
part /boot –fstype xfs – size 1024 –ondisk sda
Oracle:part swap –size 16384 –ondisk sda
part swap –size 2048 –ondisk sda
part / –fstype xfs –size 1 –grow –ondisk sda
Do not configure XWindows
skipx
%pre
$SNIPPET(‘log_ks_pre’)
$SNIPPET(‘kickstart_start’)
$S NIPPET(‘pre_install_network_config’)
Enable installation monitoring
$SNIPPET(‘pre_anamon’)
%end
Package install information
%packages
@base
@core
@fonts
@performance tools
%end p>
%post
$yum_config_stanza
wget -O /tmp/c7_op_script.tar.gz http://192.168.0.238/c7_op_script.tar.gz
cd /tmp && tar xzf c7_op_script. tar.gz
chmod +x -R /tmp/c7_op_script/*
cd /tmp/c7_op_script/sys_optimiz && /bin/sh -x centos7_optimiz.sh
%end
Place the optimization script on the website , Download and execute directly
[[email protected] ~]# cat anaconda-ks.cfg
#platform=86, AMD64, or Intel EM64T
#version= DEVEL
# System authorization information
auth --useshadow --passalgo=sha512
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.36.73/cobbler/ks_mirror/Centos-7.3-x86_64/"
# Use graphical install
graphical
# Firewall configuration
firewall --enabled
firstboot --disable
ignoredisk --only-use=sda
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=eth0 --activate
network --hostname=localhost.localdomain
# Halt after installation
halt
# Root password
rootpw --iscrypted $1$J7vTcYGq$uQYp8XPJVDuside2VcR9W.
# SELinux configuration
selinux --disabled
# System services
services --enabled="chronyd "
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --append= "net.ifnames=0 biosdevname=0 crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=953
part pv.352 --fstype="lvmpv" --ondisk=sda --size=19526
volgroup centos --pesize=4096 pv.352
logvol / --fstype="xfs" --size=9536 --name=root --vgname=centos
logvol swap --fstype="swap "--size=953 --name=swap --vgname=centos
logvol /data --fstype="xfs" --size=9022 --name=data --vgname=centos
< br />%packages
@^minimal
@core
chrony
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
[[emailprotected] ~]# cat original-ks.cfg
#platform =x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard'us'
# Root password
rootpw --iscrypted $1$J7vTcYGq$uQYp8XPJVDuside2VcR9W.
# Use network installation
url --url="http://192.168.36.73/cobbler/ks_mirror/Centos-7.3 -x86_64/"
# System language
lang en_US
# System authori zation information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --enabled
# Network information
network --bootproto=dhcp --device= eth0
# Halt after installation
halt
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --append="net.ifnames =0 biosdevname=0" --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype=" xfs" --size=1024
part / --fstype="xfs" --size=20480
part swap --fstype="swap" --size=1024
part /data --fstype="xfs" --grow --size=1
https://www.cnblogs.com/lynk/p/10480685.html
https://www.cnblogs. com/linuxliu/p/7668048.html
https://blog.51cto.com/bigboss/2060414
https://blog.csdn.net/liuyanwuyu/article/ details/80630275