原创做品,容许转载,转载时请务必以超连接形式标明文章 原始出处 、做者信息和本声明。不然将追究法律责任。http://my.oschina.net/u/2456754/admin/edit-blog?blog=506482 linux
马哥Linux运维 更多资讯:www.magedu.comweb
1、安装django
前提:cobbler由epel源提供,故此须要事先配置指向epel的yum源方可进行相似下面的安装过程。centos
# yum install cobbler cobbler-web pykickstart debmirrorsession
# service httpd startapp
# service cobblerd start运维
执行“cobbler check命令检查存的问题,然后逐一按提示解决之。常见的问题以下所示:dom
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.ui
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.this
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 'dists' on /etc/debmirror.conf for proper debian support
6 : comment '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
8 : 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.
如上各问题的解决方法以下所示:
一、修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如172.16.100.15;
二、修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如172.16.100.16;
三、若是当前节点能够访问互联网,执行“cobbler get-loaders”命令便可;不然,须要安装syslinux程序包,然后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
四、执行“chkconfig rsync on”命令便可;
五、注释/etc/debmirror.conf文件中的“@dists="sid";”一行;
六、注释/etc/debmirror.conf文件中的“@arches="i386";”一行;
七、执行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings文件中default_password_crypted参数的值;
八、执行“yum install cman fence-agents”命令安装相应的程序包便可;
接着重启cobblerd,然后执行“cobbler sync”同步新的配置至cobbler。
2、配置及启动cobbler所依赖的各服务
cobbler的运行依赖于dhcp、tftp、rsync及dns服务。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler自带的tftp功能提供;rsync由rsync程序包提供;dns可由bind提供,也可由dnsmasq提供。
cobbler可自行管理这些服务中的部分甚至是所有,但须要配置/etc/cobbler/settings文件中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分别进行定义。另外,因为每种服务都有着不一样的实现方式,如若须要进行自定义,须要经过修改/etc/cobbler/modules.conf配置文件中各服务的模块参数的值来实现。
本文采用了独立管理的方式,即不经过cobbler来管理这些服务。
2.1 配置dhcp服务
定义好所需的“subnet”及其它参数或选项,然后启动dhcpd守护进程便可。本示例中所用的dhcpd的配置以下所示:
option domain-name "magedu.com";
option domain-name-servers 192.168.10.254,172.16.0.1;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.21 192.168.10.100;
option routers 192.168.10.254;
}
next-server 192.168.10.254;
filename="pxelinux.0";
接着使用“service dhcpd start”启动服务便可。
2.2 配置tftp服务
# chkconfig tftp on
# service xinetd restart
3、配置cobbler
cobbler的各主要组件间的关系以下图所示。
3.1 管理distro
使cobbler变得可用的第一步为定义distro,其能够经过为其指定外部的安装引导内核及ramdisk文件的方式实现。而若是已经有完整的系统安装树(如CentOS6的安装镜像)则推荐使用import直接导入的方式进行。
例如,对于已经挂载至/media/cdrom目录的CentOS 6.4 x86_64的安装镜像,则可使用相似以下命令进行导入。
# cobbler import --name=centos-6.4-x86_64 --path=/media/cdrom
可以使用“cobbler distro list”列出全部的distro。
若是有kickstart文件,也可使用“--kickstart=/path/to/kickstart_file”进行导入,所以import会自动为导入的distro生成一个profile。
3.2 管理profile
cobbler使用profile来为特定的需求类别提供所须要安装配置,即在distro的基础上经过提供kickstart文件来生成一个特定的系统安装配置。distro的profile能够出如今PXE的引导菜单中做为安装的选择之一。
所以,若是须要为前面建立的centos-6.4-x86_64这个distro提供一个可引导安装条目,其用到的kickstart文件为/tmp/centos-6.4-x86_64.cfg(只提供了最基本的程序包),则可经过以下命令实现。
# cobbler profile add --name=centos-6.4-x86_64-basic --distro=centos-6.4-x86_64 --kickstart=/tmp/centos-6.4-x86_64.cfg
可以使用“cobbler profile list”查看已经建立的profile。
4、使用cobbler_web
4.1 cobbler_web的bug修复
当前epel源中提供的cobbler_web(程序包为cobbler-2.2.3-2.el6.noarch)存在bug,其/usr/share/cobbler/web/settings.py文件的内容须要修改成以下内容。
# Django settings for cobbler-web project.
import django
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = '' # cobbler-web does not use a database
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
# Force Django to use the systems timezone
TIME_ZONE = None
# Language section
# TBD.
LANGUAGE_CODE = 'en-us'
USE_I18N = False
SITE_ID = 1
# not used
MEDIA_ROOT = ''
MEDIA_URL = ''
ADMIN_MEDIA_PREFIX = '/media/'
SECRET_KEY = ''
# code config
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
else:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
if django.VERSION[0] == 1 and django.VERSION[1] < 2:
# Legacy django had a different CSRF method, which also had
# different middleware. We check the vesion here so we bring in
# the correct one.
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
else:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
'/usr/share/cobbler/web/templates',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'cobbler_web',
)
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
)
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
SESSION_FILE_PATH = '/var/lib/cobbler/webui_sessions'
4.2 配置cobbler_web的认证功能
cobbler_web支持多种认证方式,如authn_configfile、authn_ldap或authn_pam等,默认为authn_denyall,即拒绝全部用户登陆。下面说明两种能认证用户登陆cobbler_web的方式。
4.2.1 使用authn_pam模块认证cobbler_web用户
首先修改modules中[authentication]段的module参数的值为authn_pam。
接着添加系统用户,用户名和密码按需设定便可,例以下面的命令所示。
# useradd cblradmin
# echo 'cblrpass' | passwd --stdin cblradmin
然后将cblradmin用户添加至cobbler_web的admin组中。修改/etc/cobbler/users.conf文件,将cblradmin用户名添加为admin参数的值便可,以下所示。
[admins]
admin = "cblradmin"
最后重启cobblerd服务,经过http://YOUR_COBBLERD_IP/cobbler_web访问便可。
4.2.2 使用authn_configfile模块认证cobbler_web用户
首先修改modules中[authentication]段的module参数的值为authn_configfile。
接着建立其认证文件/etc/cobbler/users.digest,并添加所需的用户便可。须要注意的是,添加第一个用户时,须要为htdigest命令使用“-c”选项,后续添加其余用户时不能再使用;另外,cobbler_web的realm只能为Cobbler。以下所示。
# htdigest -c /etc/cobbler/users.digest Cobbler cblradmin
最后重启cobblerd服务,经过http://YOUR_COBBLERD_IP/cobbler_web访问便可。
本文出自 “马哥教育Linux” 博客,请务必保留此出处http://my.oschina.net/u/2456754/admin/edit-blog?blog=506482
马哥Linux运维 更多资讯:www.magedu.com