Cobbler automatic deployment and installation (based on CentOS7 actual operation!)

Cobbler automatically deploys and installs


Cobbler is an open source project developed using Python. It provides a fully automated and batch network installation environment for quickly establishing a Linux system by concentrating all the services involved in the deployment system.

Experiment preparation

  • A Linux server (Centos7 system, IP: 192.168.80.134)
  • A blank virtual machine
  • Need to be connected to the Internet, and all virtual machines use NAT mode

Related software package link: https://pan.baidu.com/s/1Cl2H_cufGmbHCWfs_mObCQ Password: desg

Cobbler automatic installation service construction steps

1. Import epel source

After downloading the installation package below, there is no need to unzip

Insert picture description here

Pull it directly into Xshell. After the transmission is completed, as shown in the figure below, rz -E will also appear in Xshell, just click Close.

Insert picture description here

Insert picture description here

Then install the dependency package

rpm –ivh epel-release-latest-7.noarch.rpm	#安装依赖包
yum list				#自动加载在线更新源

Insert picture description here

2. Install Cobbler and its related service packages

yum install -y cobbler dhcp tftp-server pykickstart httpd rsync xinetd 

Insert picture description here

2.1 The functions of each software are as follows

  • Cobbler is used to quickly establish a Linux network installation environment
  • dhcp is used to automatically assign IP addresses to blank hosts
  • tftp-server provides downloading of boot image files
  • pykickstart realizes unattended installation
  • httpd runs as a console program
  • rsync realizes data synchronization
  • xinetd provides access control, enhanced log and resource management functions

3. Modify the main cobbler configuration file

vim /etc/cobbler/settings

#Modify the following items

  • next_server: 192.168.xx #Point to the IP of the tftp server, that is, the local IP

  • server: 192.168.xx #Point to the IP of the cobbler server, that is, the local IP

  • manage_dhcp: 1 #Let cobbler manage the dhcp service

  • manage_rsync: 1 #Let cobbler manage the rsync service

  • manage_tftp: 1 #Let cobbler manage tftp service

Insert picture description here

Insert picture description here

4. Start related services and close the firewall and selinux

systemctl start httpd.service		#开启http服务
systemctl start cobblerd.service		#开启cobbler服务
systemctl stop firewalld		#关闭防火墙服务	
setenforce 0                    #关闭安全选项

Insert picture description here

5. Use the cobbler check command to check the settings of Cobbler, and query items that need to be changed.

cobbler check

Insert picture description here

6. Turn on the tftp service and rsync service

6.1 Modify tftp configuration file

vim /etc/xinetd.d/tftp #编辑tftp配置文件
disable=no #开启tftp服务

Insert picture description here

6.2 Start service

systemctl restart xinetd.service
systemctl start rsyncd.service   
ps aux | grep "xinetd" 或者 ps -elf | grep "xinetd" 

Insert picture description here

7. Download the boot operating system file

cobbler get-loaders #也可跟上--force表示强制执行

Insert picture description here

8. Set the initial password of the Cobbler user

8.1 Use salt encryption to generate keys

openssl passwd -1 -salt 'abc123' 'abc123'

The password can be written casually, abc123 is also the password of the root user after the system is installed, the key generated below is right-clicked and copied, and you will need to use it later

Insert picture description here

8.2 Add the generated key to the Cobbler configuration file

Enter the cobbler configuration file through the following code

vim /etc/cobbler/settings

Insert picture description here

9. Configure dhcp service

9.1 Modify the template file of Cobbler management dhcp service

vim /etc/cobbler/dhcp.template

subnet 192.168.x.0 netmask 255.255.255.0 {

   option routers       192.168.x.x;		#修改网关

   option domain-name-servers 192.168.x.x;		#修改DNS,如果网卡使用的是dhcp模式,可通过nslookup 127.0.0.1 | grep server 查询DNS地址

   option subnet-mask     255.255.255.0;

   range dynamic-bootp     192.168.x.x 192.168.x.x;  #修改地址池

Insert picture description here

You can also obtain the gateway and DNS server addresses through the following operations

Insert picture description here

9.2 Synchronize the configured template file to the configuration file of the DHCP service

cobbler sync

Insert picture description here

9.3 Restart the DHCP service

systemctl restart dhcpd.service

Insert picture description here

10. Import the ISO image file

10.1 Mount image file

mount /dev/sr0 /mnt

Insert picture description here

10.2 Import the Linux kernel in the iso image and initialize the image file

cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64  

Insert picture description here

#Parameter Description

#--Path indicates the directory where the mirror is mounted

#--Name indicates the name defined for the installation source

#–Atch indicates the number of system bits of the specified installation source

#The default import storage path is /var/www/cobbler/ks_mirror/CentOS-7-x86_64

10.3 Check whether the kernel and initialization files are in the tftp-server shared directory

yum install -y tree 			#系统默认没有安装,需手动安装tree

tree /var/lib/tftpboot/images	#查看文件是否存在

Insert picture description here

11. Restart all services

systemctl restart cobblerd.service

systemctl restart dhcpd.service

systemctl restart xinetd.service

systemctl restart httpd.service

Insert picture description here

12. Then use cobbler check to check the settings of Cobbler

cobbler check

Insert picture description here

13. After all configurations are completed, turn on the blank host to automatically install the system

Steps to create a blank virtual machine

Insert picture description here

compatibility

Insert picture description here

Installation source

Insert picture description here

Operating system selection

Insert picture description here

Choose a location to install

Insert picture description here

Processor settings

Insert picture description here

The virtual machine memory must be at least 2G, otherwise the installer will prompt that the memory space is insufficient, and the error will be stuck

Insert picture description here

Select NAT mode for network type

Insert picture description here

I/O controller type default

Insert picture description here

Disk type default

Insert picture description here

Select disk default

Insert picture description here

Customize the capacity

Insert picture description here

Specify the disk default

Insert picture description here

No need to customize hardware, click Finish

Insert picture description here

A prompt will appear when the virtual machine is turned on, just select "No". Then wait for the installation to complete

Insert picture description here

After the installation is complete, you can log in to root

This installation method is a minimal installation, and the installed system only has a character interface

Login account: root Password: abc123

Insert picture description here

You can install it manually if you need a graphical interface

yum list

yum -y groupinstall "server with GUI"

Guess you like

Origin blog.csdn.net/qq_35456705/article/details/111243986