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 ,如需转载请自行联系原作者
相关文章
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25
|
9天前
|
Linux Shell
问题记录:解决Linux登录故障,/etc/passwd配置受损该怎么操作
修复/etc/passwd文件是解决Linux登录故障的重要步骤。通过进入单用户模式、挂载文件系统、恢复或手动修复/etc/passwd文件,可以有效解决该问题。保持定期备份系统配置文件是预防此类问题的最佳实践。
37 13
|
8天前
|
Linux Shell
问题记录:解决Linux登录故障,/etc/passwd配置受损该怎么操作
修复/etc/passwd文件是解决Linux登录故障的重要步骤。通过进入单用户模式、挂载文件系统、恢复或手动修复/etc/passwd文件,可以有效解决该问题。保持定期备份系统配置文件是预防此类问题的最佳实践。
25 2
|
21天前
|
Ubuntu Java Linux
Linux 安装 Qualcomm ® SnapdragonTM Profiler
通过本文的详细介绍,您应该已经成功在 Linux 系统上安装并配置了 Qualcomm® Snapdragon™ Profiler,并能够连接 Android 设备进行性能分析。Snapdragon Profiler 提供了丰富的工具和功能,可以帮助开发者深入了解应用程序的性能瓶颈,从而进行优化。希望本文能对您有所帮助,让您在开发过程中更高效地使用 Snapdragon Profiler 进行性能分析和优化。
56 10
|
22天前
|
Linux
Linux安装svn并启动
Linux安装svn并启动
55 10
|
1月前
|
Oracle 关系型数据库 Linux
linux8安装oracle 11g遇到的问题记录
Oracle 11g在Linux 8上安装时会遇到link编译环节的问题。官方建议忽略安装中的链接错误,安装完成后应用DBPSU 11.2.0.4.240716补丁及一次性补丁33991024,再重新编译二进制文件,并配置监听器和数据库。但因11g已退出服务期,这些补丁需付费获取。网上信息显示22年1月的PSU补丁也可解决问题,找到该补丁后按常规方式打补丁即可。如有需求或疑问可咨询我。
83 20
|
1月前
|
弹性计算 运维 Ubuntu
os-copilot在Alibaba Cloud Linux镜像下的安装与功能测试
我顺利使用了OS Copilot的 -t -f 功能,我的疑惑是在换行的时候就直接进行提问了,每次只能写一个问题,没法连续换行更有逻辑的输入问题。 我认为 -t 管道 功能有用 ,能解决环境问题的连续性操作。 我认为 -f 管道 功能有用 ,可以单独创建可连续性提问的task问题。 我认为 | 对文件直接理解在新的服务器理解有很大的帮助。 此外,我还有建议 可以在非 co 的环境下也能进行连续性的提问。
79 7
|
2月前
|
Ubuntu Unix Linux
Linux网络文件系统NFS:配置与管理指南
NFS 是 Linux 系统中常用的网络文件系统协议,通过配置和管理 NFS,可以实现跨网络的文件共享。本文详细介绍了 NFS 的安装、配置、管理和常见问题的解决方法,希望对您的工作有所帮助。通过正确配置和优化 NFS,可以显著提高文件共享的效率和安全性。
274 7
|
2月前
|
NoSQL 关系型数据库 MySQL
Linux安装jdk、mysql、redis
Linux安装jdk、mysql、redis
238 7
|
8月前
|
NoSQL Java Linux
linux 安装 neo4j简介
Neo4j是高性能NoSQL图形数据库,利用图结构存储数据。推荐使用JDK 11配合Neo4j 3.x版本。下载3.5.9版,通过`curl`命令在Linux上获取tar.gz文件,然后解压。配置`neo4j.conf`,调整内存设置,开启远程访问。执行`./bin/neo4j start`启动,通过`http://服务器IP:7474`访问,默认凭据是username: neo4j, password: neo4j,登录后应更改密码。
662 1