Linux 运维自动化之Cobbler安装与配置详解

简介:

大纲

一、前言

二、环境配置

三、Cobbler 安装

四、Cobbler 配置详解

注,操作系统 CentOS 6.4 x86_64,软件版本 Cobbler-2.4.0-1。(目前最新版


一、前言

在上一篇博客中(http://freeloda.blog.51cto.com/2033581/1319695)我们主要讲解与Cobbler相关的基础知识,在一篇博客中我们主要中大家来说一下Cobbler安装与配置,并且详细说一下Cobbler命令的使用。好了,废话不多说下面直接上干货。


二、环境配置

1.实验拓扑

Cobbler 拓扑

2.安装yum源

1
2
3
4
5
[root@node2 ~] # rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http: //download .fedoraproject.org /pub/epel/6/x86_64/epel-release-6-8 .noarch.rpm
warning:  /var/tmp/rpm-tmp .z0cbxV: Header V3 RSA /SHA256  Signature, key ID 0608b895: NOKEY
Preparing...         ########################################### [100%]
   1:epel-release       ########################################### [100%]

3.同步系统时间

1
2
3
4
[root@node2 ~] # yum install -y ntp
[root@node2 ~] # ntpdate 202.120.2.101
  4 Nov 13:49:41 ntpdate[1190]: step  time  server 202.120.2.101 offset 388653.714776 sec
[root@node2 ~] # hwclock -w

4.关闭防火墙与SELinux

1
2
3
4
[root@node2 ~] # service iptables stop
[root@node2 ~] # chkconfig iptables off
[root@node2 ~] # getenforce
Disabled


三、Cobbler 安装

1.Cobbler运行所需基础包

1
[root@node2 ~] # yum install -y cobbler tftp dhcp httpd cman pykickstart debmirror

2.Cobblerf所需环境支持包

1
[root@node2 ~] # yum install -y ed patch perl perl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl

3.将所有服务加入开机自启动并启动相关服务

1
2
3
4
5
6
7
8
9
10
[root@node2 ~] # chkconfig httpd on
[root@node2 ~] # chkconfig dhcpd on
[root@node2 ~] # chkconfig xinetd on
[root@node2 ~] # chkconfig cobblerd on
[root@node2 ~] #
[root@node2 ~] # service httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using node2. test .com  for  ServerName
                               [确定]
[root@node2 ~] # service cobblerd start
Starting cobbler daemon:                  [确定]

4.修改apache相关配置并重新启动

注,从上面的启动信息可以看出apache启动有点小错误,我们来修正一下。

1
2
3
4
5
6
[root@node2 ~] # vim /etc/httpd/conf/httpd.conf
#增加一行
ServerName localhost:80
[root@node2 ~] # service httpd restart
停止 httpd:                        [确定]
正在启动 httpd:                      [确定]

5.运行Cobbler检查命令

1
2
3
4
5
6
7
8
9
10
[root@node2 ~] # 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 : 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.
4 : change  'disable'  to  'no'  in  /etc/xinetd .d /rsync
5 : comment out  'dists'  on  /etc/debmirror .conf  for  proper debian support
6 : comment out  'arches'  on  /etc/debmirror .conf  for  proper debian support
7 : 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
Restart cobblerd and  then  run  'cobbler sync'  to apply changes.

注,从上面的执行结果来看上面有7处错误,下面我们来解决一下。

(1).错误1,修改/etc/cobbler/settings 里面的 server 为Cobbler Server的IP地址 ;

1
2
[root@node2 ~] # vim /etc/cobbler/settings
server: 192.168.18.202

(2).错误2,修改/etc/cobbler/settings 里面的 next_serverw 为本机的 ip;

1
2
[root@node2 ~] # vim /etc/cobbler/settings
next_server: 192.168.18.202

(3).错误3,据说这个错误可以忽略,有强迫完美运行症的人士可以运行以下命令来解决;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@node2 ~] # cobbler get-loaders
task started: 2013-11-04_143149_get_loaders
task started ( id =Download Bootloader Content,  time =Mon Nov 4 14:31:49 2013)
downloading http: //www .cobblerd.org /loaders/README  to  /var/lib/cobbler/loaders/README
downloading http: //www .cobblerd.org /loaders/COPYING .elilo to  /var/lib/cobbler/loaders/COPYING .elilo
downloading http: //www .cobblerd.org /loaders/COPYING .yaboot to  /var/lib/cobbler/loaders/COPYING .yaboot
downloading http: //www .cobblerd.org /loaders/COPYING .syslinux to  /var/lib/cobbler/loaders/COPYING .syslinux
downloading http: //www .cobblerd.org /loaders/elilo-3 .8-ia64.efi to  /var/lib/cobbler/loaders/elilo-ia64 .efi
downloading http: //www .cobblerd.org /loaders/yaboot-1 .3.14-12 to  /var/lib/cobbler/loaders/yaboot
downloading http: //www .cobblerd.org /loaders/pxelinux .0-3.61 to  /var/lib/cobbler/loaders/pxelinux .0
downloading http: //www .cobblerd.org /loaders/menu .c32-3.61 to  /var/lib/cobbler/loaders/menu .c32
downloading http: //www .cobblerd.org /loaders/grub-0 .97-x86.efi to  /var/lib/cobbler/loaders/grub-x86 .efi
downloading http: //www .cobblerd.org /loaders/grub-0 .97-x86_64.efi to  /var/lib/cobbler/loaders/grub-x86_64 .efi
*** TASK COMPLETE ***

(4).错误4,修改/etc/xinetd.d/tftp 把'disable' 修改为'no';修改/etc/xinetd.d/rsync 把'disable' 修改为'no';

1
2
3
4
[root@node2 ~] # vim /etc/xinetd.d/tftp
disable         = no
[root@node2 ~] # vim /etc/xinetd.d/rsync
disable = no

注,启动xinetd服务。

1
2
[root@node2 ~] # service xinetd start
正在启动 xinetd:                     [确定]

(5).错误5与错误6,debmmirror有错误;

1
2
3
4
[root@node2 ~] # vim /etc/debmirror.conf
#注释掉@dists="sid"与@arches="i386即可
#@dists="sid";
#@arches="i386";

(6).错误7,设置默认root密码;

注,刚接触Cobbler的博友会问,这个密码是什么密码。有的博友系统安装好了会问,root密码是什么。这里设置的就是客户端安装好系统的root密码。

#生成你想要的密码的加密字符串,然后复制运行命令之后的加密代码;

1
2
[root@node2 ~] # openssl passwd -1 -salt 'hahaha' '123456'
$1$hahaha$hSxFjZSHRoiEn4DYrrGUI.

#然后替换/etc/cobbler/settings 中选项双引号中的加密代码;

1
2
[root@node2 ~] # vim /etc/cobbler/settings
default_password_crypted:  "$1$hahaha$hSxFjZSHRoiEn4DYrrGUI."

6.重新启动Cobbler并运行检查命令

1
2
3
4
5
[root@node2 ~] # service cobblerd restart
Stopping cobbler daemon:                  [确定]
Starting cobbler daemon:                  [确定]
[root@node2 ~] # cobbler check
No configuration problems found. All systems go.

好了,到这里我们Cobbler安装就全部完成了,最后我们来查看一下启动的端口。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@node2 ~] # netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address        Foreign Address       State    PID /Program  name
tcp    0   0 0.0.0.0:22         0.0.0.0:*          LISTEN   1011 /sshd 
tcp    0   0 127.0.0.1:25        0.0.0.0:*          LISTEN   1087 /master
tcp    0   0 127.0.0.1:6010       0.0.0.0:*          LISTEN   1126 /sshd 
tcp    0   0 127.0.0.1:6011       0.0.0.0:*          LISTEN   1607 /sshd 
tcp    0   0 127.0.0.1:25151       0.0.0.0:*          LISTEN   12677 /python
tcp    0   0 :::80            :::*            LISTEN   1696 /httpd
tcp    0   0 :::22            :::*            LISTEN   1011 /sshd 
tcp    0   0 ::1:25           :::*            LISTEN   1087 /master
tcp    0   0 ::1:6010          :::*            LISTEN   1126 /sshd 
tcp    0   0 ::1:6011          :::*            LISTEN   1607 /sshd 
tcp    0   0 :::873           :::*            LISTEN   12747 /xinetd
udp    0   0 0.0.0.0:69         0.0.0.0:*                12747 /xinetd


四、Cobbler 配置详解

主要的 Cobbler 配置文件是 /etc/cobbler/settings。使用文本编辑器打开这个文件,并设置以下选项:

  • manage_dhcp:1

  • manage_dns:1

  • manage_tftpd:1

  • restart_dhcp:1

  • restart_dns:1

  • pxe_just_once:1

  • next_server:<服务器的 IP 地址>

  • server:<服务器的 IP 地址>

选项 manage_* 和 restart_* 无需加以说明。选项 next_server 用在 DHCP 配置文件中,向客户端告知提供引导文件的服务器地址。选项 server 在客户端安装期间用于引用 Cobbler 服务器地址。最后,选项 pxe_just_once 预防将机器中的安装循环配置为始终从网络引导。激活此选项时,机器告诉 Cobbler 安装已完成。Cobbler 将系统对象的 netboot 标志更改为 false,这会强制机器从本地磁盘引导。好了,下面我们配置并管理dhcp服务与http服务。


1.让Cobbler来管理DHCP服务器

1
2
[root@node2 ~] # vim /etc/cobbler/settings
manage_dhcp: 1

2.修改DHCP模板

1
2
3
4
5
6
7
8
9
10
11
[root@node2 ~] # vim /etc/cobbler/dhcp.template
subnet 192.168.18.0 netmask 255.255.255.0 {
option routers 192.168.18.254;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.18.221 192.168.18.225;
filename  "/pxelinux.0" ;
default-lease- time  21600;
max-lease- time  43200;
next-server $next_server;
}

3.重新启动Cobbler服务

1
2
3
[root@node2 ~] # service cobblerd restart
Stopping cobbler daemon:                  [确定]
Starting cobbler daemon:                  [确定]

4.编辑/etc/httpd/conf.d/wsgi.conf 去掉注释

1
2
[root@node2 ~] # vim /etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules /mod_wsgi .so

5.完成后一定要运行cobbler sync 命令让配置生效,使dhcp、http被cobbler接管,不然会报错。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@node2 ~] # cobbler sync
task started: 2013-11-04_164727_sync
task started ( id =Sync,  time =Mon Nov 4 16:47:27 2013)
running pre- sync  triggers
cleaning trees
removing:  /var/lib/tftpboot/pxelinux .cfg /default
removing:  /var/lib/tftpboot/grub/grub-x86_64 .efi
removing:  /var/lib/tftpboot/grub/images
removing:  /var/lib/tftpboot/grub/efidefault
removing:  /var/lib/tftpboot/grub/grub-x86 .efi
removing:  /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink  /var/lib/cobbler/loaders/grub-x86_64 .efi ->  /var/lib/tftpboot/grub/grub-x86_64 .efi
trying hardlink  /var/lib/cobbler/loaders/grub-x86 .efi ->  /var/lib/tftpboot/grub/grub-x86 .efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating  /etc/dhcp/dhcpd .conf
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: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout: 关闭 dhcpd:[确定]
正在启动 dhcpd:[确定]
received on stderr:
running shell triggers from  /var/lib/cobbler/triggers/sync/post/ *
running python triggers from  /var/lib/cobbler/triggers/change/ *
running python trigger cobbler.modules.scm_track
running shell triggers from  /var/lib/cobbler/triggers/change/ *
*** TASK COMPLETE ***

好了,到这里我们的Cobbler安装与配置就讲解完成了,我们在下一篇博客中将讲解Cobbler管理与使用详解。最后,希望大家有所收获^_^……















本文转自陈明乾51CTO博客,原文链接: http://blog.51cto.com/freeloda/1320090 ,如需转载请自行联系原作者
目录
打赏
0
0
0
0
101
分享
相关文章
【Linux】vim使用与配置教程
Vim是一款功能强大的文本编辑器,广泛应用于Linux环境,是开发者和系统管理员的必备工具。本文介绍了Vim的基本操作与简单配置,涵盖命令模式、插入模式和底行模式的使用方法,以及光标定位、复制粘贴、搜索替换等常用技巧。同时,文章还提供了实用的分屏操作和代码注释方法,并分享了通过`.vimrc`文件进行个性化配置(如显示行号、语法高亮、自动缩进等)的技巧,帮助用户提升文本编辑效率。掌握这些内容,能让Vim更好地服务于日常工作与开发需求。
61 3
|
28天前
|
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
本文详细介绍了在VMware虚拟机中安装CentOS 6.8的全过程。首先,需确保已安装VMware并开启V-CPU虚拟化功能,可通过BIOS设置或使用LeoMoon CPU-V工具检测。接着,下载CentOS镜像文件,并在VMware中新建虚拟机,配置CPU、内存、硬盘等参数。最后,加载ISO镜像启动虚拟机,按照提示完成CentOS的安装,包括语言、键盘、存储方式、地区、密码设置及硬盘分区等步骤。安装完成后,以root用户登录即可进入系统桌面,开始学习Linux命令和操作。
109 12
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
在Rocky Linux 9上安装JDK并配置环境变量!
本教程介绍在Rocky Linux 9上安装JDK并配置环境变量的完整步骤。首先更新系统,清理旧版本JDK相关包及残留文件,确保环境干净。接着搜索并安装所需版本的JDK(如OpenJDK 17),验证安装是否成功。然后查找JDK安装路径,配置全局环境变量`JAVA_HOME`和`PATH`,最后验证环境变量设置。按照此流程操作,可顺利完成Java开发环境搭建,支持多版本切换(如JDK 8/11/17)。生产环境请谨慎操作,避免影响现有服务。
79 21
YashanDB Linux客户端安装
本文详细介绍了YashanDB客户端在Linux系统中的安装、使用与卸载步骤。安装方法包括适用于所有Linux平台的脚本安装和专用于CentOS的rpm安装。脚本安装需解压软件包并配置环境变量,而rpm安装则需以root用户执行相关命令。此外,文章还说明了如何通过yasql连接YashanDB并进行数据库操作,以及两种安装方式对应的卸载方法,帮助用户顺利完成客户端的管理与维护。
Linux 手动安装快速部署 LNMP 环境实战
本文详细记录了在阿里云ECS上手动搭建LNMP环境的过程,系统选用Ubuntu 24.04。主要内容包括:1) 使用`apt`安装Nginx和MySQL,并更新软件源;2) 编译安装PHP 8.4.5,配置PHP-FPM及环境路径;3) 配置MySQL root用户密码;4) 调整Nginx支持PHP解析并测试整体环境。通过此过程,重现手动配置服务器的细节,帮助熟悉各组件的安装与协同工作。
Android调试终极指南:ADB安装+多设备连接+ANR日志抓取全流程解析,覆盖环境变量配置/多设备调试/ANR日志分析全流程,附Win/Mac/Linux三平台解决方案
ADB(Android Debug Bridge)是安卓开发中的重要工具,用于连接电脑与安卓设备,实现文件传输、应用管理、日志抓取等功能。本文介绍了 ADB 的基本概念、安装配置及常用命令。包括:1) 基本命令如 `adb version` 和 `adb devices`;2) 权限操作如 `adb root` 和 `adb shell`;3) APK 操作如安装、卸载应用;4) 文件传输如 `adb push` 和 `adb pull`;5) 日志记录如 `adb logcat`;6) 系统信息获取如屏幕截图和录屏。通过这些功能,用户可高效调试和管理安卓设备。
|
15天前
|
微服务2——MongoDB单机部署4——Linux系统中的安装启动和连接
本节主要介绍了在Linux系统中安装、启动和连接MongoDB的详细步骤。首先从官网下载MongoDB压缩包并解压至指定目录,接着创建数据和日志存储目录,并配置`mongod.conf`文件以设定日志路径、数据存储路径及绑定IP等参数。之后通过配置文件启动MongoDB服务,并使用`mongo`命令或Compass工具进行连接测试。此外,还提供了防火墙配置建议以及服务停止的两种方法:快速关闭(直接杀死进程)和标准关闭(通过客户端命令安全关闭)。最后补充了数据损坏时的修复操作,确保数据库的稳定运行。
47 0
,自动化运维成为现代IT基础设施的关键部分。Puppet是一款强大的自动化运维工具
【10月更文挑战第7天】随着云计算和容器化技术的发展,自动化运维成为现代IT基础设施的关键部分。Puppet是一款强大的自动化运维工具,通过定义资源状态和关系,确保系统始终处于期望配置状态。本文介绍Puppet的基本概念、安装配置及使用示例,帮助读者快速掌握Puppet,实现高效自动化运维。
127 4
HTTPS 证书自动化运维:https证书管理系统- 自动化监控
本文介绍如何设置和查看域名或证书监控。步骤1:根据证书状态选择新增域名或证书监控,线上部署推荐域名监控,未部署选择证书监控。步骤2:查询监控记录详情。步骤3:在详情页查看每日定时检测结果或手动测试。
HTTPS 证书自动化运维:https证书管理系统- 自动化监控
HTTPS 证书自动化运维:https证书管理系统-自动化部署
本指南介绍如何部署Linux服务器节点。首先复制生成的Linux脚本命令,然后将其粘贴到目标服务器上运行。接着刷新页面查看节点记录,并点击“配置证书”选择证书以自动部署。最后,节点部署完成,后续将自动调度,无需人工干预。
HTTPS 证书自动化运维:https证书管理系统-自动化部署