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 ,如需转载请自行联系原作者
相关文章
|
10天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
61 0
|
10天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
28 0
|
10天前
|
NoSQL Linux Redis
linux 下和win下安装redis 并添加开机自启 图文详解
linux 下和win下安装redis 并添加开机自启 图文详解
15 0
|
10天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
35 0
|
18天前
|
运维 监控
现代运维中的自动化技术应用与挑战
现代运维工作中,自动化技术的应用已成为提高效率、降低成本的重要手段。本文探讨了自动化技术在运维领域的应用现状和挑战,包括自动化工具的选择、实施过程中的注意事项以及未来发展趋势。通过深入分析,帮助读者更好地理解和应用自动化技术,提升运维工作效率。
12 2
|
3天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
13 0
|
10天前
|
Java Linux 开发工具
linux jdk的安装
linux jdk的安装
16 0
|
18天前
|
Ubuntu Linux 虚拟化
【Linux】ubuntu安装samba服务器
【Linux】ubuntu安装samba服务器
|
18天前
|
NoSQL Linux Redis
Linux安装Redis
Linux安装Redis
26 0
|
18天前
|
Linux
Linux安装bind9搭建自己的域名服务器
Linux安装bind9搭建自己的域名服务器
11 0

热门文章

最新文章