博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cobbler 自动化安装简单实现
阅读量:6615 次
发布时间:2019-06-25

本文共 4489 字,大约阅读时间需要 14 分钟。

cobbler系统自动化安装

准备环境:

centos7
EPEL源(sohu旧源)
连接互联网
独立网段vmnet6 (确保vmware中dhcp服务关闭)
eth0:10.0.0.200/16 vmnet6
eth1:172.20.0.7/16 vmnet0 桥接 192.168.33.131 NAT 可以上网

[root@centos7 ~]#getenforce //确保selinux已经关闭

Disabled
[root@centos7 ~]#iptables -F //清防火墙

1、 安装包

[root@centos7 ~]#yum install cobbler cobbler-web dhcp
[root@centos7 ~]#systemctl enable dhcpd httpd tftp cobblerd //暂且先不起dhcp, 服务尚未配置
[root@centos7 ~]#systemctl start cobblerd httpd tftp

2、检查cobbler配置存在的问题,逐一解决

[root@centos7 ~]#cobbler check

3、编辑cobbler的配置文件

[root@centos7 ~]#vim /etc/cobbler/settings
server 10.0.0.200
next_server: 10.0.0.200
manage_dhcp: 1
default_password_crypted: "$1$iXvBL83y$EYkqMm9z.clIubP/kB6PC0" //用下面命令生成密码来取代默认的密码,更安全

[root@centos7 ~]#openssl passwd -1 //生成root口令

Password:
Verifying - Password:
$1$iXvBL83y$EYkqMm9z.clIubP/kB6PC0

执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;

[root@centos7 ~]#cobbler get-loaders
task started: 2019-01-31_100341_get_loaders
task started (id=Download Bootloader Content, time=Thu Jan 31 10:03:41 2019)
downloading to /var/lib/cobbler/loaders/README
downloading to /var/lib/cobbler/loaders/COPYING.elilo
downloading to /var/lib/cobbler/loaders/COPYING.yaboot
downloading to /var/lib/cobbler/loaders/COPYING.syslinux
downloading to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading to /var/lib/cobbler/loaders/yaboot
downloading to /var/lib/cobbler/loaders/pxelinux.0
downloading to /var/lib/cobbler/loaders/menu.c32
downloading to /var/lib/cobbler/loaders/grub-x86.efi
downloading to /var/lib/cobbler/loaders/grub-x86_64.efi
TASK COMPLETE

//查看/var/lib/cobbler/loaders/目录结构

[root@centos7 ~]#tree /var/lib/cobbler/loaders/
/var/lib/cobbler/loaders/
├── COPYING.elilo
├── COPYING.syslinux
├── COPYING.yaboot
├── elilo-ia64.efi
├── grub-x86_64.efi
├── grub-x86.efi
├── menu.c32
├── pxelinux.0
├── README
└── yaboot

//查看/var/lib/tftpboot/目录结构

[root@centos7 ~]#tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│ └── grub
│ └── menu.lst
├── etc
├── grub
│ ├── efidefault
│ └── images -> ../images
├── images
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│ └── default
└── s390x
└── profile_list

4、修改cobbler的dhcp模版,这个模板会覆盖dhcp本身的配置文件

[root@centos7 ~]#vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.0.0 {
option routers 10.0.0.254;
option domain-name-servers 223.5.5.5;
range dynamic-bootp 10.0.0.10 10.0.100.254;

5、同步cobbler的配置,可以看到同步干了哪些事

[root@centos7 ~]#cobbler sync

[root@cobbler ~]# cobbler //Cobbler的命令行管理(6和7的命令是一致的)

usage

cobbler <distro|profile|system|repo|p_w_picpath|mgmtclass|package|file> ...

[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
cobbler check //核对当前设置是否有问题
cobbler list //列出所有的cobbler元素cobbler
report //列出元素的详细信息
cobbler sync //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync //同步yum仓库
cobbler distro //查看导入的发行版系统信息
cobbler system //查看添加的系统信息cobbler
profile //查看配置信息

6、导入系统源

[root@centos7 ~]#echo "- - -" > /sys/class/scsi_host/host0/scan //添加光驱,挂载光盘,通过下面步骤识别光盘

[root@centos7 ~]#df

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sr0 9176232 9176232 0 100% /run/media/root/CentOS 7 x86_64
/dev/sr1 3897932 3897932 0 100% /run/media/root/CentOS_6.10_Final

[root@centos7 ~]#mount /dev/sr1 /mnt/ //临时挂载光盘

[root@centos7 mnt]# cobbler import --name=centos-6.10-x86_64 --path=/mnt --arch=x86_64

--name //为安装源定义一个名字
--path //镜像路径
--arch //指定安装源是32位、64位、ia64, 目前支持的选项有: x86 x86_64 ia64

#查看镜像列表

[root@centos7 mnt]# cobbler distro list
CentOS-6.10-x86_64

[root@centos7 ~]#du -sh /var/www/cobbler/ks_mirror/ //导入文件的路径

3.8G /var/www/cobbler/ks_mirror/

[root@centos7 ~]#cat /var/lib/tftpboot/pxelinux.cfg/default

DEFAULT menu
PROMPT 0
MENU TITLE Cobbler |
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local

MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1

LABEL centos-6.10-x86_64

kernel /images/centos-6.10-x86_64/vmlinuz
MENU LABEL centos-6.10-x86_64
append initrd=/images/centos-6.10-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=
ipappend 2
MENU end

7、 导入自定义的ks文件

[root@centos7 ~]#cobbler profile remove --name=centos-7.6-x86_64
[root@centos7 ~]#cobbler profile add --name=centos-7.6-x86_64_test --distro=centos-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7_mini.cfg

cobbler 自动化部署也可以参考网上资料:

Cobbler-自动化部署神器:

转载于:https://blog.51cto.com/8845692/2350839

你可能感兴趣的文章
笔记本电脑同时连接无线网络(互联网)和有线网络(内网)的方法
查看>>
eclipse离线插件
查看>>
BOM导致的Build failed in Jenkins with error MSB4025
查看>>
渣打迷你编程马拉松(Mini Code Marathon)小记
查看>>
mac 下添加mysql开机启动
查看>>
末日生存者的信条
查看>>
jquery mobile 定时器代码
查看>>
牛人整理的Django资源大全(转载)
查看>>
Android4.0 WiFi 源码解读
查看>>
反序列化坑
查看>>
dubbo源码解读系列之一dubbo项目组成
查看>>
linux中seq命令用法
查看>>
arnold resouces
查看>>
凭兴趣求职80%会失败,为什么
查看>>
URI的常用使用场景
查看>>
详解网络流量监控
查看>>
Ubuntu 修改 IP/DNS
查看>>
Java API 学习 (java 、javax 、org )的理解 (1)
查看>>
mysql error:Lock wait timeout exceeded
查看>>
将乱码后的中文作为key放入redis后,取值时找不到key该怎么弄
查看>>