2024年Linux最新Cobbler原理与实战(1)

Restart cobblerd and then run ‘cobbler sync’ to apply changes.


问题**1,2,7:**



> 
> 默认密码,setting,和dhcp
> 
> 
> 


生成新的默认密码



[root@l27-server1 ~]# openssl passwd -1 -salt openssl rand 15 -base64 ‘123’
1 1 1Yo1o0fBf$pm5RkWqGdviwsu4YiWhF9/



> 
> 注意: 此密码是系统安装后的默认密码,建议使用强密码
> 
> 
> 


修改setting配置文件



sed -i ‘s%^server: 127.0.0.1%server: 192.168.217.155%g’ /etc/cobbler/settings
sed -i ‘s%^next_server: 127.0.0.1%next_server: 192.168.217.155%g’ /etc/cobbler/settings
sed -i ‘s%manage_dhcp: 0%manage_dhcp: 1%g’ /etc/cobbler/settings
sed -i ‘s%^default_password_crypted.*%default_password_crypted: “ 1 1 1Yo1o0fBf$pm5RkWqGdviwsu4YiWhF9/”%g’ /etc/cobbler/settings


配置DHCP /etc/dhcp/dhcpd.conf(根据需求更改)



subnet 192.168.217.0 netmask 255.255.255.0 {
option routers 192.168.217.254; #网关地址
option domain-name-servers 114.114.114.114; #dns地址
option subnet-mask 255.255.255.0; #掩码
range dynamic-bootp 192.168.217.10 192.168.217.100; #地址分配范围 default-lease-time 21600;
max-lease-time 43200;
next-server $next_server; #引用上面setting配置的nex-server值
filename “/pxelinux.0”;
}


还要修改/etc/cobbler/dhcp.template 文件



subnet 192.168.217.0 netmask 255.255.255.0 {
option routers 192.168.217.155;
option domain-name-servers 114.114.114.114;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.217.10 192.168.217.100;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class “pxeclients” {


问题**3:**



> 
> 关闭selinux
> 
> 
> 



[root@l27-server1 ~]# setenforce 0
#编辑/etc/selinux/config,并重启生效
SELINUX=disabled
init 6


问题**4**



> 
> 启动**tftp**服务
> 
> 
> 


编辑tftp服务配置文件 /etc/xinetd.d/tftp



service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no #修改此处值为
no per_source = 11
cps = 100 2
flags = IPv4
}


问题**5:**



> 
> 获取引导文件
> 
> 
> 



[root@l27-server1 ~]# cobbler get-loaders


截图


![在这里插入图片描述](https://img-blog.csdnimg.cn/20200430204400299.png)


问题**6:**



> 
> debian相关文件获取(如不需要部署debian系统可省略)
> 
> 
> 



[root@l27-server1 ~]# yum -y install debmirror
#修改/etc/debmirror.conf配置文件,注释掉@dists和@arches两行
[root@l27-server1 ~]# vi /etc/debmirror.conf

#@dists=“sid”;
@sections=“main,main/debian-installer,contrib,non-free”;
#@arches=“i386”;


问题**8:**


电源管理工具(可选)



yum -y install fence-agents


重启服务并同步状态



[root@l27-server1 ~]# systemctl restart cobblerd
[root@l27-server1 ~]# cobbler check
No configuration problems found. All systems go.


这就完成


 


##### cobbler基础配置


同步配置是配置生效



cobbler sync


配置**distro:**


主要用来定义和设置系统发行版本,里包含了系统的内核,引导文件,以及安装包等内容,就相当于一个LINUX系统的ISO镜像。如:多个发行版本,同一发行版不同版本号。


1.首先上传系统iso镜像文件,此处以ubuntu12.04镜像为例,其他镜像做法类似


wget http://releases.ubuntu.com/precise/ubuntu-12.04.5-server-amd64.iso



[root@l27-server1 ~]# mkdir -p /system/ubuntu1204 ; mount -t iso9660 ~/ubuntu-12.04.5-server-amd64.iso /system/ubuntu1204


2.导入镜像



[root@l27-server1 ~]# cobbler import --name=ubuntu1204 --path=/system/ubuntu1204 --arch=x86_64
task started: 2020-04-30_102441_import
task started (id=Media import, time=Thu Apr 30 10:24:41 2020)
Found a candidate signature: breed=freebsd, version=10.1
Found a candidate signature: breed=freebsd, version=10.0
Found a candidate signature: breed=freebsd, version=8.3
Found a candidate signature: breed=freebsd, version=8.2
Found a candidate signature: breed=freebsd, version=8.4
Found a candidate signature: breed=freebsd, version=11.0
Found a candidate signature: breed=freebsd, version=10.3
Found a candidate signature: breed=freebsd, version=11.2
Found a candidate signature: breed=freebsd, version=11.1
Found a candidate signature: breed=freebsd, version=12.0
Found a candidate signature: breed=freebsd, version=10.2
Found a candidate signature: breed=freebsd, version=11.3
Found a candidate signature: breed=freebsd, version=9.0
Found a candidate signature: breed=freebsd, version=9.1
Found a candidate signature: breed=freebsd, version=9.2
Found a candidate signature: breed=freebsd, version=9.3
Found a candidate signature: breed=ubuntu, version=precise
running: /usr/bin/file /var/www/cobbler/ks_mirror/ubuntu1204-x86_64/dists/precise/Release.gpg
received on stdout: /var/www/cobbler/ks_mirror/ubuntu1204-x86_64/dists/precise/Release.gpg: PGP signature

received on stderr:
running: /usr/bin/file /var/www/cobbler/ks_mirror/ubuntu1204-x86_64/dists/precise/Release
received on stdout: /var/www/cobbler/ks_mirror/ubuntu1204-x86_64/dists/precise/Release: ASCII text

received on stderr:
Found a matching signature: breed=ubuntu, version=precise
Adding distros from path /var/www/cobbler/ks_mirror/ubuntu1204-x86_64:
creating new distro: ubuntu1204-x86_64
trying symlink: /var/www/cobbler/ks_mirror/ubuntu1204-x86_64 -> /var/www/cobbler/links/ubuntu1204-x86_64
creating new profile: ubuntu1204-x86_64
associating repos
checking for apt repo(s)
adding apt repo for ubuntu1204-x86_64
Added repos for ubuntu1204-x86_64
*** TASK COMPLETE ***


3.查看distro配置



[root@localhost ~]# cobbler distro report
Name : ubuntu1204-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : ubuntu
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/ubuntu1204-x86_64/install/netboot/ubuntu-installer/amd64/initrd.gz
Kernel : /var/www/cobbler/ks_mirror/ubuntu1204-x86_64/install/netboot/ubuntu-installer/amd64/linux
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {‘tree’: ‘http://@@http_server@@/cblr/links/ubuntu1204-x86_64’}
Management Classes : []
OS Version : precise
Owners : [‘admin’]
Red Hat Management Key : <>
Red Hat Management Server : <>
Template Files : {}


查看ubuntu相关文件:



[root@localhost ~]# cobbler list
distros:
ubuntu1204-x86_64 #镜像

profiles:
ubuntu1204-x86_64 #配置,用于配置关联自动应答ks文件

systems: #可以为不同的主机根据MAC设置地址及安装参数

repos:
ubuntu1204-x86_64 #仓库,用于自定义仓库

images:

mgmtclasses:

packages:

files:


(**自定义**)**配置**profifile:定义自动安装应答文件


主要用来定义kickstart配置文件,安装时依据配置文件进行定制化安装,配置此项时要和distro进行关联。



[root@localhost ~]# cobbler profile report
Name : ubuntu1204-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : ubuntu1204-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.seed #关联的kickstart文件 (ubuntu和centos的ks文件格式有很大区别,不能混用)
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <>
Name Servers : []
Name Servers Search Path : []
Owners : [‘admin’]
Parent Profile :
Internal proxy :
Red Hat Management Key : <>
Red Hat Management Server : <>
Repos : []
Server Override : <>
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


配置repo:定义本地或远程仓库源


查看默认repo



[root@localhost ~]# cobbler repo report
Name : ubuntu1204-x86_64
Apt Components (apt only) : [‘main’, ‘universe’]
Apt Dist Names (apt only) : [‘precise’, ‘precise-updates’, ‘precise-security’]
Arch : x86_64
Breed : apt
Comment :
Createrepo Flags : <>
Environment Variables : {}
Keep Updated : True
Mirror : http://archive.ubuntu.com/ubuntu
Mirror locally : True
Owners : [‘admin’]
Priority : 99
External proxy URL :
RPM List : []
Yum Options : {‘–verbose’: ‘~’, ‘–ignore-release-gpg’: ‘~’}


自定义repo



cobbler repo add --help #创建
repo cobbler repo edit --help #修改repo


**(**自定义**)**配置**system**


主要用来定义内核参数,电源管理,计算机名,网络接口参数等(客户机),如:根据mac地址配置IP地址,通过和


profifile,distro关联实现自动化安装。



cobbler system add --help #创建
system cobbler system edit --help #修改system

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前在阿里

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上运维知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以点击这里获取!

帮助到想自学提升又不知道该从何学起的朋友。**
[外链图片转存中…(img-7rwMvtoW-1714476833875)]
[外链图片转存中…(img-uBtPGDmC-1714476833876)]
[外链图片转存中…(img-hFKayNNN-1714476833877)]
[外链图片转存中…(img-9tLA5GkL-1714476833877)]
[外链图片转存中…(img-ighBMllk-1714476833877)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上运维知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以点击这里获取!

  • 23
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值