美文网首页linux
cobbler搭建centos7无人值守安装

cobbler搭建centos7无人值守安装

作者: yundd | 来源:发表于2019-03-09 01:12 被阅读0次

一、cobbler简介

Cobbler是一款自动化操作系统部署的实现工具,由Python语言开发,是对PXE的二次封装。融合多种特性,提供了CLI和Web的管理形式。同时,Cobbler也提供了API接口,方便二次开发使用。它不仅可以安装物理机,同时也支持kvm、xen虚拟化、Guest OS的安装。另外,它还能结合Puppet等集中化管理软件,实现自动化管理。

二、cobbler组件关系

三、cobbler服务的构成

  • pxe服务
  • dhcp服务
  • rsync服务
  • httpd服务
  • DNS服务
  • kickstart服务

四、cobbler相关使用目录的说明

1.配置目录/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 : 模块的配置文件

2.数据目录/var/lib/cobbler/*

/var/lib/cobbler/config/: 用于存放distros,system,profiles 等信息
/var/lib/cobbler/triggers/: 用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/: 默认存放kickstart文件
/var/lib/cobbler/loaders/: 存放各种引导程序

3.镜像目录/var/www/cobbler/

/var/www/cobbler/ks_mirror/: 导入的发行版系统的所有数据
/var/www/cobbler/images/ : 导入发行版的kernel和initrd镜像用于远程网络启动

4.日志目录/var/log/cobbler/

/var/log/cobbler/installing: 客户端安装日志
/var/log/cobbler/cobbler.log : cobbler日志

五、安装cobbler 及组件

[root@yundd ~]#yum -y install cobbler dhcp httpd xinetd tftp-server syslinux pykickstart xinetd rsync cobbler-web

六、配置cobbler

1.生成密码设置新系统root密码(toor)

[root@yundd ~]# openssl passwd -1
Password: 
Verifying - Password: 
$1$AD.iYUtp$l6VfSLTZGC.6J4AU92Eeg1
[root@yundd ~]#  cp /etc/cobbler/settings  /opt/settings.bak 
301行设置密码
vim /etc/cobbler/settings
100 # and put the output between the "" below.
101 default_password_crypted: "$1$4U0LMJ5K$7MoCcgTFFjdPALFazWDvX1"
102 
103 # the default template type to use in the absence of any

2.设置server和next_server

vim /etc/cobbler/settings
server: 192.168.1.140
next_server: 192.168.1.140
设置allow_dynamic_settings: 1

注释:设置cobbler服务器地址的ip

3.设置dhcp,生成DHCP文件(使用cobbler sync命令生效)

#vim /etc/cobbler/settings
manage_dhcp: 1
#vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.5;
     option domain-name-servers 192.168.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
          if option pxe-system-type = 00:02 {
                  filename "ia64/elilo.efi";
          } else if option pxe-system-type = 00:06 {
                  filename "grub/grub-x86.efi";
          } else if option pxe-system-type = 00:07 {
                  filename "grub/grub-x86_64.efi";
          } else if option pxe-system-type = 00:09 {
                  filename "grub/grub-x86_64.efi";
          } else {
                  filename "pxelinux.0";
          }
     }

4.下载启动菜单

[root@yundd ~]#  cobbler get-loaders
change 'disable' to 'no' in /etc/xinetd.d/tftp

5.启动cobbler

[root@yundd ~]# systemctl restart cobblerd httpd tftp
[root@yundd ~]# systemctl enable cobblerd httpd tftp

6.检查cobbler服务

修改防火墙规则
您需要修改和更改防火墙规则,然后依次运行以下命令。

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=443/tcp --permanent
firewall-cmd --add-service=dhcp --permanent
firewall-cmd --add-port=69/tcp --permanent
firewall-cmd --add-port=69/udp --permanent
firewall-cmd --add-port=4011/udp --permanent
firewall-cmd --reload

7.挂载导入镜像文件

[root@note1 ~]# mount /dev/cdrom  /mnt
[root@note1 cobbler]# cobbler import --path=/mnt/ --name=Centos-7-x86_64 --arch=x86_64
[root@note1 kickstarts]# cobbler distro report --name=Centos-7-x86_64

8.配置centos7kickstart 文件

[root@note1 kickstarts]# cat CentOS-7-x86_64.cfg 
install
url --url=$tree  
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr 
# Network information
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw  --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size 500  
part swap --size 2000
part / --fstype xfs --size 20000 
part /data --fstype xfs --size 30000 
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
%end
%post
systemctl disable postfix.service
%end

9.重启cobbler服务保证所有组件开机自动启动

相关文章

网友评论

    本文标题:cobbler搭建centos7无人值守安装

    本文链接:https://www.haomeiwen.com/subject/swtdpqtx.html