Big Data's Linux deployment automation systems - unattended

Automated deployment of Linux systems

  • Realization of ideas, methods: FTP + TFTP + DHCP + Kickstart + PXE:

1, source structures yum

1.1 using yum to install the required packages, let's build yum CD-ROM source:
  1. Mnt folder created in the root directory, mount
[root@localhost ~]# mkdir /mnt/
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
  1. A self yum source, create a file that ends in /etc/yum.repos.d .repo catalog:
[root@localhost ~]# vi /etc/yum.repos.d/server.repo
  1. yum source edits:
[base] 
Name=base 
Baseurl=file:///mnt/      #(部分系统可能需要使用file:///mnt/server 的路径)
Enabled=1 
Gpgcheck=0 
  1. If there is a conflict in /etc/yum.repos.d/, delete the repo file inside, it is best to back up the contents inside.
 [root@localhost ~]# mkdir /home/repo_backup;cp CentOS-* /home/repo_backup   //备份并且复制
  1. /Etc/yum.repos.d/ delete all files CentOS- the inside.
[root@localhost yum.repos.d]# rm -rf CentOS-*

2. Installation and set boot from Kai

2.1 ftp installation services and open service, set to start automatically start
  1. Ftp installation services
[root@localhost yum.repos.d]# yum install -y vsftpd
  • failure:: Packages / vsftpd-2.2.2-11.el6 _4.1.x86_64.rpm from base: [Errno 256] No more mirrors to try. If "vsftpd-2.2.2-11.el6_4.1.x86_64 appear "the case, first check whether the disc is hanging on to / mnt. If you have still hanging in the still prompt the error, execute the command "yum clean all" command.
  1. Start Service
[root@localhost yum.repos.d]# service vsftpd start
  1. Set boot from Kai
[root@localhost yum.repos.d]# chkconfig vsftpd on
2.2 TFTP installation services and open service, set to start automatically boot
  1. Installation and service tftp
[root@localhost yum.repos.d]# yum install tftp -y 
[root@localhost yum.repos.d]# yum install tftp-server -y 
  1. /Etc/xinetd.d/tftp change the configuration file inside the lines 13, 14
[root@localhost yum.repos.d]# vim /etc/xinetd.d/tftp

Here Insert Picture Description

  1. Restart the service xinetd
[root@localhost yum.repos.d]# service xinetd restart

Here Insert Picture Description

  • TFTP services start properly. Xinetd service has always been boot, so we no longer need to set up here.
  • Note: xinetd is a new generation of network daemon service program, also known as Super Internet server, used to manage a variety of lightweight Internet Services
2.3. Installing dhcp, modify the configuration file and start the service
  1. Installation dhcp service
[root@localhost yum.repos.d]# yum install dhcp -y
  1. /Etc/dhcp/dhcpd.conf configuration file
ddns-update-style interim;
ignore client-updates;
# 注意网段需要相同。否则无法使用
subnet 192.168.153.0 netmask 255.255.255.0 {
# 与服务器IP地址相同
option routers 192.168.153.111;
# IP默认租约时间
default-lease-time 21600;
#IP最大租约时间
max-lease-time 43200;
#IP租约地址池,这里要注意网段一定相同,否则起不来DHCP服务
range 192.168.153.3 192.168.153.120;
option subnet-mask 255.255.255.0;
#与服务器IP地址相同
next-server 192.168.153.111;
filename "pxelinux.0";
}
  1. Start Service
[root@localhost yum.repos.d]# service dhcpd start
  1. Set boot from Kai
[root@localhost yum.repos.d]# chkconfig dhcpd on

2.4 preparations are completed, the configuration Kickstart

  1. Need to be installed yum install system-config-kickstart.noarch -y
[root@localhost yum.repos.d]# yum install system-config-kickstart.noarch -y
  1. Creating / tftpboot directory and /tftpboot/pxelinux.cfg
[root@localhost yum.repos.d]# mkdir /tftpboot
[root@localhost yum.repos.d]# mkdir /tftpboot/pxelinux.cfg 
  1. Copy several files
[root@localhost yum.repos.d]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/ 
[root@localhost yum.repos.d]# cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default 
[root@localhost yum.repos.d]# cp /mnt/images/pxeboot/initrd.img /tftpboot/ 
[root@localhost yum.repos.d]# cp /mnt/images/pxeboot/vmlinuz /tftpboot/ 
  1. Change Permissions
[root@localhost yum.repos.d]# chmod 644 /tftpboot/pxelinux.cfg/default
  1. /Tftpboot/pxelinux.cfg/default then modify the configuration file.
  • Two lines which need to modify the file, modifying the first line, the latter means is to find label linux linux following row 18, row 22 and then modify (i.e., add later ks = ftp: // "pxe-server-ip" / ks .cfg). Line 22 means that the installation program to access the kickstart file via FTP server.
    Here Insert Picture Description

2.5 Production unattended installation kickstart file.

  1. Open the terminal input system-config-kickstart pop up interface. At this point you need to be performed on the graphical interface of the server.
  2. kickstart pop up screen. At this point you need to be performed on the graphical interface of the server.
    Here Insert Picture Description
  3. A method of mounting an ftp server configuration
    Here Insert Picture Description
  4. Select the partition
    Here Insert Picture Description
Partition name File system type Hard disk space
/boot ext4 200MB
/swap 2048MB
/ Root partition ext4 All the remaining hard disk space

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

  1. Network Settings
    Here Insert Picture Description

  2. Firewall settings
    Here Insert Picture Description

  3. Package settings. The remaining two rear: pre-install script, the script does not require configuration after installation.
    Here Insert Picture Description

  4. Storage
    Here Insert Picture Description

  5. Copy the ks.cfg file to the / var / ftp / directory:

[root@localhost yum.repos.d]# cp /root/ks.cfg /var/ftp/
  1. Unmounted and remounted to the new directory:
[root@localhost yum.repos.d]# umount /mnt/
[root@localhost yum.repos.d]# mount /dev/cdrom /var/ftp/pub/
  1. Turn off the firewall
  • chkconfig iptables off (restart to take effect)
  • service iptables stop (effective immediately)
[root@localhost yum.repos.d]# chkconfig iptables off
[root@localhost yum.repos.d]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter        [确定]
iptables:清除防火墙规则:                     [确定]
iptables:正在卸载模块:                       [确定]
  1. SElinux:
  • Temporary closure: setenforce 0
  • Permanently closed: / etc / sysconfig / selinux file, SELINUX = enforcing to disabled
  • SELinux need to reboot the system permanently closed.
  1. Next, create a virtual machine:
  • Direct power without into the image file.
  • It will automatically reboot after installing.
  • After installing the server good:
    Here Insert Picture Description
Published 37 original articles · won praise 7 · views 1163

Guess you like

Origin blog.csdn.net/zy13765287861/article/details/104862482