码迷,mamicode.com
首页 > 其他好文 > 详细

Cobbler-CentOS6.7-无人值守安装

时间:2016-06-11 16:06:45      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:cobbler   配置文件   项目规划   管理工具   管理系统   服务器   

第1章 项目规划

1.1 角色说明

服务器说明

数量

说明

分发系统服务器

1

批量部署系统

新服务器

1

等待安装系统通过cobbler方式

1.2 主机规划

服务器说明

名称规划

外网IP/eth0

内网IP/eth1

分发系统服务器

kickstart

10.0.0.199/24

172.16.1.199/24

新服务器

根具kickstart配置文件决定

根据cobbler dhcp地址确定

根具cobbler dhcp地址确定

第2章 Cobbler工具介绍

2.1 简介

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCPDNS等。

       Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

       Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack

2.2 支持的服务

    PXE服务支持

    DHCP服务管理

    DNS服务管理(可选bind,dnsmasq)

    电源管理

    Kickstart服务支持

    YUM仓库管理

    TFTP(PXE启动时需要)

    Apache(提供kickstart的安装源,并提供定制化的kickstart配置

第3章 配置

3.1 查看系统环境

3.1.1 批量执行

cat /etc/redhat-release

uname -r

uname -m

hostname

ifconfig eth1|awk -F "[ :]+"‘NR==2{print $3}‘

getenforce

/etc/init.d/iptables status

3.1.2 执行结果

[root@cobbler ~]# cat /etc/redhat-release

CentOS release 6.7 (Final)

[root@cobbler ~]# uname -r

2.6.32-573.26.1.el6.x86_64

[root@cobbler ~]# uname -m

x86_64

[root@cobbler ~]# hostname

cobbler

[root@cobbler ~]# ifconfig eth1|awk -F"[ :]+" ‘NR==2{print $3}‘

addr

[root@cobbler ~]# getenforce

Disabled

[root@cobbler ~]# /etc/init.d/iptablesstatus

iptables:未运行防火墙。

3.2 安装所需环境软件

3.2.1 批量执行

yum -y install cobbler cobbler-web dhcptftp-server pykickstart httpd xinetd

3.2.2 执行结果

[root@cobbler ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpdxinetd

已加载插件:fastestmirror, security

设置安装进程

.

.

.


已安装:

 cobbler.x86_64 0:2.6.11-1.el6        cobbler-web.noarch 0:2.6.11-1.el6   dhcp.x86_64 12:4.1.1-51.P1.el6.centos   httpd.x86_64 0:2.2.15-53.el6.centos  

 pykickstart.noarch 0:1.74.20-1.el6   tftp-server.x86_64 0:0.49-8.el6     xinetd.x86_64 2:2.3.14-40.el6          

 

作为依赖被安装:

 Django14.noarch 0:1.4.21-1.el6                    PyYAML.x86_64 0:3.10-3.1.el6                            apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1        

 createrepo.noarch 0:0.9.9-24.el6                  deltarpm.x86_640:3.5-0.5.20090913git.el6               genisoimage.x86_64 0:1.1.9-12.el6             

 httpd-tools.x86_64 0:2.2.15-53.el6.centos         libyaml.x86_64 0:0.1.3-4.el6_6                           mod_ssl.x86_641:2.2.15-53.el6.centos         

 mod_wsgi.x86_64 0:3.2-7.el6                       mtools.x86_640:4.0.12-1.el6                            portreserve.x86_64 0:0.0.4-11.el6             

 python-cheetah.x86_64 0:2.4.1-1.el6               python-deltarpm.x86_640:3.5-0.5.20090913git.el6        python-markdown.noarch 0:2.0.1-3.1.el6        

 python-netaddr.noarch 0:0.7.5-4.el6               python-pygments.noarch0:1.1.1-1.el6                    python-setuptools.noarch 0:0.6.10-3.el6       

 python-simplejson.x86_64 0:2.0.9-3.1.el6          syslinux.x86_64 0:4.04-3.el6                            syslinux-nonlinux.noarch 0:4.04-3.el6          

 

作为依赖被升级:

 dhclient.x86_64 12:4.1.1-51.P1.el6.centos                                   dhcp-common.x86_64 12:4.1.1-51.P1.el6.centos                                  

 

完毕!

3.3 启动相关服务

3.3.1 批量执行

/etc/init.d/xinetd start

/etc/init.d/httpd start

/etc/init.d/cobblerd start

3.3.2 执行结果

[root@cobbler ~]# /etc/init.d/xinetd start

正在启动 xinetd                                          [确定]

[root@cobbler ~]# /etc/init.d/httpd start

正在启动 httpd

[root@cobbler ~]# /etc/init.d/cobblerdstart

Starting cobbler daemon:                                   [确定]

第4章 检测配置

执行以下命令检查Cobbler的配置,如果看不到下面的结果,再次执行cobblerhttpd服务。(cobblercheck命令用于向用户提供检查信息,就安装可能出现的问题进行提示)

[root@cobbler ~]# cobbler check

Traceback (most recent call last):

 File "/usr/bin/cobbler", line 36, in <module>

   sys.exit(app.main())

 File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line657, in main

   rc = cli.run(sys.argv)

 File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line270, 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, inrequest

   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‘">

4.1 解决上面的报错

[root@cobbler ~]# /etc/init.d/cobblerd restart

Stopping cobbler daemon:                                  [确定]

Starting cobbler daemon:                                   [确定]

[root@cobbler ~]# cobbler check

The following are potential configurationitems that you may want to fix:

 

1 : The ‘server‘ field in/etc/cobbler/settings must be set to something other than localhost, orkickstarting features will not work. This should be a resolvable hostname or IP for the boot server asreachable 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 otherthan 127.0.0.1, and should match the IP of the boot server on the PXE network.

3 : change ‘disable‘ to ‘no‘ in/etc/xinetd.d/tftp

4 : some network boot-loaders are missingfrom /var/lib/cobbler/loaders, you may run ‘cobbler get-loaders‘ to downloadthem, or, if you only want to handle x86/x86_64 netbooting, you may ensure thatyou have installed a *recent* version of the syslinux package installed and canignore this message entirely.  Files inthis directory, should you want to support all architectures, should includepxelinux.0, menu.c32, elilo.efi, and yaboot. The ‘cobbler get-loaders‘ commandis the easiest way to resolve these requirements.

5 : change ‘disable‘ to ‘no‘ in/etc/xinetd.d/rsync

6 : file /etc/xinetd.d/rsync does not exist

7 : debmirror package is not installed, itwill be required to manage debian deployments and repositories

8 : The default password used by the sampletemplates 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 arerequired to use the (optional) power management features. install cman orfence-agents to use them

 

Restart cobblerd and then run ‘cobblersync‘ to apply changes.

4.2 配置rsync

sed -i -e ‘s/\=\ yes/\=\ no/g‘/etc/xinetd.d/rsync

service xinetd restart

4.2.1 执行结果

[root@cobbler ~]# sed -i -e ‘s/\=\ yes/\=\ no/g‘ /etc/xinetd.d/rsync

[root@cobbler ~]# service xinetd restart

停止 xinetd                                              [确定]

正在启动 xinetd                                          [确定]

4.3 根据cobbler check的结果进行修改

4.3.1 批量执行

openssl passwd -1 -salt ‘cobbler‘ ‘123456‘

sed -i.bak0 ‘101s#default_password_crypted:"$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."#default_password_crypted:$1$cobbler$sqDDOBeLKJVmxTCZr52/11 #‘ /etc/cobbler/settings

sed -i.bak1 ‘242s#manage_dhcp:0#manage_dhcp: 1#‘ /etc/cobbler/settings

sed -i.bak2 ‘272s#next_server: 127.0.0.1#next_server:172.16.1.31#‘ /etc/cobbler/settings

sed -i.bak3 ‘384s#server: 127.0.0.1#server:172.16.1.199#‘ /etc/cobbler/settings

ls -l /etc/cobbler/settings*

4.3.2 执行结果

[root@cobbler ~]# openssl passwd -1 -salt ‘cobbler‘ ‘123456‘

$1$cobbler$sqDDOBeLKJVmxTCZr52/11

[root@cobbler ~]# sed -i.bak0 ‘101s#default_password_crypted:"$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."#default_password_crypted:$1$cobbler$sqDDOBeLKJVmxTCZr52/11 #‘ /etc/cobbler/settings

[root@cobbler ~]# sed -i.bak1 ‘242s#manage_dhcp: 0#manage_dhcp:1#‘ /etc/cobbler/settings

[root@cobbler ~]# sed -i.bak2 ‘272s#next_server: 127.0.0.1#next_server:172.16.1.199#‘ /etc/cobbler/settings

[root@cobbler ~]# sed -i.bak3 ‘384s#server: 127.0.0.1#server:172.16.1.199#‘ /etc/cobbler/settings

[root@cobbler ~]# ls -l /etc/cobbler/settings*

-rw-r--r-- 1 root root 19652 6  10 01:18 /etc/cobbler/settings

-rw-r--r-- 1 root root 19651 6  10 01:13 /etc/cobbler/settings.bak0

-rw-r--r-- 1 root root 19649 6  10 01:18 /etc/cobbler/settings.bak1

-rw-r--r-- 1 root root 19649 6  10 01:18 /etc/cobbler/settings.bak2

-rw-r--r-- 1 root root 19649 6  10 01:18 /etc/cobbler/settings.bak3

4.4 编辑dnsmasq.template 模板

只更改粗体部分

[root@cobbler ~]# vim /etc/cobbler/dhcp.template

[root@cobbler ~]#

[root@cobbler ~]#

[root@cobbler ~]#

[root@cobbler ~]#

[root@cobbler ~]# cat/etc/cobbler/dhcp.template

#******************************************************************

# Cobbler managed dhcpd.conf file

#

# generated from cobbler dhcp.conf template($date)

# Do NOT make changes to /etc/dhcpd.conf. Instead,make your changes

# in /etc/cobbler/dhcp.template, as/etc/dhcpd.conf will be

# overwritten.

#

#******************************************************************

 

ddns-update-style interim;

 

allow booting;

allow bootp;

 

ignore client-updates;

set vendorclass = optionvendor-class-identifier;

 

option pxe-system-type code 93 = unsignedinteger 16;

 

subnet172.16.1.0 netmask 255.255.255.0 {      网段和子网掩码

     option routers             172.16.1.2;网关

     option domain-name-servers 172.16.1.2;DNS

     option subnet-mask         255.255.255.0;子网

     range dynamic-bootp        172.16.1.100172.16.1.150;          地址段

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                172.16.1.199;    服务器地址

    class "pxeclients" {

.

.


#end for

4.5 挂载ISO文件拷贝到本地

4.5.1 批量执行

mkdir -p /data

mount /dev/cdrom /mnt/

cp -a /mnt/* /data/

umount /mnt

ls -l /data/

4.5.2 执行结果

[root@cobbler ~]# mkdir -p /data

[root@cobbler ~]# mount /dev/cdrom /mnt/

mount: block device /dev/sr0 iswrite-protected, mounting read-only

[root@cobbler ~]# cp -a /mnt/* /data/

[root@cobbler ~]# umount /mnt

[root@cobbler ~]# ls -l /data/

总用量 300

-r--r--r-- 1 root root     14 8   52015 CentOS_BuildTag

dr-xr-xr-x 3 root root   4096 8   52015 EFI

-r--r--r-- 1 root root    212 11 27 2013 EULA

-r--r--r-- 1 root root  18009 11 27 2013 GPL

dr-xr-xr-x 3 root root   4096 8   52015 images

dr-xr-xr-x 2 root root   4096 8   52015 isolinux

dr-xr-xr-x 2 root root 237568 8   5 2015 Packages

-r--r--r-- 1 root root   1354 7  252015 RELEASE-NOTES-en-US.html

dr-xr-xr-x 2 root root   4096 8   52015 repodata

-r--r--r-- 1 root root   1706 11 27 2013 RPM-GPG-KEY-CentOS-6

-r--r--r-- 1 root root   1730 11 27 2013 RPM-GPG-KEY-CentOS-Debug-6

-r--r--r-- 1 root root   1730 11 27 2013 RPM-GPG-KEY-CentOS-Security-6

-r--r--r-- 1 root root   1734 11 27 2013 RPM-GPG-KEY-CentOS-Testing-6

-r--r--r-- 1 root root   3380 8   52015 TRANS.TBL

4.6 导入系统镜像

4.6.1 启动服务

[root@cobbler ~]# cobbler sync

task started: 2016-06-10_015953_sync

task started (id=Sync, time=Fri Jun 1001:59:53 2016)

running pre-sync triggers

cleaning trees

removing: /var/lib/tftpboot/grub/images

copying bootloaders

trying hardlink/usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0

trying hardlink /usr/share/syslinux/menu.c32-> /var/lib/tftpboot/menu.c32

trying hardlink /usr/share/syslinux/memdisk-> /var/lib/tftpboot/memdisk

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 triggercobbler.modules.sync_post_restart_services

running: dhcpd -t -q

received on stdout:

received on stderr:

running: service dhcpd restart

received on stdout: 正在启动 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 triggercobbler.modules.scm_track

running shell triggers from/var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

[root@cobbler ~]# /etc/init.d/dhc restart

dhcpd     dhcpd6     dhcrelay   dhcrelay6 

[root@cobbler ~]# /etc/init.d/dhcpd restart

关闭 dhcpd                                              [确定]

正在启动 dhcpd                                           [确定]

4.6.2 导入

cobbler import --path=/data/--name=CentOS-6.7-x86_64 --arch=x86_64

4.6.3 执行结果

[root@cobbler ~]# cobbler import --path=/data/ --name=CentOS-6.7-x86_64 --arch=x86_64

task started: 2016-06-10_020146_import

task started (id=Media import, time=Fri Jun10 02:01:46 2016)

Found a candidate signature: breed=redhat,version=rhel6

Found a matching signature: breed=redhat,version=rhel6

Adding distros from path/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64:

creating new distro: CentOS-6.7-x86_64

trying symlink:/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64 ->/var/www/cobbler/links/CentOS-6.7-x86_64

creating new profile: CentOS-6.7-x86_64

associating repos

checking for rsync repo(s)

checking for rhn repo(s)

checking for yum repo(s)

starting descent into/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64 for CentOS-6.7-x86_64

processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64

need to process repo/comps:/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64

looking for/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata/*comps*.xml

Keeping repodata as-is:/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata

*** TASK COMPLETE ***

4.6.4 说明

# --path 镜像路径

# --name 为安装源定义一个名字

# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64

# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-6.7-x86_64,如果重复,系统会提示导入失败。

4.7 查看镜像列表

镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.7-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。

[root@cobbler ~]#  cobbler distro list

  CentOS-6.7-x86_64

4.7.1 查看生成的镜像目录

cd /var/www/cobbler/ks_mirror/

ls

ls CentOS-6.7-x86_64/

4.7.2 执行结果

[root@cobbler ~]# cd /var/www/cobbler/ks_mirror/

[root@cobbler ks_mirror]# ls

CentOS-6.7-x86_64  config

[root@cobbler ks_mirror]# ls CentOS-6.7-x86_64/

CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6

EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6

EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6

GPL              repodata                  TRANS.TBL

images           RPM-GPG-KEY-CentOS-6

4.8 查看导入的帮助信息

[root@cobbler ~]# cobbler import --help

Usage: cobbler [options]

 

Options:

  -h,--help            show this help messageand exit

 --arch=ARCH           OSarchitecture being imported

 --breed=BREED         the breedbeing imported

 --os-version=OS_VERSION

                        the version being imported

 --path=PATH           local pathor rsync location

 --name=NAME           name, ex‘RHEL-5‘

 --available-as=AVAILABLE_AS

                        tree is here, don‘tmirror

 --kickstart=KICKSTART_FILE

                        assign this kickstartfile

 --rsync-flags=RSYNC_FLAGS

                        pass additional flagsto rsync

第5章 定制ks.cfg文件及调整内核参数

5.1 进入到Cobbler kickstart文件的默认存放位置

[root@cobbler ~]# cd /var/lib/cobbler/kickstarts/

5.2 上传写好的CetnOS-6.7-x86_64.cfg文件到/var/lib/cobbler/kickstart下面

[root@cobbler kickstarts]# rz -E

rz waiting to receive.

[root@cobbler kickstarts]# ls -l CentOS-6.7-x86_64.cfg

-rw-r--r-- 1 root root 1510 6  10 02:15 CentOS-6.7-x86_64.cfg

5.2.1 CetnOS-6.7-x86_64.cfg文件内容

#Kickstart Configurator by Jason Zhao

#platform=x86, AMD64, or Intel EM64T

#System language

lang en_US

#System keyboard

keyboard us

#Sytem timezone

timezone Asia/Shanghai

#Root password

rootpw --iscrypted$default_password_crypted

#rootpw --iscrypted$1$ops-node$7hqdpgEmIE7Z0RbtQkxW20

#Use text mode install

text

#Install OS instead of upgrade

install

#Use NFS installation Media

url --url=$tree

#url--url=http://172.16.1.199/CentOS-6.7-x86_64

#System bootloader configuration

bootloader --location=mbr

#Clear the Master Boot Record

zerombr

#Partition clearing information

clearpart --all --initlabel

#Disk partitioning information

part /boot --fstype ext4 --size 1024--ondisk sda

part swap --size 16384 --ondisk sda

part / --fstype ext4 --size 1 --grow--ondisk sda

#System authorization infomation

auth --useshadow  --enablemd5

#Network information

$SNIPPET(‘network_config‘)

#network --bootproto=dhcp --device=eth0--onboot=on

# Reboot after installation

reboot

#Firewall configuration

firewall --disabled

#SELinux configuration

selinux --disabled

#Do not configure XWindows

skipx

 

%pre

$SNIPPET(‘log_ks_pre‘)

$SNIPPET(‘kickstart_start‘)

$SNIPPET(‘pre_install_network_config‘)

# Enable installation monitoring

$SNIPPET(‘pre_anamon‘)

%end

 

#Package install information

%packages

@ base

@ core

@debugging

@development

sysstat

tree

telnet

dos2unix

ntp

lrzsz

nfs-utils

rpcbind

openssl-devel

zlib-devel

nmap

screen

%end

 

%post

%end

5.3 编辑profile,修改关联的ks文件,修改内核参数

cobbler profile edit--name=CentOS-6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.7-x86_64.cfg

 

[root@cobbler kickstarts]# cobbler profile edit--name=CentOS-6.7-x86_64--kickstart=/var/lib/cobbler/kickstarts/CentOS-6.7-x86_64.cfg

第6章 Cobbler Web页面配置

6.1 相同网段内,打开浏览器,输入http://172.16.1.199/cobbler_web

用户名和密码都是cobbler


6.2 方便配置

第7章 定制化安装系统

7.1 安装koan

[root@cobbler kickstarts]# cd ~

[root@cobbler ~]# yum -y install koan

已加载插件:fastestmirror, security

设置安装进程

.

.

.

已安装:

 koan.noarch 0:2.6.11-1.el6                                                                 

 

作为依赖被安装:

 cyrus-sasl-md5.x86_64 0:2.1.23-15.el6_6.2      gnutls-utils.x86_64 0:2.8.5-19.el6_7       

 libselinux-python.x86_64 0:2.0.94-7.el6        libvirt-client.x86_640:0.10.2-60.el6      

 libvirt-python.x86_64 0:0.10.2-60.el6          python-virtinst.noarch0:0.600.0-29.el6    

 yajl.x86_64 0:1.0.7-3.el6                    

 

作为依赖被升级:

 libselinux.x86_64 0:2.0.94-7.el6           libselinux-utils.x86_640:2.0.94-7.el6         

 

完毕!

7.2 查看镜像列表

[root@cobbler ~]# koan --server=172.16.1.199 --list=profiles

- looking for Cobbler athttp://172.16.1.199:80/cobbler_api

CentOS-6.7-x86_64

7.3 解析

[root@cobbler ~]# koan --replace-self --server=172.16.1.199 --profile=CentOS-6.7-x86_64

- looking for Cobbler athttp://172.16.1.199:80/cobbler_api

- reading URL:http://172.16.1.199/cblr/svc/op/ks/profile/CentOS-6.7-x86_64

install_tree:http://172.16.1.199/cblr/links/CentOS-6.7-x86_64

downloading initrd initrd.img to/boot/initrd.img_koan

url=http://172.16.1.199/cobbler/images/CentOS-6.7-x86_64/initrd.img

- reading URL:http://172.16.1.199/cobbler/images/CentOS-6.7-x86_64/initrd.img

downloading kernel vmlinuz to/boot/vmlinuz_koan

url=http://172.16.1.199/cobbler/images/CentOS-6.7-x86_64/vmlinuz

- reading URL:http://172.16.1.199/cobbler/images/CentOS-6.7-x86_64/vmlinuz

- [‘/sbin/grubby‘, ‘--add-kernel‘,‘/boot/vmlinuz_koan‘, ‘--initrd‘, ‘/boot/initrd.img_koan‘, ‘--args‘,‘"ks=http://172.16.1.199/cblr/svc/op/ks/profile/CentOS-6.7-x86_64ksdevice=link kssendmac "‘, ‘--copy-default‘, ‘--make-default‘,‘--title=kick1465496560‘]

- [‘/sbin/grubby‘, ‘--update-kernel‘,‘/boot/vmlinuz_koan‘, ‘--remove-args=root‘]

- reboot to apply changes

最后设置

cobbler system add --name=test--mac=00:50:56:26:DC:7B --ip-address=172.16.1.199 --subnet=255.255.255.0--gateway=172.16.1.2 --name-servers="172.16.1.2 8.8.8.8"--interface=eth1 --static=1 --hostname=xeon--kickstart=/var/lib/cobbler/kickstarts/CentOS-6.7-x86_64.cfg --profile=Centos-6.7-x86_64

 

[root@cobbler ~]# cobbler system add --name=test --mac=00:50:56:26:DC:7B--ip-address=172.16.1.199 --subnet=255.255.255.0 --gateway=172.16.1.2--name-servers="172.16.1.2 8.8.8.8" --interface=eth1 --static=1--hostname=xeon --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.7-x86_64.cfg--profile=Centos-6.7-x86_64

第8章 测试

8.1 报错

8.1.1 重新启动所有服务

[root@cobbler ~]# /etc/init.d/httpd restart

停止 httpd                                              [确定]

正在启动 httpd                                           [确定]

[root@cobbler ~]# /etc/init.d/cobblerd restart

Stopping cobbler daemon:                                    [确定]

Starting cobbler daemon:                                     [确定]

[root@cobbler ~]# /etc/init.d/xinetd restart

停止 xinetd                                              [确定]

正在启动 xinetd                                          [确定]  

[root@cobbler ~]# /etc/init.d/dhcpd restart

关闭 dhcpd                                               [确定]

正在启动 dhcpd                                         [确定]

8.2 安装过程截图






第9章 开机自启动

因后边会把他写入到内核里,所以,小心开启选择顺序

9.1 修改grub,更改启动项

9.1.1 备份grub配置文件

etc目录下面的grub.conf是一个链接文件,需要备份原始文件.修改链接文件无效!!!

[root@cobbler ~]# ls -l /etc/grub.conf

lrwxrwxrwx. 1 root root 22 5  22 13:44 /etc/grub.conf -> ../boot/grub/grub.conf

[root@cobbler ~]# cp -a /boot/grub/grub.conf /boot/grub/grub.conf.bak

[root@cobbler ~]# ls -l /boot/grub/grub*

-rw------- 1 root root 1463 6  10 02:22 /boot/grub/grub.conf

-rw------- 1 root root 1463 6  10 02:22 /boot/grub/grub.conf.bak

9.1.2 编辑grub配置文件

以“title”为首的项目,每一个这样的项目,就是我们安装的操作系统,如果我们想让哪个为默认启动操作系统,那么我们需要修改“default”的值,这个值按照数组方式来设置,设置的值为我们系统中实际操作系统数量-1,例如我们现在有两个操作系统,我们想设置第一个为默认操作系统,那么我们应该把这个值设置为0;如果想第二个为默认操作系统,那么应该设置这个值为1

9.1.2.1 查看grub配置文件

[root@cobbler ~]# cat /boot/grub/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grubafter making changes to this file

# NOTICE: You have a /boot partition.  Thismeans that

#         all kernel and initrd paths are relative to /boot/, eg.

#         root (hd0,0)

#         kernel /vmlinuz-version ro root=/dev/sda3

#         initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title kick1465496560

       root(hd0,0)

       kernel/vmlinuz_koan ro nomodeset rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us.UTF-8 rd_NO_MDSYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quietks=http://172.16.1.199/cblr/svc/op/ks/profile/CentOS-6.7-x86_64 ksdevice=linkkssendmac

       initrd/initrd.img_koan

title CentOS (2.6.32-573.26.1.el6.x86_64)

       root(hd0,0)

       kernel/vmlinuz-2.6.32-573.26.1.el6.x86_64 roroot=UUID=0ede13b1-3bea-4ef0-911d-f708c9f13d48 nomodeset rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us.UTF-8rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgbquiet

       initrd/initramfs-2.6.32-573.26.1.el6.x86_64.img

title CentOS 6 (2.6.32-573.el6.x86_64)

       root(hd0,0)

       kernel/vmlinuz-2.6.32-573.el6.x86_64 roroot=UUID=0ede13b1-3bea-4ef0-911d-f708c9f13d48 nomodeset rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us.UTF-8rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgbquiet

       initrd/initramfs-2.6.32-573.el6.x86_64.img

9.1.2.2 替换

sed -i.bak ‘s#default=0#default=1#g‘ /boot/grub/grub.conf

sed -n ‘10p‘ /boot/grub/grub.conf

ls -l /boot/grub/grub.conf*

 

[root@cobbler ~]# sed -i.bak ‘s#default=0#default=1#g‘ /boot/grub/grub.conf

[root@cobbler ~]# sed -n ‘10p‘ /boot/grub/grub.conf

default=1

[root@cobbler ~]# ls -l /boot/grub/grub.conf*

-rw------- 1 root root 1463 6  10 03:24 /boot/grub/grub.conf

-rw------- 1 root root 1463 6  10 02:22 /boot/grub/grub.conf.bak

9.1.3 重启测试

9.2 开机手动执行脚本(启动服务)

这样做的目的是为了避免在同一网段的机器被错误装系统!

cat >/server/scripts/cobbler_service.sh<<EOF

#!/bin/sh

/etc/init.d/httpd restart

/etc/init.d/cobblerd restart

/etc/init.d/xinetd restart

/etc/init.d/dhcpd restart

EOF

chmod +x /server/scripts/cobbler_server.sh

ls -l /server/scripts/cobbler_service.sh

9.3 执行结果

[root@cobbler ~]# cat >/server/scripts/cobbler_service.sh<<EOF

> #!/bin/sh

> /etc/init.d/httpd restart

> /etc/init.d/cobblerd restart

> /etc/init.d/xinetd restart

> /etc/init.d/dhcpd restart

> EOF

[root@cobbler ~]# chmod +x /server/scripts/cobbler_service.sh

[root@cobbler ~]# ls -l /server/scripts/cobbler_service.sh

-rwxr-xr-x 1 root root 118 6  10 03:00 /server/scripts/cobbler_service.sh

9.4 手动执行脚本

[root@cobbler ~]# /bin/sh /server/scripts/cobbler_service.sh

停止 httpd                                              [确定]

正在启动 httpd                                           [确定]

Stopping cobbler daemon:                                    [失败]

Starting cobbler daemon:                                     [确定]

停止 xinetd                                              [失败]

正在启动 xinetd                                          [确定]

正在启动 dhcpd                                         [确定]

安装结束,欢迎大家讨论!!

本文出自 “漂流的青春” 博客,请务必保留此出处http://pldqc.blog.51cto.com/4413174/1787884

Cobbler-CentOS6.7-无人值守安装

标签:cobbler   配置文件   项目规划   管理工具   管理系统   服务器   

原文地址:http://pldqc.blog.51cto.com/4413174/1787884

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!