原創做品,容許轉載,轉載時請務必以超連接形式標明文章 原始出處 、做者信息和本聲明。不然將追究法律責任。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