如何使用PXE为批量服务器安装Centos7系统以及cobbler的使用介绍
Admin 2023-09-14 群英技术资讯 355 次浏览
作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘、U盘等介质安装,1小时也完成了,但是如果有成百台的服务器还要用光盘、U盘去安装,就显得有些力不从心了。PXE技术就能很好的解决这个问题,本文将会对PXE的工作原理有所介绍,而cobbler则是基于PXE技术的工作原理的二次封装,通过命令的方式简化了PXE配置过程。
事实上把PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提条件是计算机的网卡必须具有引导功能,这个网卡中要有一个PXE客户端。当计算机POST自检成功以后,BIOS把网卡中ROM的PXE客户端调入内存执行,PXE客户端通过网络中的DHCP服务器获取一个IP地址,拿到IP地址以后PXE继续引导计算机与网络中的TFTP客户端建立连接,从而从TFTP服务器中获取开机引导文件之后请求并下载安装需要的文件。在这个过程中需要一台服务器来提供启动文件、安装文件、以及安装过程中的自动应答文件等。
原理介绍
鉴于pxe自动装系统网上一搜一大把,我就不详细操作举例了,今天主要讲一讲Cobbler。
Cobbler是一个Linux服务器快速网络安装的服务,由python开发,小巧轻便(15k行python代码),可以通过PXE的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS,TFTP、RSYNC以及yum仓库、构造系统ISO镜像。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
配置文件目录:
/etc/cobbler
/etc/cobbler/settings : cobbler 主配置文件
/etc/cobbler/iso/: iso模板配置文件
/etc/cobbler/pxe: pxe模板文件
/etc/cobbler/power: 电源配置文件
/etc/cobbler/user.conf: web服务授权配置文件
/etc/cobbler/users.digest: web访问的用户名密码配置文件
/etc/cobbler/dhcp.template : dhcp服务器的的配置末班
/etc/cobbler/dnsmasq.template : dns服务器的配置模板
/etc/cobbler/tftpd.template : tftp服务的配置模板
/etc/cobbler/modules.conf : 模块的配置文件
数据目录:
/var/lib/cobbler/config/: 用于存放distros,system,profiles 等信 息配置文件
/var/lib/cobbler/triggers/: 用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/: 默认存放kickstart文件
/var/lib/cobbler/loaders/: 存放各种引导程序 镜像目录
/var/www/cobbler/ks_mirror/: 导入的发行版系统的所有数据
/var/www/cobbler/images/ : 导入发行版的kernel和initrd镜像用于 远程网络启动
/var/www/cobbler/repo_mirror/: yum 仓库存储目录
日志目录:
/var/log/cobbler/installing: 客户端安装日志
/var/log/cobbler/cobbler.log : cobbler日志
cobbler commands介绍
cobbler check 核对当前设置是否有问题
cobbler list 列出所有的cobbler元素
cobbler report 列出元素的详细信息
cobbler sync 同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro 查看导入的发行版系统信息
cobbler system 查看添加的系统信息
cobbler profile 查看配置信息
default_password_crypted: "$1$gEc7ilpP$pg5iSOj/mlxTxEslhRvyp/"
manage_dhcp:1
manage_tftpd:1
pxe_just_once:1
next_server:< tftp服务器的 IP 地址>
server:
1 [root@localhost ~]# cat /etc/redhat-release 2 CentOS Linux release 7.2.1511 (Core) 3 [root@localhost ~]# uname -r 4 3.10.0-327.el7.x86_64 5 [root@localhost ~]# getenforce 6 Disabled 7 [root@localhost ~]# systemctl status firewalld.service 8 ● firewalld.service - firewalld - dynamic firewall daemon 9 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) 10 Active: inactive (dead) 11 Docs: man:firewalld(1) 12 [root@localhost ~]# ifconfig eno16777736|awk -F "[ :]+" 'NR==2 {print $3}' 13 10.0.0.101 14 [root@localhost ~]# hostname 15 localhost.localdomain 16 [root@localhost ~]#
[root@localhost ~]## rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
[root@localhost ~]## yum makecache
[root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web
[root@localhost ~]# systemctl start httpd [root@localhost ~]# systemctl enable httpd [root@localhost ~]# systemct1 enable cobblerd [root@localhost ~]# systemctl start cobblerd
1 [root@localhost ~]# cobbler check 2 The following are potential configuration items that you may want to fix: 3 4 1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it. 5 2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network. 6 3 : change 'disable' to 'no' in /etc/xinetd.d/tftp 7 4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements. 8 5 : enable and start rsyncd.service with systemctl 9 6 : debmirror package is not installed, it will be required to manage debian deployments and repositories 10 7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one 11 8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them 12 13 Restart cobblerd and then run 'cobbler sync' to apply changes.
按照提示一个一个的解决问题:
问题1:
[root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 10.0.0.101/' /etc/cobbler/settings # 修改server的ip地址为本机ip
问题2:
[root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 10.0.0.101/' /etc/cobbler/settings # TFTP Server 的IP地址
问题3:
1 service tftp 2 { 3 socket_type = dgram 4 protocol = udp 5 wait = yes 6 user = root 7 server = /usr/sbin/in.tftpd 8 server_args = -s /var/lib/tftpboot 9 disable = no # 修改为no 10 per_source = 11 11 cps = 100 2 12 flags = IPv4 13 }
问题4:
[root@localhost ~]# cobbler get-loaders # 下载缺失的文件 task started: 2017-10-15_113824_get_loaders task started (id=Download Bootloader Content, time=Sun Oct 15 11:38:24 2017) downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE ***
问题5:
# 添加rsync到自启动并启动rsync [root@localhost ~]# systemctl enable rsyncd Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service. [root@localhost ~]# systemctl start rsyncd
问题6:
跟debian 相关,可以忽略
问题7:
# 修改密码为123456 ,salt后面是常用的加盐方式加密 [root@localhost ~]# openssl passwd -1 -salt '123456' '123456' $1$123456$wOSEtcyiP2N/IfIl15W6Z0 [root@localhost ~]# vim /etc/cobbler/settings # 修改settings配置文件中下面位置,把新生成的密码加进去 default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0
再次执行cobbler check
[root@localhost ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories# debian相关
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them# fence设备相关,不需要
Restart cobblerd and then run 'cobbler sync' to apply changes.
以上两个问题暂时可以忽略
修改cobbler配置
[root@localhost ~]# vim /etc/cobbler/settings # 修改settings中参数,由cobbler控制dhcp manage_dhcp: 1
修改dhcp.templates配置文件(仅列出修改部分)
[root@localhost ~]# vim /etc/cobbler/dhcp.template subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.2; option domain-name-servers 10.0.0.2; option subnet-mask 255.255.255.0; range dynamic-bootp 10.0.0.100 10.0.0.250;
重启服务并同步配置,改完dhcp必须要sync同步配置
1 [root@localhost ~]# systemctl restart cobblerd.service 2 [root@localhost ~]# cobbler sync 3 task started: 2017-10-15_122732_sync 4 task started (id=Sync, time=Sun Oct 15 12:27:32 2017) 5 running pre-sync triggers 6 cleaning trees 7 removing: /var/lib/tftpboot/pxelinux.cfg/default 8 removing: /var/lib/tftpboot/grub/efidefault 9 removing: /var/lib/tftpboot/grub/grub-x86.efi 10 removing: /var/lib/tftpboot/grub/images 11 removing: /var/lib/tftpboot/grub/grub-x86_64.efi 12 removing: /var/lib/tftpboot/s390x/profile_list 13 copying bootloaders 14 trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi 15 trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi 16 copying distros to tftpboot 17 copying images 18 generating PXE configuration files 19 generating PXE menu structure 20 rendering DHCP files 21 generating /etc/dhcp/dhcpd.conf 22 rendering TFTPD files 23 generating /etc/xinetd.d/tftp 24 cleaning link caches 25 running post-sync triggers 26 running python triggers from /var/lib/cobbler/triggers/sync/post/* 27 running python trigger cobbler.modules.sync_post_restart_services 28 running: dhcpd -t -q 29 received on stdout: 30 received on stderr: 31 running: service dhcpd restart 32 received on stdout: 33 received on stderr: Redirecting to /bin/systemctl restart dhcpd.service 34 35 running shell triggers from /var/lib/cobbler/triggers/sync/post/* 36 running python triggers from /var/lib/cobbler/triggers/change/* 37 running python trigger cobbler.modules.scm_track 38 running shell triggers from /var/lib/cobbler/triggers/change/* 39 *** TASK COMPLETE ***
检查dhcp
[root@localhost ~]# netstat -lnup|grep dhcp udp 0 0 0.0.0.0:39776 0.0.0.0:* 53381/dhcpd udp 0 0 0.0.0.0:67 0.0.0.0:* 53381/dhcpd udp6 0 0 :::46146 :::* 53381/dhcpd
[root@localhost ~]# mount /dev/cdrom /mnt # 挂载光盘镜像 mount: /dev/sr0 is write-protected, mounting read-only [root@localhost ~]# cobbler import --path=/mnt --name=Centos-7.2 --arch=x86_64 # cobbler导入镜像 task started: 2017-10-15_145401_import task started (id=Media import, time=Sun Oct 15 14:54:01 2017) Found a candidate signature: breed=redhat, version=rhel6 Found a candidate signature: breed=redhat, version=rhel7 Found a matching signature: breed=redhat, version=rhel7 Adding distros from path /var/www/cobbler/ks_mirror/Centos-7.2-x86_64: # 导入镜像的位置 creating new distro: Centos-7.2-x86_64 trying symlink: /var/www/cobbler/ks_mirror/Centos-7.2-x86_64 -> /var/www/cobbler/links/Centos-7.2-x86_64 creating new profile: Centos-7.2-x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/Centos-7.2-x86_64 for Centos-7.2-x86_64 processing repo at : /var/www/cobbler/ks_mirror/Centos-7.2-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-7.2-x86_64 looking for /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos-7.2-x86_64/repodata *** TASK COMPLETE ***
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64,如果重复,系统会提示导入失败
导入完镜像以后,那么就使查看下cobbler
[root@localhost ks_mirror]# cobbler list distros: Centos-7.2-x86_64 profiles: Centos-7.2-x86_64 systems: repos: images: mgmtclasses: packages: files:
[root@localhost kickstarts]# ls default.ks esxi5-ks.cfg legacy.ks sample_autoyast.xml sample_esx4.ks sample_esxi5.ks sample_old.seed esxi4-ks.cfg install_profiles pxerescue.ks sample_end.ks sample_esxi4.ks sample.ks sample.seed [root@localhost kickstarts]# pwd /var/lib/cobbler/kickstarts [root@localhost kickstarts]# rz rz waiting to receive. zmodem trl+C ȡ 100% 1 KB 1 KB/s 00:00:01 0 Errors.
查看导入信息及默认ks文件
[root@localhost kickstarts]# cobbler report distros: ========== Name : Centos-7.2-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/Centos-7.2-x86_64'} Management Classes : [] OS Version : rhel7 Owners : ['admin'] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {} profiles: ========== Name : Centos-7.2-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : Centos-7.2-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks # 默认ks文件,这里需要修改为我们自己配置好的ks文件 Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm systems: ========== repos: ========== images: ========== mgmtclasses: ========== packages: ========== files: ==========
我ks文件(只是简单配置的,具体可以按自己业务来)
1 #platform=x86, AMD64, or Intel EM64T 2 #version=DEVEL 3 # Install OS instead of upgrade 4 install 5 # Keyboard layouts 6 keyboard 'us' 7 # Root password 8 rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1 9 # Use network installation 10 url --url="$tree" 11 # System language 12 lang en_US 13 # Firewall configuration 14 firewall --disabled 15 # System authorization information 16 auth --useshadow --passalgo=sha512 17 # Use graphical install 18 graphical 19 firstboot --disable 20 # SELinux configuration 21 selinux --disabled 22 23 # Network information 24 network --bootproto=dhcp --device=eth0 25 network --bootproto=dhcp --device=eth1 26 # Reboot after installation 27 reboot 28 # System timezone 29 timezone Asia/Shanghai 30 # System bootloader configuration 31 bootloader --location=mbr 32 # Clear the Master Boot Record 33 zerombr 34 # Partition clearing information 35 clearpart --all --initlabel 36 # Disk partitioning information 37 part /boot --asprimary --fstype="ext4" --size=200 38 part swap --fstype="swap" --size=1024 39 part / --fstype="ext4" --grow --size=1 40 %packages 41 @base 42 @core 43 @compat-libraries 44 @debugging 45 @development 46 @gnome-desktop 47 @X Window System 48 %end
检查ks命令
# 写完 ks 文件之后,先通过 validateks 测试一下有没有语法错误
# cobbler validateks
# 通过下面这个命令查看 ks 文件,发现一些逻辑上的问题
# cobbler system getks --name=test
编辑修改指定ks文件为我们刚刚上传的ks
1 [root@localhost kickstarts]# cobbler profile list
2 Centos-7.2-x86_64
3 [root@localhost kickstarts]# cobbler profile edit --name Centos-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg # 编辑profile,修改ks文件为我们刚刚上传的Centos7.2-x86_64.cfg 4 [root@localhost kickstarts]# cobbler profile edit --name Centos-7.2-x86_64 --kopts='net.ifnames=0 biosdevname=0'
# 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用上面的参数。但要注意是CentOS7才需要上面的步骤,CentOS6不需要。
5 [root@localhost kickstarts]# cobbler profile report
6 Name : Centos-7.2-x86_64
7 TFTP Boot Files : {}
8 Comment :
9 DHCP Tag : default
10 Distribution : Centos-7.2-x86_64
11 Enable gPXE? : 0
12 Enable PXE Menu? : 1
13 Fetchable Files : {}
14 Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
15 Kernel Options (Post Install) : {}
16 Kickstart : /var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg # ks文件已经修改为我们上传的ks文件 17 Kickstart Metadata : {}
18 Management Classes : []
19 Management Parameters : <<inherit>>
20 Name Servers : []
21 Name Servers Search Path : []
22 Owners : ['admin']
23 Parent Profile :
24 Internal proxy :
25 Red Hat Management Key : <<inherit>>
26 Red Hat Management Server : <<inherit>>
27 Repos : []
28 Server Override : <<inherit>>
29 Template Files : {}
30 Virt Auto Boot : 1
31 Virt Bridge : xenbr0
32 Virt CPUs : 1
33 Virt Disk Driver Type : raw
34 Virt File Size(GB) : 5
35 Virt Path :
36 Virt RAM (MB) : 512
37 Virt Type : kvm
1 [root@localhost kickstarts]# cobbler sync 2 task started: 2017-10-15_154709_sync 3 task started (id=Sync, time=Sun Oct 15 15:47:09 2017) 4 running pre-sync triggers 5 cleaning trees 6 removing: /var/www/cobbler/images/Centos-7.2-x86_64 7 removing: /var/lib/tftpboot/pxelinux.cfg/default 8 removing: /var/lib/tftpboot/grub/efidefault 9 removing: /var/lib/tftpboot/grub/grub-x86.efi 10 removing: /var/lib/tftpboot/grub/images 11 removing: /var/lib/tftpboot/grub/grub-x86_64.efi 12 removing: /var/lib/tftpboot/images/Centos-7.2-x86_64 13 removing: /var/lib/tftpboot/s390x/profile_list 14 copying bootloaders 15 trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi 16 trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi 17 copying distros to tftpboot 18 copying files for distro: Centos-7.2-x86_64 19 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos-7.2-x86_64/vmlinuz 20 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos-7.2-x86_64/initrd.img 21 copying images 22 generating PXE configuration files 23 generating PXE menu structure 24 copying files for distro: Centos-7.2-x86_64 25 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos-7.2-x86_64/vmlinuz 26 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.2-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos-7.2-x86_64/initrd.img 27 Writing template files for Centos-7.2-x86_64 28 rendering DHCP files 29 generating /etc/dhcp/dhcpd.conf 30 rendering TFTPD files 31 generating /etc/xinetd.d/tftp 32 processing boot_files for distro: Centos-7.2-x86_64 33 cleaning link caches 34 running post-sync triggers 35 running python triggers from /var/lib/cobbler/triggers/sync/post/* 36 running python trigger cobbler.modules.sync_post_restart_services 37 running: dhcpd -t -q 38 received on stdout: 39 received on stderr: 40 running: service dhcpd restart 41 received on stdout: 42 received on stderr: Redirecting to /bin/systemctl restart dhcpd.service 43 44 running shell triggers from /var/lib/cobbler/triggers/sync/post/* 45 running python triggers from /var/lib/cobbler/triggers/change/* 46 running python trigger cobbler.modules.scm_track 47 running shell triggers from /var/lib/cobbler/triggers/change/* 48 *** TASK COMPLETE ***
为避免发生未知问题,先把服务端所有服务重启
[root@localhost cobbler]#systemctl restart xinetd.service
[root@localhost cobbler]#systemctl restart cobblerd.service
[root@localhost cobbler]#systemctl restart httpd.service
新建虚拟机从pxe启动,如果出现下面图形,则说明已经成功了
上图中网址也可以定制为我们自己的
[root@localhost cobbler]# vim /etc/cobbler/pxe/pxedefault.template MENU TITLE Cobbler | I'm here # 修改这里为你想修改的内容 [root@localhost cobbler]# cobbler sync # 同步之后就可以看到效果了
我们可以根据不同的MAC地址来给安装 不同的操作系统,配置不同的静态iP,设置不同的主机名等等,虚拟机查看MAC地址步骤如图:
配置定制化安装(需要验证,后续验证后添加验证结果)
[root@localhost cobbler]# cobbler system add \ --name=linux-web01 \ --mac=00:0C:29:3B:03:9B \ --profile=Centos-7.2-x86_64 \ --ip-address=10.0.0.200 \ --subnet=255.255.255.0 \ --gateway=10.0.0.2 \ --interface=eth0 \ --static=1 \ --hostname=linux-web01 \ --name-servers="10.0.0.2" \ --kickstart=/var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg
system add # 添加定制系统
name # 定制系统名称
mac # mac地址
profile #指定profile
ip-address # 指定IP地址
subnet # 指定子网掩码
gateway # 指定网关
interface # 指定网卡,eth0上面配置已经修改,centos7默认网卡名称不是eth0
static # 1表示启用静态IP
hostname # 定义hostname
name-server # dns服务器
kickstart # 指定ks文件
配置成功后我们可以查看到刚才定制的系统
[root@localhost cobbler]# cobbler system list
linux-web01
接下来我们创建一个虚拟机,mac地址为00:0C:29:3B:03:9B,启动后你就会发现自动进入安装系统了,等安装完以后,所有的配置都和我们当初设置的一样。
在客户端安装koan(要配置好源)
[root@localhost ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm [root@localhost ~]# yum install koan
查看cobbler上的配置文件
1 [root@localhost ~]# koan --server=10.0.0.101 --list=profiles 2 - looking for Cobbler at http://10.0.0.101:80/cobbler_api 3 Centos-7.2-x86_64
重新安装客户端系统
[root@localhost ~]# koan --replace-self --server=10.0.0.101 --profile=webserver1
重启系统后会自动重装系统
参考文章:
http://www.cnblogs.com/liaojiafa/p/6445759.html
http://www.voidcn.com/article/p-dwdfkmfh-boa.html
http://werewolftj.blog.51cto.com/1606482/1673779
http://www.cnblogs.com/qige2017/p/7545812.htmlb
以上就是关于“如何使用PXE为批量服务器安装Centos7系统以及cobbler的使用介绍”的介绍了,感谢各位的阅读,希望这篇文章能帮助大家解决问题。如果想要了解更多知识,欢迎关注群英网络,小编每天都会为大家更新不同的知识。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
Centos7 yum安装 Lnmp以及Lamp
Centos7 下安装及配置cobbler
在linux中,协议栈是计算机网络协议套件的一个具体的软件实现,是网络中各层协议的总和;协议套件中的一个协议通常是只为一个目的而设计的,这样可以使得设计更容易,协议栈反映了一个网络中文件传输的过程。
linux引导分区是指“/boot分区”,该分区是系统的启动分区,存放引导文件和Linux内核,用于判断需要启动哪个操作系统或哪个内核,其中包含了操作系统的内核和在启动系统过程中所要用到的文件。
在linux中,工作目录又称“当前目录”,是用户登录Linux系统后,在文件系统中当前所在的目录;用户在该目录下的一系列操作,相当于在该目录下工作,所以叫”工作“目录。工作目录是可以随时改变的,使用cd命令即可切换工作目录,语法“cd [相对路径或绝对路径]”。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008