cobbler安装CentOS

安装cobbler

1、配置EPEL源

[root@cobbler ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all &&yum makecache

2、安装cobbler

[root@cobbler ~]yum install -y httpd tftp dhcp cobbler cobbler-web pykickstart

3、查看cobbler安装文件

[root@linux-node2 ~]# rpm -ql cobbler
/etc/cobbler                  # 配置文件目录
/etc/cobbler/settings         # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
/etc/cobbler/dhcp.template    # DHCP服务的配置模板
/etc/cobbler/tftpd.template   # tftp服务的配置模板
/etc/cobbler/rsync.template   # rsync服务的配置模板
/etc/cobbler/iso              # iso模板配置文件目录
/etc/cobbler/pxe              # pxe模板文件目录
/etc/cobbler/power            # 电源的配置文件目录
/etc/cobbler/users.conf       # Web服务授权配置文件
/etc/cobbler/users.digest     # 用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template # DNS服务的配置模板
/etc/cobbler/modules.conf     # Cobbler模块配置文件
/var/lib/cobbler              # Cobbler数据目录
/var/lib/cobbler/config       # 配置文件
/var/lib/cobbler/kickstarts   # 默认存放kickstart文件
/var/lib/cobbler/loaders      # 存放的各种引导程序
/var/www/cobbler              # 系统安装镜像目录
/var/www/cobbler/ks_mirror    # 导入的系统镜像列表
/var/www/cobbler/images       # 导入的系统镜像启动文件
/var/www/cobbler/repo_mirror  # yum源存储目录
/var/log/cobbler              # 日志目录
/var/log/cobbler/install.log  # 客户端系统安装日志
/var/log/cobbler/cobbler.log  # cobbler日志

4、启动服务

[root@cobbler cobbler]# systemctl start httpd && systemctl start cobblerd

5、检查cobbler

[root@cobbler cobbler]# cobbler check
The following are potential configuration items that you may want to fix:

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.
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.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

根据check信息修改配置文件

1/2: [root@cobbler ~]# sed -i s/"server: 127.0.0.1"/"server: 192.168.2.1"/g /etc/cobbler/settings
3:[root@cobbler ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
4:   [root@cobbler ~]# vi  /etc/xinetd.d/tftp         
disable			= no
5:[root@cobbler cobbler]# cobbler get-loaders
task started: 2020-02-05_090915_get_loaders
task started (id=Download Bootloader Content, time=Wed Feb  5 09:09:15 2020)
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 ***
6: [root@cobble]# systemctl start rsyncd
    [root@cobbler]# systemctl enable rsyncd
8:[root@cobbler cobbler]# openssl passwd -1 -salt `openssl rand -hex 4` '123456'
   $1$9383662e$XpOaAGkc8EuL8fz3OvgaK
    [root@cobbler cobbler]# cat /etc/cobbler/settings | grep default_password
   default_password_crypted: "$1$9383662e$XpOaAGkc8EuL8fz3OvgaK1"

5、重启cobbler服务

[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

6、同步cobbler配置

[root@cobbler ~]# cobbler sync
task started: 2020-02-05_094912_sync
task started (id=Sync, time=Wed Feb  5 09:49:12 2020)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying: /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying: /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

配置DHCP

[root@cobbler ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@cobbler ~]# cat /etc/dhcp/dhcpd.conf 
subnet 192.168.2.0 netmask 255.255.255.0 {
     option routers             192.168.2.1;
     option domain-name-servers 192.168.2.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.2.100 192.168.2.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.2.1;
}
filename="pxelinux.0";
[root@cobbler ~]# systemctl start dhcpd

cobbler 命令

cobbler check    核对当前设置是否有问题
cobbler list     列出所有的cobbler元素
cobbler report   列出元素的详细信息
cobbler sync     同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro   查看导入的发行版系统信息
cobbler system   查看添加的系统信息
cobbler profile  查看配置信息

cobbler import镜像

[root@cobbler CentOS]# cobbler import --name=CentOS7.3.1611 --path=/media/CentOS/
task started: 2020-02-05_233719_import
task started (id=Media import, time=Wed Feb  5 23:37:19 2020)
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/CentOS7.3.1611:
creating new distro: CentOS7.3.1611-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS7.3.1611 -> /var/www/cobbler/links/CentOS7.3.1611-x86_64
creating new profile: CentOS7.3.1611-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/CentOS7.3.1611 for CentOS7.3.1611-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS7.3.1611
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS7.3.1611
looking for /var/www/cobbler/ks_mirror/CentOS7.3.1611/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS7.3.1611/repodata
*** TASK COMPLETE ***

查看distro

[root@cobbler CentOS]# cobbler list
distros:
   CentOS7.3.1611-x86_64

profiles:
   CentOS7.3.1611-x86_64

创建kickstarts
[root@cobbler kickstarts]# vi /var/lib/cobbler/kickstarts/Centos-7.3.cfg

vi  /var/lib/cobbler/kickstarts/Centos-7.3.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'
# Root password
rootpw --iscrypted $1$vRQHZSOE$sSVeJcLgyHKU8bvnFYnb9.
# Use network installation
url --url=$tree
##也可以写成 url="http://192.168.2.1/cobbler/ks_mirror/centos7/"
# System language
lang en_US.UTF-8
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx

# System services
services --disabled="chronyd"
ignoredisk --only-use=sda
# Network information
network  --bootproto=dhcp --onboot=yes
# Halt after installation
reboot
# System timezone
timezone Asia/Shanghai --nontp
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part / --fstype="ext4" --size=51200
part swap --fstype="swap" --size=2048

%post

rm -f /etc/yum.repos.d/*

cat >>/etc/yum.repos.d/my.repo<<eof

[base]
name=sohu

baseurl=http://mirrors.sohu.com/centos/7/os/x86_64/

gpgcheck=0

enable=1


[epel]
name=epel

baseurl=http://mirrors.aliyun.com/epel/7Server/x86_64/

enable=1

gpgcheck=0

eof

%end


%packages
@^graphical-server-environment
@base
@compat-libraries
@core
@desktop-debugging
@development
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@java-platform
@kde-desktop
@multimedia
@print-client
@x11
kexec-tools

%end
[root@cobbler kickstarts]# cobbler profile edit --name=CentOS7.3.1611-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos-7.3.cfg
[root@cobbler kickstarts]# cobbler profile report | grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/Centos-7.3.cfg
Kickstart Metadata             : {}

添加cobbler

[root@cobbler kickstarts]# cobbler profile add --name=Centos7.3-2 --distro=CentOS7.3.1611-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos-7.3.2.cfg 
[root@cobbler kickstarts]# cobbler list
distros:
   CentOS7.3.1611-x86_64

profiles:
   CentOS7.3.1611-x86_64
   Centos7.3-2
   
[root@cobbler kickstarts]# cobbler sync

查看/var/lib/tftpboot/pxelinux.cfg/default

[root@cobbler pxelinux.cfg]# cat default 
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL CentOS7.3.1611-x86_64
        kernel /images/CentOS7.3.1611-x86_64/vmlinuz
        MENU LABEL CentOS7.3.1611-x86_64
        append initrd=/images/CentOS7.3.1611-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://192.168.2.1/cblr/svc/op/ks/profile/CentOS7.3.1611-x86_64
        ipappend 2

LABEL Centos7.3-2
        kernel /images/CentOS7.3.1611-x86_64/vmlinuz
        MENU LABEL Centos7.3-2
        append initrd=/images/CentOS7.3.1611-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://192.168.2.1/cblr/svc/op/ks/profile/Centos7.3-2
        ipappend 2



MENU end
[root@cobbler pxelinux.cfg]# pwd

第一次安装可以把local删掉
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值