Automatic Installation of CentOS Based on Business Requirements

Source: Internet
Author: User

Automatic Installation of CentOS Based on Business Requirements
 
In a few days, 29 servers will be mounted in the data center, and the system needs to be installed. There are too many machines and you want to install them automatically. Because there is no testing machine, the experiment is all implemented on the virtual machine. In order to complete the deployment, you have thought of several solutions. After all, you can go back to the dormitory after the deployment is completed early, you don't have to go to the company anymore.
 
The general operation is to find a DVD and install it according to business needs (such as the partition installation package language). After the installation is complete, the system will create an automatic installation system cfg template file, in the/root directory. At the same time, the root directory has an install. the log file records the packages installed in the system. Then, based on the file records, extract the required packages from the DVD and reencapsulate them into a new image, copy the automatic installation file under the root directory to the new image directory, and then make a small modification.
 
Step 1: First mount the DVD image;
[Root @ localhost ~] # Mount/dev/cdrom/mnt ### mount the image to the/mnt directory
Step 2: create a directory to save the files that require service packages and new images;
[Root @ localhost ~] # Mkdir-p iso/CentOS
[Root @ localhost CentOS] # pwd
/Root/iso/CentOS
Step 3: extract the packages required by the business. The system installation package names mentioned above are recorded in the install. log file of the root directory;
[Root @ localhost ~] # Awk '/Installing/{print $2}' install. log | sed's/^ [0-9] *: // G'> the package.txtpackage.txt file stores all packages installed in the current system;
Step 4: extract the required package from the DVD Image Based on the package content and put it in the/root/iso/CentOS directory;
[Root @ localhost ~] # Cat cp. sh
#! /Bin/bash
DVD = '/mnt/CentOS' # path of the DVD Image Storage Package
PACKDIR = '/root/package.txt' # records the names of all packages installed in the system.
NEW_DVD = '/root/iso/CentOS/' # Storage path of the package required for the new image
While read LINE
Do
Cp $ {DVD}/$ {LINE} *. rpm/$ {NEW_DVD} | echo "$ LINE don't cp ......."
Step 5 of done <package.txt: copy other files required by the image to the iso Directory, which is no different from the attached DVD image except for the lack of some packages.
[Root @ localhost CentOS] # rsync-a -- exclude = CentOS/mnt // root/iso # This command is used to remove the/mnt directory from the CentOS directory, other files are copied to the/root/iso directory.
 
 
Step 6: copy the anaconda-ks.cfg to/root/iso directory
[Root @ localhost ~] # Cat anaconda-ks.cfg | grep-v "^ #"
 
 
Install
Cdrom
Lang en_US.UTF-8
Keyboard us
Network -- device eth0 -- bootproto static -- ip 192.168.0.45 -- netmask 255.255.255.0 -- gateway 192.168.0.1
Rootpw -- iscrypted $1 $ cT7w. PYF $ autqNIf5WqO0P. 3CW5nru.
Firewall -- enabled -- port = 22: tcp
Authconfig -- enableshadow -- enablemd5
Selinux -- enforcing
Timezone -- utc Asia/Shanghai
Bootloader -- location = mbr -- driveorder = sda
Clearpart -- linux
Part/boot -- fstype ext3 -- size = 100
Part swap -- size = 2000
Part/-- fstype ext3 -- size = 100 -- grow
% Packages
@ Base
@ Core
@ Dialup
@ Editors
@ Text-internet
Keyutils
Trousers
Fipscheck
Device-mapper-multipath [root @ localhost ~] # Cp anaconda-ks.cfg/root/iso # You can add write scripts to this file as needed
Step 7: Modify/root/iso/isolinux. cfg
[Root @ localhost ~] # Vim/root/iso/isolinux. cfg
 
Default linux modified to default linux ks = cdrom:/anaconda-ks.cfg save it on
Step 8: generate the comps. xml file
[Root @ localhost ~] # Cd/root/iso/
[Root @ localhost iso] # createrepo-g repodata/* comps. xml/root/iso/
457/457-CentOS/fbset-2.1-22.x86_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[Root @ localhost iso] # Step 9: create a new image
[Root @ localhost ~] # Mkisofs-o MyCentOS. iso-B isolinux/isolinux. bin-c isolinux/boot. cat-no-emul-boot-load-size 4-boot-info-table-R-J-v-T/root/iso/Step 10: generate an MD5 Verification Code
[Root @ localhost ~] #/Usr/lib/anaconda-runtime/implantisomd5 MyCentOS. iso
Inserting md5sum into iso image...
Md5 = 82cc70b16908bea468a2ce1c263dee9a
Inserting fragment md5sums into iso image...
Fragmd5 = bdf4b332ccf4a6fafe883a4cff54527df985ac2ee71be3c6c66d51e3421c
Frags = 20
Setting supported flag to 0
[Root @ localhost ~] # If this command is not prompted, install yum-y install anaconda-runtime
 
The above content reference http://liusy23.blog.51cto.com/1306558/280831
This article is from the blog "becoming a network security engineer ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.