cobbler(安装配置步骤)

引导

他支持多个系统版本选择
自定义 指定的主机装centos7

  • distro(发行版)
    定义操作系统的版本
  • Profile
    修改默认的ks文件为自定义ks文件
  • System主要用来控制网络

安装步骤

注意事项

如果要用yum安装在基本的base源中没有可以在阿里云的镜像站上找epel.repo源

开始安装(yum)

yum install cobbler cobbler-web dhcp tftp rsync pykickstart httpd xinetd 

注:xinetd是tftp的守护进程服务,rsync是同步服务


配置服务

首先启动服务

systemctl start httpd;systemctl start cobbler

配置开机自启

systemctl enable httpd;systemctl enable cobbler

然后运行cobbler check进行检测(检查自己需要配置什么文件)

cobbler check

按照要求更改文件

完成后配置dhcp,在主配置文件/etc/setting下把manage_dhcp改成1开启他(因为dhcp在cobbler里面可以自己管理也可以让cobbler管理)

vim /etc/cobbler/settings 
# choose whether to enable puppet parameterized classes or not.
# puppet versions prior to 2.6.5 do not support parameters
#puppet_parameterized_classes: 1

# set to 1 to enable Cobbler's DHCP management features.
# the choice of DHCP management engine is in /etc/cobbler/modules.conf
manage_dhcp: 1

# set to 1 to enable Cobbler's DNS management features.
# the choice of DNS mangement engine is in /etc/cobbler/modules.conf

然后配置dhcp的模板文件(/etc/cobbler/dhcp.template)

option pxe-system-type code 93 = unsigned integer 16;

subnet 192.168.56.0 netmask 255.255.255.0 {
     option routers             192.168.56.2;
     option domain-name-servers 192.168.56.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.56.100 192.168.56.200;
     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 {

然后配置distro(导入镜像)

挂载镜像

mount  /dev/cdrom /mnt

导入镜像(–arch指定架构 --path指定你自己想导入的镜像路径 --name指定在distor中的名字))

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

然后配置profile

建立kickstart脚本

cd /var/lib/cobbler/kickstarts/
vim centos6-x86_64.cfg
#CentOS7
#Kickstart Configurator by xuliangwei
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#url --url=

http://192.168.56.11/CentOS-7.1-x86_64 

#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel 
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5 
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled 
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

#Package install information
%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
tree
nmap
screen
%end

%post
systemctl disable postfix.service
%end

然后更改名字叫做Centos-7-x86_64的kickstart脚本路径

cobbler profile edit --name=Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6-x86_64.cfg 

如果是centos7你想用原来的eth0这样的网卡需要更改内核参数(在profile里面改)

cobbler profile edit --name=Centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'      #--kopts就是更改内核参数(kernel options)

完成后开启一个新的虚拟机用网卡启动即可

注:机器重启后不能去自动装系统就执行同步cobbler即可

cobbler sync


Koan配置

简介

koan是一个cobbler的辅助工具 koan
是kickstart-over-a-network的缩写,安装在客户端的使用,koan配合cobbler实现快速重装linux

安装(yum)

koan是cobbler的辅助工具所以他的yum源和cobbler的yum源一样 (这里我们以阿里云的开源镜像站做yum源)

[root@linux-node3 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

开始在cobbler的客户端安装koan

[root@linux-node3 ~]# yum install koan

查看远程的cobbler-server的镜像库

[root@linux-node3 ~]# koan --list=profiles --server=192.168.56.11
- looking for Cobbler at http://192.168.56.11:80/cobbler_api
Centos-7-x86_64
Centos6-x86_64
Centos6-i386
[root@linux-node3 ~]# 

注:system和profile的区别

profile类似于一个 配置文件,在里面定义好版本号(系统镜像也就是distro),ks文件,定义待安装主机的内核参数,等等

system是对安装的机器做具体的设置,如设置ip地址,hostname,等他还可以根据mac应用到具体的机器上

查看cobbler上的名字叫做Centos6-x86_64的profile

[root@linux-node3 ~]# koan --profile=Centos6-x86_64 --display --server=192.168.56.11
- looking for Cobbler at http://192.168.56.11:80/cobbler_api
- reading URL: http://192.168.56.11/cblr/svc/op/ks/profile/Centos6-x86_64
install_tree: http://192.168.56.11/cblr/links/Centos6-x86_64
                name  : Centos6-x86_64
              distro  : Centos6-x86_64
           kickstart  : http://192.168.56.11/cblr/svc/op/ks/profile/Centos6-x86_64
             ks_meta  : tree=http://@@http_server@@/cblr/links/Centos6-x86_64 
        install_tree  : http://192.168.56.11/cblr/links/Centos6-x86_64
              kernel  : /var/www/cobbler/ks_mirror/Centos6-x86_64/images/pxeboot/vmlinuz
              initrd  : /var/www/cobbler/ks_mirror/Centos6-x86_64/images/pxeboot/initrd.img
      kernel_options  : ks=http://192.168.56.11/cblr/svc/op/ks/profile/Centos6-x86_64 ksdevice=link kssendmac lang= text 
               repos  : 
            virt_ram  : 512
    virt_disk_driver  : raw
           virt_type  : kvm
           virt_path  : 
      virt_auto_boot  : 1
[root@linux-node3 ~]# 

然后再客户端上重新安装

[root@linux-node3 ~]# koan -r --server=192.168.56.11 --profile=Centos6-x86_64

注:-r:reinstall this host at next reboot

重启客户端开始重新自动安装

[root@linux-node3 ~]# reboot

cobbler同步远程的yum源到本地。

首先创建一个repo,并且指定mirror(远程的yum库,import是导入系统)

[root@localhost boot]# cobbler repo add --name=my_repo --arch=x86_64 --breed=yum --mirror=https://mirrors.aliyun.com/ceph/rpm/el6/x86_64/   

然后将上面的repo关联到指定的profile上

[root@localhost boot]# cobbler profile edit --name=Centos6-x86_64  --repo=my_repo

然后从远程同步到这个profile上

[root@localhost boot]# cobbler reposync

更改这个profile的ks文件

[root@localhost ~]# vim /var/lib/cobbler/kickstarts/Centos6-x86_64.cfg 
tree
nmap
sysstat
lrzsz
dos2unix
telnet

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
$yum-config_stanza
%post

%end

system

简介

system是profile的上面一层,他对profile做了扩展可以对特定的主机安装的时候做特定的配置也可以更改,mac,主机名,ip,等等不通过ks文件

配置

在创建system的时候就可以指定mac,然后这个这指定mac的主机可以直接自动安装,不用再选择

[root@localhost ~]# cobbler system add --name=Centos7-x86_64  --profile=Centos7-x86_64 --ip-address=192.168.56.55 --subnet=255.255.255.0 --gateway=192.168.56.2 --interface=eth0  --static=1 --name-servers=192.168.56.2 --hostname=linux-node5 --mac=00:50:56:20:F5:E7 

然后同步一下文件

[root@localhost ~]# cobbler sync

完成

猜你喜欢

转载自blog.csdn.net/qq_37026934/article/details/82799986