运维自动化之Cobbler安装配置

Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。

Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。

和Kickstart不同的是,使用cobbler不会因为在局域网中启动了dhcp而导致有些机器因为默认从pxe启动在重启服务器后加载tftp内容导致启动终止。

cobbler的安装部署配置

环境准备:

1、安装epel

rpm -Uvh ‘http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm’

2、安装dhcp服务

yum -y install dhcp

3、其他服务的安装

额外需要的服务还有tftp,rsync,xinetd,httpd。所以如果安装系统的时候如果这几个包没装上,请手动安装。

4、关闭selinux

sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config

关闭后最好重启一下,让selinux的设置生效

cobbler安装配置

1、cobbler安装

yum -y install cobbler

2、cobbler的配置

启动cobbler

# /etc/init.d/cobblerd start

启动httpd服务

# /etc/init.d/httpd start

检查配置,香港服务器,执行

cobbler check

检查后会出现类似于这样的日志

主要的修改:

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之类的系统,此提示可以忽略,免备案空间,如果需要安装,下载地址为:?query=debmirrorCentOS 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的使用

1、导入系统镜像

cobbler import –path=/mnt –name=rhel6.1_x86_64

cobbler会将镜像中的拷贝到本地一份,香港虚拟主机,放在/var/www/cobbler/ks_mirrors下的rhel6.1_x86_64目录下。同时会创建一个名字为rhel6.1_x86_64的一个发布版本,以及一个名字为rhel6.1_x86_64的profile文件,次路径可以作为今后的yum源使用

2、配置dhcp

首先修改cobbler配置,让cobbler来管理dhcp服务,编辑文件/etc/cobbler/settings

manage_dhcp: 1

接下来修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板

对于此文件,本例中只需要修改如下部分

subnet 192.168.10.0 netmask 255.255.255.0 {

option routers 192.168.10.1;

option domain-name-servers 8.8.8.8;

option subnet-mask 255.255.255.0;

range dynamic-bootp 192.168.10.100 192.168.10.254;

filename “/pxelinux.0”;

default-lease-time 21600;

max-lease-time 43200;

next-server $next_server;

}

其余部分维持默认值即可。

到目前为止,全部的准备工作已经就算全部完成,接下来要做的就是启动服务了。在之前的调试过程中,很多服务已经启动过了,这里只需要启动xinetd服务即可:

/etc/init.d/xinetd start

同步cobbler配置

执行

cobbler sync

cobbler会自动进行初始化工作,移除已经存在的启动项,然后根据模板拷贝loader文件。之后再生成pxe的配置文件,生成dhcp的配置文件,最后再重启dhcp服务。

3、设置profile

profile可以理解为按角色进行分类。

cobbler profile add –name=webserver –distro= rhel6.1_x86_64 kickstart=/var/lib/cobbler/kickstarts/webserver.ks

cobbler的ks 文件默认都放在/var/lib/cobbler/kickstarts/下面 可以根据不同的需求定制ks文件

ks文件实例

#platform=x86, AMD64, or Intel EM64T

# System authorization information

auth –useshadow –enablemd5

# System bootloader configuration

bootloader –location=mbr

# Partition clearing information

clearpart –all –initlabel

# Use text mode install

text

# Firewall configuration

firewall –enabled

# Run the Setup Agent on first boot

firstboot –disable

# System keyboard

keyboard us

# System language

lang en_US

# Use network installation

url –url=$tree

# Reboot after installation

reboot

#Root password

rootpw –iscrypted $default_password_crypted

# SELinux configuration

selinux –disabled

# Do not configure the X Window System

skipx

# System timezone

timezone Asia/Shanghai

# Install OS instead of upgrade

install

# Clear the Master Boot Record

zerombr

# Allow anaconda to partition the system as needed

clearpart –all –initlabel

part /boot –fstype=ext4 –size=256

part swap –size=1024

part / –fstype=ext4 –size=10240

part /data –fstype=ext4 –grow –size=200

%packages

@base

@core

%end

%post

mkdir /data/sh

mkdir /data/applogs

mkdir /data/appbak

与kickstart的ks文件不太一致,可以根据不同的业务需求编写不同的ks文件,以便快速的部署应用到服务器

到此就可以安装系统了

与kickstart不同的是可以选择所需的操作系统安装可以多制定一些profile

本文出自 “向梦想奔跑” 博客,请务必保留此出处

相信梦想是价值的源泉,相信眼光决定未来的一切,

运维自动化之Cobbler安装配置

相关文章:

你感兴趣的文章:

标签云: