Linux 运维自动化之Cobbler实战案例(4)

六、Cobbler 实战案例安装CentOS6.4
1.实验拓扑

Linux 运维自动化之Cobbler实战案例

2.安装yum源
[root@node2 ~]# rpm -ivh Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving
warning: /var/tmp/rpm-tmp.N9dqlP: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY 
Preparing...        ########################################### [100%] 
  1:epel-release      ########################################### [100%]

3.同步系统时间
[root@node2 ~]# yum install -y ntp
[root@node2 ~]# ntpdate 202.120.2.101 
13 Nov 15:14:52 ntpdate[1174]: step time server 202.120.2.101 offset -28799.776629 sec 
[root@node2 ~]# hwclock -w

4.安装Cobbler基础包
[root@node2 ~]# yum install -y cobbler tftp dhcp httpd cman pykickstart debmirror

5.安装Cobbler依赖包
[root@node2 ~]# yum install -y ed patch perl perl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl

6.将所有服务加入开机自启动
[root@node2 ~]# chkconfig httpd on 
[root@node2 ~]# chkconfig dhcpd on 
[root@node2 ~]# chkconfig xinetd on 
[root@node2 ~]# chkconfig cobblerd on

7.修改httpd配置文件并启动httpd
[root@node2 ~]# vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
[root@node2 ~]# service httpd start 
正在启动 httpd:                      [确定] 
[root@node2 ~]# netstat -ntulp | grep :80 
tcp    0  0 :::80            :::*            LISTEN  1525/httpd

8.启动Cobbler服务并执行检查命令
[root@node2 ~]# service cobblerd start 
Starting cobbler daemon:                  [确定] 
[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.

9.解决上述相关配置错误
(1).错误1,修改/etc/cobbler/settings 里面的 server 为Cobbler Server的IP地址 ;
[root@node2 ~]# vim /etc/cobbler/settings
server: 192.168.18.202

(2).错误2,修改/etc/cobbler/settings 里面的 next_serverw 为本机的 ip;
[root@node2 ~]# vim /etc/cobbler/settings
next_server: 192.168.18.202

(3).错误3,据说这个错误可以忽略,有强迫完美运行症的人士可以运行以下命令来解决;
[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 to /var/lib/cobbler/loaders/README
downloading to/var/lib/cobbler/loaders/COPYING.elilo
downloading to/var/lib/cobbler/loaders/COPYING.yaboot
downloading to/var/lib/cobbler/loaders/COPYING.syslinux
downloading to/var/lib/cobbler/loaders/elilo-ia64.efi
downloading to/var/lib/cobbler/loaders/yaboot
downloading to/var/lib/cobbler/loaders/pxelinux.0
downloading to /var/lib/cobbler/loaders/menu.c32
downloading to/var/lib/cobbler/loaders/grub-x86.efi
downloading 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';
[root@node2 ~]# vim /etc/xinetd.d/tftp
disable    = no
[root@node2 ~]# vim /etc/xinetd.d/rsync
disable = no

注,启动xinetd服务。
[root@node2 ~]# service xinetd start
正在启动 xinetd:          [确定]

(5).错误5与错误6,debmmirror有错误;
[root@node2 ~]# vim /etc/debmirror.conf
#注释掉@dists="sid"与@arches="i386即可
#@dists="sid";
#@arches="i386";

(6).错误7,设置默认root密码;
注,刚接触Cobbler的博友会问,这个密码是什么密码。有的博友系统安装好了会问,root密码是什么。这里设置的就是客户端安装好系统的root密码。
注,生成你想要的密码的加密字符串,然后复制运行命令之后的加密代码;
12 [root@node2 ~]# openssl passwd -1 -salt 'hahaha' '123456'
$1$hahaha$hSxFjZSHRoiEn4DYrrGUI.

注,然后替换/etc/cobbler/settings 中选项双引号中的加密代码;
[root@node2 ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$hahaha$hSxFjZSHRoiEn4DYrrGUI."

10.重新启动Cobbler并运行检查命令
[root@node2 ~]# service cobblerd restart
Stopping cobbler daemon:        [确定]
Starting cobbler daemon:        [确定]
[root@node2 ~]# cobbler check 
The following are potential configuration items that you may want to fix:
1 : service dhcpd is not running
Restart cobblerd and then run 'cobbler sync' to apply changes.

11.修改DHCP模板
[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 192.168.18.254; 
  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;

linux

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/18954.html