【Linux】部署cobbler

环境Centos 6.3,本地挂载镜像配置本地yum源

yum -y install dhcp httpd xinetd tftp-server

http://dl.fedoraproject.org/pub/epel/6/x86_64/目录下有epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm

yum update

遇到报错:

[root@localhost ~]# yum update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

需要调通网络,然后可执行成功。

yum install cobbler

(http://ftp6.sjtu.edu.cn/fedora/epel/6/x86_64/cobbler-2.4.0-1.el6.noarch.rpm)

启动cobbler

/etc/init.d/cobbler start

启动httpd

/etc/init.d/httpd start

关闭SELinux

/usr/sbin/setenforce 0

配置DHCP

####

检查cobbler配置

[root@localhost yum.repos.d]# 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : 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.
5 : change 'disable' to 'no' in /etc/xinetd.d/rsync
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : 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
9 : 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.
View Code

  

上面这段信息大意就是:

1,编辑/etc/cobbler/settings文件,找到 server选项,修改为适当的ip地址,本实例配置ip为:192.168.10.1

2,编辑/etc/cobbler/settings文件,找到 next_server选项,修改为适当的ip地址,本实例配置ip为:192.168.10.1

3,SELinux的设置。如果上面已经关闭了SELinux就不用管了

4,执行 cobbler get-loaders,系统将自动下载loader程序,完成提示4的修复工作。

5,编辑/etc/xinetd.d/tftp文件,将文件中的disable字段的配置由yes改为no

6,编辑/etc/xinetd.d/rsync文件,将文件中的disable字段的配置由yes改为no

7,在iptables中将69,80,25151端口打开。如果仅仅只是在内部环境中使用,建议直接将防火墙关掉

8,提示说debmirror没安装。如果不是安装 debian之类的系统,此提示可以忽略,如果需要安装,下载地址为:

http://rpmfind.net/linux/rpm2html/search.php?query=debmirror

CentOS 6使用RHEL 5的包就可以。

9,修改cobbler用户的默认密码,可以使用如下命令生成密码,并使用生成后的密码替换/etc/cobbler/settings中的密码。生成密码命令:

openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'

其中“random-phrase-here”为干扰码

所有提示全部fix之后,执行

/etc/init.d/cobblerd restart

再次cobbler check后提示

[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : service dhcpd is not running
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : ksvalidator was not found, install pykickstart
5 : 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
6 : 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.
View Code

执行cobbler sync出现报错

running: service dhcpd restart
received on stdout: Starting dhcpd: [FAILED]

修改DHCP配置文件

[root@localhost log]# vim /etc/cobbler/dhcp.template 
subnet 192.168.123.0 netmask 255.255.255.0 {
     option routers             192.168.123.1;
     option domain-name-servers 10.12.96.17;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.123.105 192.168.123.199;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.123.100;
     filename                   "/pxelinux.0";
}
View Code

如果启动dhcp服务仍然失败,可以tail -f /var/log/messages 分析原因

不用手动去修改dhcp服务配置文件,因为/etc/cobbler/dhcp.template文件会覆盖过去

报错提示没有kickstart,执行yum install pykickstart

报错提示没有fence-agents,执行yum install fence-agents

如果出现以下报错

[root@localhost ~]# cobbler check
Traceback (most recent call last):
  File "/usr/bin/cobbler", line 35, in <module>
    sys.exit(app.main())
  File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 644, in main
    rc = cli.run(sys.argv)
  File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 270, in run
    self.token         = self.remote.login("", self.shared_secret)
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib64/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<class 'cobbler.cexceptions.CX'>:'login failed'">
View Code

可以尝试

1、service cobblerd restart

2、cobbler get-loaders

对于自动部署的系统可以使用kickstart自动安装,可参考

http://my.oschina.net/lionel45/blog/111618 

原文地址:https://www.cnblogs.com/jiangxu67/p/3686489.html