登录  | 加入社区

黑狼游客您好!登录后享受更多精彩

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

查看: 909|回复: 0

怎样利用cobbler批量安装操纵体系(基于Centos7.x)?

[复制链接]

156

主题

156

帖子

0

现金

黑狼菜鸟

Rank: 1

积分
0
发表于 2019-3-4 22:50:35 | 显示全部楼层 |阅读模式 来自 江苏徐州
MC3aC2cC342335B1.jpg

一、Cobbler简介
Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和假造机,同时还可以管理DHCP,DNS等。
Cobbler可以利用下令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开辟利用。
Cobbler是较早前的kickstart的升级版,长处是比力轻易设置,还自带web界面比力易于管理。
Cobbler内置了一个轻量级设置管理体系,但它也支持和别的设置管理体系集成,如Puppet,临时不支持SaltStack。
cobbler集成的服务PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
电源管理
Kickstart服务支持
YUM堆栈管理
TFTP(PXE启动时必要)
Apache(提供kickstart的安装源,并提供定制化的kickstart设置)


二、安装cobbler
2.1 情况阐明
[root@Cobbler ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

[root@Cobbler ~]# uname -r
3.10.0-693.el7.x86_64

[root@Cobbler ~]# getenforce
Disabled

[root@Cobbler ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

[root@Cobbler ~]# hostname -I
10.0.0.202 172.16.1.202
yum源阐明:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2.2 利用yum安装cobbler
yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd阐明:cobbler是依靠与epel源下载
2.3 cobbler语法查抄前先启动http与cobbler
systemctl start httpd.service
systemctl start cobblerd.service
cobbler check2.4 举行语法查抄
[root@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.1and should match the IP of the boot server on the PXE network.

3 : change 'disable' to 'no' in /etc/xinetd.d/tftp

4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, orif 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.

5 : enable and start rsyncd.service with systemctl

6 : debmirror package is not installed, it will be required to manage debian deployments and repositories

7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settingsis still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one

8 : fencing tools were not foundand 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.2.5 办理当中的报错
下令集
sed -i 's/server: 127.0.0.1/server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'oldboy' '123456'`\"#" /etc/cobbler/settings
sed -i 's#yes#no#' /etc/xinetd.d/tftp

systemctl start rsyncd
systemctl enable rsyncd
systemctl enable tftp.socket
systemctl start tftp.socket
systemctl restart cobblerd.service

sed -i.ori 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template

cobbler sync
详解
办理1、2
cp /etc/cobbler/settings{,.ori}
sed -i 's/server: 127.0.0.1/server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.202/' /etc/cobbler/settings
题目3
sed 's#yes#no#g' /etc/xinetd.d/tftp -i
4 下载包所需的软件包
[root@Cobbler ~]# cobbler get-loaders
[root@Cobbler ~]# ls  /var/lib/cobbler/loaders
COPYING.elilo     elilo-ia64.efi   menu.c32    yaboot
COPYING.syslinux  grub-x86_64.efi  pxelinux.0
COPYING.yaboot    grub-x86.efi     README
5 启动rsync服务
[root@Cobbler ~]# systemctl start rsyncd.service
[root@Cobbler ~]# systemctl enable rsyncd.service
6 debian相干无需修改
7 修改安装完成后的root暗码
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
random-phrase-here  随机字符串
your-password-here 暗码
示例
[root@Cobbler ~]# openssl passwd -1 -salt 'OLDBOY' '123456'
$1$OLDBOY$LpJk4x1cplibx3q/O4O/K/
管理dhcp
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
防止重装
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
修改dhcp模板
sed -i.ori 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template
cobbler组设置文件位置
/etc/cobbler/settings
留意:修改完成之后要利用cobbler sync 举行同步,否则不见效。

2.6 修改之后
再次查抄语法:
[root@Cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : 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.
重启全部服务
systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket
到此cobbler就安装完成,下面举行web界面的操纵。

三、cobbler的web及界面操纵
欣赏器访问http://10.0.0.202/cobbler_web

留意CentOS7中cobbler只支持https访问。
账号暗码默认均为cobbler
3.1 操纵阐明--导入镜像
1)在假造机上添加上镜像
qwv1uVU9Hvv86uo1.jpg

2)挂载上镜像
[root@Cobbler ~]# mount /dev/cdrom  /mnt/
mount: /dev/sr0 is write-protected, mounting read-only

[root@Cobbler ~]# df -h |grep mnt
/dev/sr0        4.3G  4.3G     0 100% /mnt
3)举行导入镜像

选择Import DVD  输入Prefix(文件前缀),Arch(版本),Breed(品牌),Path(要从什么地方导入)
在导入镜像的时间要留意路径,防止循环导入。
信息设置好后,点击run,即可举行导入。
FY04i45TxFttITX7.jpg

导入过程利用rsync举行导入,三个历程消散表现导入完毕
[root@Cobbler mnt]# ps -ef |grep rsync
root   12026      1  0 19:04 ?   00:00:00 /usr/bin/rsync --daemon --no-detach
root  13554  11778 12 19:51 ?    00:00:06 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root   13555  13554  0 19:51 ?     00:00:00 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root   13556  13555 33 19:51 ?        00:00:17 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root   13590  10759  0 19:52 pts/1    00:00:00 grep --color=auto rsync
检察日记可以发现右running历程

日记位于 Events
Tchfqkv2uQ2Ilf9Z.jpg

导入完成后天生的文件夹
[root@Cobbler ks_mirror]# pwd
/var/www/cobbler/ks_mirror

[root@Cobbler ks_mirror]# ls
CentOS7.4-x86_64  config
3.2 创建一台空缺假造机,举行测试网路安装

留意:假造机的内存不能小于2G,网卡的设置要包管网络互通
启动假造机
启动假造机即可发现会有cobbler的选择界面
eGq5FQGFhzf58RfM.jpg

选择CentOS7.4即可举行安装,安装过程与光盘安装同等,这里就不在复述。
四、定制化安装操纵体系4.1 添加内核参数
1)检察导入的镜像,点击edit
les7e1YTMEzWgA5O.jpg

2)在内核参数中添加net.ifnames=0 biosdevname=0
可以或许让表现的网卡变为eth0 ,而不是CentOS7中的ens33
修改完成后点击生存
GFFfzo7HClCfLF7l.jpg

4.2 检察镜像属性
O7MvB6rioIQ3dLgD.jpg

4.3 编写ks文件
1)创建新的ks文件
kGuJbzmjcDUBdugp.jpg

2)添加ks文件,并设置文件名
创建完成后点击Save举行生存
oFk76LiK4l03L4l2.jpg

CentOS7  ks设置文件参考
 1 # Cobbler for Kickstart Configurator for CentOS 7 by oldboy
 2 install
 3 url --url=$tree
 4 text
 5 lang en_US.UTF-8
 6 keyboard us
 7 zerombr
 8 bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
 9 #Network information
10 $SNIPPET('network_config')
11 #network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7
12 timezone --utc Asia/Shanghai
13 authconfig --enableshadow --passalgo=sha512
14 rootpw  --iscrypted $default_password_crypted
15 clearpart --all --initlabel
16 part /boot --fstype xfs --size 1024
17 part swap --size 1024
18 part / --fstype xfs --size 1 --grow
19 firstboot --disable
20 selinux --disabled
21 firewall --disabled
22 logging --level=info
23 reboot
24 
25 %pre
26 $SNIPPET('log_ks_pre')
27 $SNIPPET('kickstart_start')
28 $SNIPPET('pre_install_network_config')
29 # Enable installation monitoring
30 $SNIPPET('pre_anamon')
31 %end
32 
33 %packages
34 @^minimal
35 @compat-libraries
36 @core
37 @debugging
38 @development
39 bash-completion
40 chrony
41 dos2unix
42 kexec-tools
43 lrzsz
44 nmap
45 sysstat
46 telnet
47 tree
48 vim
49 wget
50 %end
51 
52 %post
53 systemctl disable postfix.service
54 %end
4.4 自界说安装体系
1)选择systems 创建一个新的体系
HFW1p88pgxsU2Ac8.jpg

2)界说体系信息
pNhK85y1xQHNC6kA.jpg

3)设置全局网络信息
主机名、网关、DNS
N3MU6m6B0Gn8Z3o6.jpg

4)设置网卡信息,eth0,eth1
必要留意,选择static静态,
ffU1CUf0bN8n1Zu3.jpg

以上的全部设置完成后,点击Save举行生存
附录:
VMware workstation中检察假造机mac地点的方法。在假造机设置中。
hmkJH58519J5T2AH.jpg

cobbler web 界面阐明
AcoYE9zZJhd77Dgh.jpg

五、安装假造机
5.1 开启假造机

假如之前的设置就表现安装进度
sb6KY040By4zV7ky.jpg

5.2 安装完成举行查抄
vFlIPnz0njaEVasS.jpg



六、cobbler利用常见错误6.1 cobbler check报错
[root@Cobbler ~]# cobbler sync
Traceback (most recent call last):
  File "/usr/bin/cobbler", line 36in <span class="hljs-keyword" style="font-size: inherit;line-height: inherit;color: #F82375;word-wrap: inherit !important;word-break: inherit !important;"module/span>
    sys.exit(app.main())
  File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 662in main
    rc = cli.run(sys.argv)
  File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 269in run
    self.token         = self.remote.login("", self.shared_secret)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1587in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1273in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1306in single_request
    return self.parse_response(response)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1482in parse_response
    return u.close()
  File "/usr/lib64/python2.7/xmlrpclib.py", line 794in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: 
办理办法
systemctl restart httpd.service
systemctl restart cobblerd.service
cobbler check6.2 No space left on device
出现这个错误的缘故原由是假造机的内存不敷2G,将内存调为2G即可(这个错误只会出如今CentOS7.3之上)
本文内容来自于 老男孩Linux云盘算运维良好学员课后条记整理




老男孩教诲作为率先开展Linux和Python培训的领跑者,
Linux云盘算&&安全运维工程师2019重磅升级,连续领跑高端IT教诲:
课程更新7大亮点:
1、增长Python主动化CMDB平台实战项目(约4-10天);
2、增长大量网络安全课程(约10-20天);
3、增长阿里云企业级云服务实战情况项目实践(约2-4天);
4、增长个人发展、职场高薪、成为管理者职场头脑课(约10-20天);
5、增长Docker、K8S企业级实战实战项目(约5-10天);
6、增长ELK日记网络项目实战(约2天);
7、全程提供讲授课本、习题、测验,门生人手多本;
将Linux运维工程师、网络安全工程师、云盘算工程师、运维开辟、高级架构师、数据库管理员全运维类技能岗位一扫而空。



D75CYPAODPc5YTp1.jpg
● 免费充电桩 | 0底子学习Go语言"光速"入门教程
● 号外:老男孩又出新书啦(预售赠80元书签一套)!
● Linux运维Nginx软件优化,你会吗?
● 做运维比做开辟岗位强的6点利益,你知道么?
● 做运维必要相识哪些Redis数据库知识?(上)
● 做运维必要相识哪些Redis数据库知识?(下)
● CCTV央视访谈:老男孩教诲首创人冉宏元,带你玩转IT职场(内附视频)


老男孩IT教诲【Linux云盘算运维】课程,开设有整日制脱产班、周末班和网络在线班,以资助更多有必要的盆友们提拔技能,如果想要相识详细课程内容的话,那就点击本文左下方“阅读原文”来咨询吧~


看完本文有劳绩?那就分享给更多朋侪吧~

长按下方二维码,关注我哟

wl4uaDnbbL81baIU.jpg

万水千山总是情,点个【悦目】行不可? br0R2cf7d3I7z3mO.jpg




上一篇:Java高级|最新ElasticSearch6实战教程
下一篇:centos7新体系教程
您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

 

QQ|申请友链|小黑屋|手机版|Hlshell Inc. ( 豫ICP备16002110号-5 )

GMT+8, 2024-5-8 00:19 , Processed in 0.102414 second(s), 47 queries .

HLShell有权修改版权声明内容,如有任何爭議,HLShell將保留最終決定權!

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表