Cobbler automatically deploys Linux installation (step by step to teach you to install)

Cobbler automatically deploys Linux installation (step by step to teach you to install)

Preface

  • Cobbler is an open source project developed using Python. It provides a fully automated batch and rapid network installation environment for Linux systems by concentrating all the services involved in the deployment system.
  • Cobbler initially supports Fedora, RedHat and derivatives (such as CentOS and Scientific Linux), but also supports Debian, Ubuntu, SuSE, FreeBSD, ESXI, etc.
  • Cobbler Chinese translation: Cobbler
  • Cobbler provides DHCP management, YUM source management, power management and other functions. In addition, it also supports command line management, WEB interface management, and provides API interfaces to facilitate secondary development.

1. Experiment preparation

l A Linux server (Centos7 system, IP: 192.168.126.10)

l A blank virtual machine

l 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 (The downloaded software package can be directly dragged into xSHELLL to install directly, or look at my previous window Sharing files with Linux can also be installed)

(1) Cobbler automatic installation service construction steps

1. Import epel source

rpm –ivh epel-release-latest-7.noarch.rpm #安装依赖包(刚刚下载好的软件)

yum list #自动加载在线更新

2. Install Cobbler and its related service packages

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

Insert picture description here

`#The functions of each software are as follows`

\#cobbler 用来快速建立Linux网络安装环境

\#dhcp 用来为空白主机自动分配IP地址

\#tftp-server 提供引导镜像文件的下载

\#pykickstart 实现无人值守安装

\#httpd 作为控制台程序运行

\#rsync 实现数据同步

\#xinetd 提供访问控制、加强的日志和资源管理功能

修改cobbler主配置文件
vim /etc/cobbler/settings
修改以下几项
next_server: 192.168.80.10       	#指向tftp服务器的IP,即本机IP
server: 192.168.80.10				#指向cobbler服务器的IP,即本机IP
manage_dhcp: 1                 		#让cobbler管理dhcp服务
manage_rsync: 1					#让cobbler管理rsync服务
manage_tftp: 1					#让cobbler管理tftp服务

Insert picture description here
Insert picture description here

Others can be modified one by one according to the requirements, save and exit

3. 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

4. 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

(1) Open tftp service and rsync service

修改tftp的配置文件

vim /etc/xinetd.d/tftp

Insert picture description here

开启服务:

systemctl restart xinetd.service

systemctl start rsyncd.service

下载引导操作系统文件

cobbler get-loaders

Insert picture description here

(2) Set the initial password of the Cobbler user

使用盐值加密方式生成密钥

openssl passwd -1 -salt 'abc123' 'abc123' (给root用户设置密码)

Insert picture description here

将生成的密钥加入Cobbler配置文件中

vim /etc/cobbler/settings
Insert picture description here

5. Configure dhcp service

修改Cobbler管理dhcp服务的模板文件

vim /etc/cobbler/dhcp.template

subnet 192.168.126.0 netmask 255.255.255.0 {

option routers 192.168.126.1; #修改网关

option domain-name-servers 192.168.126.2; #修改DNS,如果网卡使用的是dhcp模式,可通过nslookup 127.0.0.1 | grep server 查询DNS地址(我自己使用的是static模式,通过ens-33配置文件查询也可以)

option subnet-mask 255.255.255.0;

range dynamic-bootp 192.168.126.88 192.168126.188; #修改地址池

Insert picture description here

6. Synchronize the configured template file to the configuration file of the DHCP service

cobbler sync
Insert picture description here
Insert picture description here

7. Restart the DHCP service

systemctl restart dhcpd.service

8. Import ISO image file

挂载镜像文件

mount /dev/cdrom /mnt

导入iso镜像中的Linux 内核、初始化镜像文件

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

`#Parameter description`

\#--path 表示镜像所挂载的目录

\#--name 表示为安装源定义的名字

\#--atch 表示指定安装源的系统位

\#默认导入存放路径为/var/www/cobbler/ks_mirror/CentOS-7-x86_64

Insert picture description here
Insert picture description here

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

9. Restart all services

systemctl restart cobblerd.service

systemctl restart dhcpd.service

systemctl restart xinetd.service

systemctl restart httpd.service

10. Use cobbler check to check settings for Cobbler

Insert picture description here

11. After all configurations are completed, open the blank host to automatically install the system

Insert picture description here

Insert picture description here

此安装方式为最小化安装,安装的系统只有字符界面

登录账户:root 密码:111111

Guess you like

Origin blog.csdn.net/weixin_51573771/article/details/111033799