Detailed Installed Linux configuration batch

 项目名称:机房PXE全自动批量装配

Objectives: There are a number of rooms (more than 200) computer, you need to install CentOS 7.5 as its operating system, and deployed Web services .......
Time to complete: to be delivered within 24 hours

    应用场景:

1) XX school room
2) Red Hat certification exam environment
3) business cluster node deployment
4) data center server configuration Batch
Shell Scripts

项目需求:
  1. As the number of machines (such as bare metal) Quick Installation CentOS7 operating system
  2. Through a separate network (do not have other DHCP servers, as necessary, to close the VMware DHCP) to achieve
  3. Organize their own version of Word test report, for a rainy day

    Task analysis
    Task One: Prepare a CentOS7 server
    Task Two: providing DHCP services
    Task three: the client software packages provide resources (Web mode)
    Task four: to provide network boot related files (build TFTP boot server)
    Task Five: PXE test network boot and installation
    tasks six: providing auto-answer file (answer questions during the installation process)
    task 7: client unattended installation test

TFTP, FTP protocol simple (UDP 161)
FTP, TCP 21/20. . .

Knowledge: XX rapid access using the command or description of the profile / manual
man command name
or
man profile name

Run in the English environment XX command line
LANG = XX command line

Shell scripts, long-legged (run their own) text file that contains a lot of executable command line
vim script file
. . . . .
chmod + x script file

相关知识:

PXE, pre-boot environment (the Pre-Excute the Boot Environment)
- default integrated in the chip card BOOTROM (pxeclient)

Additional preparation: PXE server (for the client to install the system, provides the client system)

How to provide a batch installed PXE server-side:
1) the DHCP service to provide IP address, boot server in which to inform, inform obtain a boot file
2) TFTP service, provided to boot the kernel, boot configuration files, etc.
3) HTTP or FTP service provide resources software package CentOS7
4) configured to automatically install

Implementation process

任务一: 准备一台CentOS7服务器

1) configured fixed hostname pxesvr, IP address 192.168.10.7/24
#hostnamectl the SET-hostname pxesvr
#nmcli the Modify Connection ens33 ipv4.method Manual ipv4.addresses 192.168.10.7/24 connection.autoconnect yes
#nmcli Connection up ens33
2) turn off the firewall, disable SELinux protection
#systemctl disable firewalld --now // ban boot from the start, and stop immediately
vim / etc / SELinux / config
SELINUX = disabled
setenforce 0
3) the CentOS7 CD-ROM (if a virtual machine you want to connect good ISO file) mount / mnt / dvd
mkdir / mnt / dvd
#mount / dev / cdrom / mnt / dvd
4) using the / mnt / dvd directory as a temporary source software
rm -rf /etc/yum.repos.d /*.repo
yum-config---add File Manager: /// mnt / DVD
Vim /etc/yum.conf
gpgcheck = 0
yum repolist

!!!! If the current host without a network connection, you need to add a connection, then configure the address
1) find the name (such as ens33) card devices
nmcli Device Status
.. ..
2) for the network card ens33 add a connection (for example, also called ens33 )
format: nmcli con add con-name connection name ifname ethernet NIC name of the type
nmcli the Add connection CON-name ens33 ifname ens33 of the type ethernet

Within Linux configuration files, some beginning with # denotes a comment

任务二:提供DHCP服务

1) The client is assigned an IP address associated parameter
2) tells the client which server to look for the next step, to obtain a boot file NIC
comment mark # !!!! Linux system configuration file
!!!! disabled work network (such as NAT) other DHCP services (such as VMware native), to avoid conflict

the install DHCP -Y yum
Vim /etc/dhcp/dhcpd.conf
Subnet Netmask 192.168.10.0 255.255.255.0 {
Range 192.168.10.100 192.168.10.200;
Next-Server 192.168.10.7; // next inform a server (TFTP) address
filename "pxelinux.0"; // told to start the download card file name
}
systemctl enable dhcpd --now // set the boot from the start, and start immediately

Other configurations Reference:
#option Routers default gateway address;
#option Domain name-server-1 Servers the DNS address, DNS server address 2;
# default-Lease Time-3600; // default lease time
# max-lease-time 7200; / / maximum lease time

!!!! DHCP service troubleshooting -
1) Check service status
systemctl status dhcpd
state should be the normal green of the Active (running)
systemctl dhcpd restart
the Job for dhcpd.service Because at The failed The Control Process the Exited with error code See "systemctl Status. dhcpd.service "and" journalctl -xe "for details. ==" explained the configuration file was incorrect or does not match the IP address of the network segment of the machine.

2) to know where the configuration file is wrong, what kind of error
vim / var / log / messages // diary Linux server
.. .. from the last row looking forward
/etc/dhcp/dhcpd.conf line 10:. . . . . // line 10 has XX error

!!!! This machine tests to get DHCP Address:
dhclient -d ens33 // - d represents a debug mode, not really modify the address
.. ..
bound to 192.168.10.x
.. ..
Press Ctrl + C to terminate the test

任务三:为客户机提供软件包资源(Web方式)

1) mounted httpd package
yum the install httpd -Y
2) resource deployment package
mkdir / var / WWW / HTML / cos7dvd
CP -R & lt / mnt / DVD / * / var / WWW / HTML / cos7dvd
.. .. Wait, Do not interrupt
3) from the httpd service
systemctl enable httpd --now

Access from native browser http://192.168.10.7/cos7dvd, to see the software resource page

!!!! Web Configuration (if the original Web-configured virtual hosts, need to pay attention)
1) Once web hosting enabled, the default ServerName, DocumentRoot failure
2) If submitted over HTTP browser request does not belong to any virtual one already defined host, to host the first virtual web directory of feedback do
vim /etc/httpd/conf.d/vhosts.conf // insert the following line 1
<VirtualHost *: 80>
DocumentRoot / var / the WWW / HTML
< / VirtualHost>
systemctl enable httpd --now

任务四:提供网络启动相关的文件(构建TFTP启动服务器)

1) pxelinux.0 NIC boot file
provided by the package syslinux (/usr/share/syslinux/pxelinux.0)
2) Start menu configuration pxelinux.cfg / default (module configuration file, background images ......), load CentOS7 system installation program (vmlinuz, initrd.img)
obtained from the optical disc directory CentOS7 isolinux / under
yum -y install tftp-server // TFTP server software installed
yum the install the syslinux -Y
CP /usr/share/syslinux/pxelinux.0 / var / lib / tftpboot / // deploy the startup file
cp / mnt / dvd / isolinux / * / var / lib / tftpboot / // deployment supporting documents
cd / var / lib / tftpboot /
mkdir pxelinux.cfg // create the configuration directory
cp isolinux.cfg pxelinux .cfg / default // establish a default menu configuration
vim pxelinux.cfg / default
lookup label linux, modify append line below, inst.stage2 = after the specified archive and address
append the initrd = initrd.img inst.stage2 = HTTP: // 192.168.10.7/cos7dvd
systemctl enable the TFTP --now // start the TFTP server

TFTP test whether resources can be downloaded:
cd / root
yum -y install the TFTP
the TFTP 192.168.10.7 -c GET pxelinux.0
LS -LH pxelinux.0

任务五:测试PXE网络启动及安装

1) Create a virtual machine (CentOS64 bit memory> 2G)
2) the virtual machine boot client to boot from the network card
---- DHCP to automatically obtain the address
---- connect to the TFTP server
---- Download pxelinux.0 startup file
---- acquisition menu configuration file pxelinux.cfg / default
3) the installation menu == "CentOS7 choose to install the install
---- Download vmlinuz, initrd.img
---- running kernel file to load the installation program, to ensure that the election could see a graphical interface language, ......
---- manually specify the installation source http://192.168.10.7/cos7dvd
---- subsequent process is similar to the installation CD, you can not complete the installation, you can turn off the virtual machine

!!!! If the client machine's memory is too small, prone to crashes the kernel at boot PXE boot
kernel panic kernel panic (panic)

kickstart unattended / auto-answer technique

kick, kick
start, beginning

Shell scripts (they will run / running text)

kickstart unattended art
kick, start

Shell scripts, long-legged (+ x) text

rm -rf /etc/yum.repos.d/*.repo
echo '[development]
name=CentOS7
baseurl=http://192.168.10.7/cos7dvd/
enabled=1
gpgcheck=0' > /etc/yum.repos.d/centos7.repo

任务六:提供自动应答文件(回答安装过程中的各种问题)

1) how to obtain an answer file
Vim /etc/yum.repos.d/ .repo
[Development] // request source ID into Development
yum -Y-config-System the install the kickstart
System-config-the kickstart
basic configuration: language, time zone , password management
installation method: a new installation, HTTP installation source is provided
to install the boot loader: the boot loader to install new
partition: the first three are selected radio added swap 2000M, / the remaining space all
network configurations: Add a connection (DHCP)
software package selection: select all except KDE software category of "Desktop"
post-install script, refer to the following:
RM -rf /etc/yum.repos.d/
.repo
echo '[cos7dvd]
name = added from: File: /// mnt / DVD
BaseURL = http://192.168.10.7/cos7dvd
Enabled. 1 =
gpgcheck = 0
'> /etc/yum.repos.d/cos7dvd.repo
yum the install the httpd -Y
echo' NTD1906 ' > /var/www/html/index.html
wgethttp://192.168.10.7/Discuz_X3.4_SC_UTF8.zip
unzip Discuz_X3.4_SC_UTF8.zip
cp -rf upload/* /var/www/html/
systemctl enable httpd
.. ..

- Save to /root/ks.cfg

2) how to get clients to spend the answer file
cp /root/ks.cfg /var/www/html/ks-cos7.cfg
browser access http://192.168.10.7/ks-cos7.cfg
vim / var / lib / tftpboot / pxelinux.cfg / default
look for linux, modify append line below,
delete inst.stage2 = part, and replaced with ks = answer file Download
append the initrd = initrd.img ks = http://192.168.10.7/ ks-cos7.cfg

任务七:客户机无人值守安装测试

1) Create a virtual machine (CentOS64 bit memory> 2G)
2) the virtual machine boot client to boot from the network card
---- DHCP to automatically obtain the address
---- connect to the TFTP server
---- Download pxelinux.0 startup file
---- acquisition menu configuration file pxelinux.cfg / default
3) the installation menu == "choose to install CentOS7
---- Download vmlinuz, initrd.img
---- running kernel file to load the installation program, ensure can see the graphic language interface option, ......
---- automate the installation process

Shell scripts -
Shell (/ bin / bash)
long-legged text file (containing a number of Linux command line)

Guess you like

Origin blog.51cto.com/11806823/2447982