Cobbler环境搭建

Cobbler服务器系统: CentOS 6.6 64位
Cobbler版本: cobbler-2.6.11
IP地址:192.168.166.136

1、安装epel库

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

2、安装依赖包

yum  -y install cobbler tftp tftp-server xinetd  dhcp  httpd  rsync pykickstart  debmirror  python-ctypes   cman

3、配置http

sed -i ‘s/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/g‘ /etc/httpd/conf/httpd.conf
chkconfig httpd on
/etc/init.d/httpd start

4、配置tftp和rsync

sed -i ‘s/disable\t= yes/disable\t= no/g‘ /etc/cobbler/tftpd.template
sed -i ‘s/disable\t= yes/disable\t= no/g‘ /etc/xinetd.d/rsync
chkconfig xinetd on
/etc/init.d/xinetd start

5、配置cobbler相关参数

[[email protected]_166_136 ~]#sed -i ‘s/^@dists/#@dists/g;s/^@arches/#@arches/g‘ /etc/debmirror.conf
#生成root密码的密文,cobber客户端使用,该机器也必须能使用这个密码,否则执行cobbler sync/cobbler get-loaders报登录失败
[[email protected]_166_136 kickstarts]# openssl passwd -1 -salt ‘‘ ‘123456‘
$1$$RmyPVMlhpXjJj8iv4w.Ul.
[[email protected]_166_136 ~]#vi /etc/cobbler/settings
default_password_crypted: "$1$$RmyPVMlhpXjJj8iv4w.Ul."

[[email protected]_166_136 ~]#IP=$(ifconfig |grep -A 2 "eth0 " |grep ‘inet addr‘|awk ‘{print $2}‘|awk -F: ‘{print $2}‘)
[[email protected]_166_136 ~]#sed -i "s/^next_server.*$/next_server: $IP/g" /etc/cobbler/settings
[[email protected]_166_136 ~]#sed -i "s/^server.*$/server: $IP/g" /etc/cobbler/settings
[[email protected]_166_136 ~]#sed -i "s/^manage_dhcp.*$/manage_dhcp: 1/g" /etc/cobbler/settings
[[email protected]_166_136 ~]#sed -i "s/^pxe_just_once.*$/pxe_just_once: 1/g" /etc/cobbler/settings
[[email protected]_166_136 ~]#sed -i "s/^manage_rsync.*$/manage_rsync: 1/g" /etc/cobbler/settings

#查看修改的配置
[[email protected]_166_136 ~]#grep -E "^default_password_crypted|^next_server|^server|^pxe_just_once|^manage_rsync|^manage_dhcp" /etc/cobbler/settings

6、配置dhcp服务器

#修改subnet信息
[[email protected]_166_136 ~]#vi /etc/cobbler/dhcp.template
subnet 192.168.166.0 netmask 255.255.255.0 {
	#option routers            192.168.166.1;
	option domain-name-servers 192.168.166.2;
	option subnet-mask         255.255.255.0;
	range dynamic-bootp        192.168.166.10 192.168.166.60;
	default-lease-time         21600;
	max-lease-time             43200;
	next-server                $next_server;
	class "pxeclients" {
		match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
		if option pxe-system-type = 00:02 {
			filename "ia64/elilo.efi";
		} else if option pxe-system-type = 00:06 {
			filename "grub/grub-x86.efi";
		} else if option pxe-system-type = 00:07 {
			filename "grub/grub-x86_64.efi";
		} else {
			filename "pxelinux.0";
		}
	}
}

[[email protected]_166_136 ~]#echo "DHCPDARGS=eth0" >/etc/sysconfig/dhcpd 

#检查cobber配置是否有误 ------下面这个问题,已确认有该文件,不知道为什么还是提示。。我这里忽略
[[email protected]_166_136 kickstarts]# cobbler check
The following are potential configuration items that you may want to fix:

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

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.

  

chkconfig dhcpd on
chkconfig cobblerd on
cobbler get-loaders
service cobblerd start
cobbler sync
#测试dhcp服务器配置是否正确
dhcpd
service dhcpd start

设置cobbler相关服务启动脚本

vi /etc/rc.d/init.d/cobbler
#!/bin/sh
# chkconfig: - 80 90
# description:cobbler
case $1 in
start)
	/etc/init.d/httpd start
	/etc/init.d/xinetd start
	/etc/init.d/dhcpd start
	/etc/init.d/cobblerd start
	;;
stop)
	/etc/init.d/httpd stop
	/etc/init.d/xinetd stop
	/etc/init.d/dhcpd stop
	/etc/init.d/cobblerd stop
	;;
restart)
	/etc/init.d/httpd restart
	/etc/init.d/xinetd restart
	/etc/init.d/dhcpd restart
	/etc/init.d/cobblerd restart
	;;
status)
	/etc/init.d/httpd status
	/etc/init.d/xinetd status
	/etc/init.d/dhcpd status
	/etc/init.d/cobblerd status
	;;
sync)
	cobbler sync
	;;
*)
	echo "Input error,please in put ‘start|stop|restart|status|sync‘!";
	exit 2>&1 >/dev/null &
	;;
esac

chmod +x /etc/rc.d/init.d/cobbler
chkconfig cobbler on
service cobbler  restart

7、制作镜像

mkdir -p /data/iso/tmp
rz -be   #上传ios至/data/iso目录
mount -t iso9660 -o loop /data/iso/CentOS-6.6-x86_64-bin-DVD1.iso  /data/iso/tmp

#将iso导入到cobber,切记必须切换到/var/www/cobbler/ks_mirror执行,该目录开启了http访问
cd /var/www/cobbler/ks_mirror
cobbler import --path=/data/iso/tmp  --name=CentOS-6.6-x86_64  --arch=x86_64

8、设置kickstarts安装配置文件

#定制系统安装及脚本设置,重要
#1、不支持中文,切记
#2、不支持bash里面的转义字符
#3、自定义脚本,请使用http的方式执行
cat /var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.ks
# kickstart template for Fedora 8 and later.
# (includes %end blocks)
# do not use with earlier distros

#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 --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US.UTF-8
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET(‘network_config‘)
# 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
autopart

%pre
$SNIPPET(‘log_ks_pre‘)
$SNIPPET(‘kickstart_start‘)
$SNIPPET(‘pre_install_network_config‘)
# Enable installation monitoring
$SNIPPET(‘pre_anamon‘)
%end

%packages
$SNIPPET(‘func_install_if_enabled‘)
%end

%post --nochroot
$SNIPPET(‘log_ks_post_nochroot‘)
%end

%post
$SNIPPET(‘log_ks_post‘)
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET(‘post_install_kernel_options‘)
$SNIPPET(‘post_install_network_config‘)
$SNIPPET(‘func_register_if_enabled‘)
$SNIPPET(‘download_config_files‘)
$SNIPPET(‘koan_environment‘)
$SNIPPET(‘redhat_register‘)
$SNIPPET(‘cobbler_register‘)
# Enable post-install boot notification
$SNIPPET(‘post_anamon‘)
# Start final steps
$SNIPPET(‘kickstart_done‘)
# End final steps
# Custom scripts
cd /root
wget http://192.168.166.136/cobbler/ks_mirror/config/custom.sh
sh custom.sh

%end

#设置自定义脚本,用于定制 

[[email protected]_166_136 kickstarts]# cat /var/www/cobbler/ks_mirror/config/custom.sh
#!/bin/bash

date >>/tmp/date.log

cobbler常用命令

#查看当前配置文件
cobbler profile report

#修改profile,默认是/var/lib/cobbler/kickstarts/sample_end.ks 配置文件,必须
cobbler profile edit --name=CentOS-6.6-x86_64 --distro=CentOS-6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.ks

#指定安装的配置文件,需要时候,才使用
cobbler profile remove --name=CentOS-5.10-x86_64

#查看Cobbler列表
cobbler list
#查看所有参数
cobbler report
#查看配置文件相关参数
cobbler profile report
#查看distro列表
cobbler distro list

#修改cobber 客户端的默认启动项

[[email protected]_166_136 kickstarts]# cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io
TIMEOUT 60
TOTALTIMEOUT 6000
#ONTIMEOUT local
ONTIMEOUT CentOS-6.6-x86_64

LABEL local
        MENU LABEL (local)
        LOCALBOOT -1

LABEL CentOS-6.6-x86_64
        kernel /images/CentOS-6.6-x86_64/vmlinuz
        MENU LABEL CentOS-6.6-x86_64
        MENU DEFAULT
	append initrd=/images/CentOS-6.6-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://192.168.166.136/cblr/svc/op/ks/profile/CentOS-6.6-x86_64
        ipappend 2

MENU end

到这里,新建的虚拟机,已经可以自动安装操作系统了。

9、重新安装系统

在需要重装系统的服务器上安装koan
1.安装epel库
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2.安装koan
yum -y install koan.noarch
3.查看Cobbler服务器系统镜像列表
koan --list=profiles  --server=192.168.166.136
4.查看Cobbler服务器系统镜像列表
koan --replace-self --server=192.168.166.136 --profile=CentOS-6.6-x86_64
5.重新启动系统进行自动安装
reboot

Kickstart: /var/lib/cobbler/kickstarts/
cobbler相关配置文件: /etc/cobbler
cobbler数据存储目录: /var/www/cobbler
dhcp配置文件: /etc/dhcpd.conf
dhcp租期缓存文件: /var/lib/dhcpd/dhcpd.leases
pxe配置文件: /tftpboot/pxelinux.cfg/default
cobbler日志:
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志

时间: 2024-10-12 13:11:16

Cobbler环境搭建的相关文章

一、环境搭建

1 更新到最新版本的pip(这是安装python扩展包的一个插件)命令如下: python -m pip install --upgrade pip 2 使用pip安装virtualenv,命令 pip install virtualenv  如果要指定版本号,pip install virtualenv==15.0.1(安装虚拟环境) 3 创建django虚拟环境,命令 virtualenv django_basic_venv 4 使用虚拟环境 需要进入到安装目录的Scripts文件夹下,运行

Ionic2环境搭建及文件目录介绍

[注]引用自:http://blog.csdn.net/jasonzds/article/details/53821184 1环境搭建 一年前研究混合框架,初步确定了四种方案给公司选择,ionic,hbuilder,wex5,react-native这四个框架各有优缺点,ionic和react-native是国外框架,相对好一点,文档更新很快,就不一一说了,大概的思路都是一样的,js逻辑实现,同时调用原生功能,h5,css3 UI实现,其实他们都有自己的ui框架,当时选择了国内的hbuiler,

Selenium+Java+Eclipse 自动化测试环境搭建

一.下载Java windows java下载链接 https://www.java.com/zh_CN/download/win10.jsp 二.安装Java 安装好后检查一下需不需要配置环境变量,现在java 8已经不用配置环境变量了,直接在命令行输入:java -version 三.下载和安装Eclipse windows Eclipse下载链接 https://www.eclipse.org/downloads/ 你也可以下载绿色版 四.下载selenium,然后解压 selenium

Qt在Mac OS X下的编程环境搭建(配置Qt库和编译器,有图,很清楚)

尊重作者,支持原创,如需转载,请附上原地址:http://blog.csdn.net/libaineu2004/article/details/46234079 在Mac OS X下使用Qt开发,需要配置Qt库和编译器.编译器只能使用苹果公司自主研发的Clang.1.分别下载并安装XCode和Command Line Tools(必须安装),安装完毕后,Clang就有了. https://developer.apple.com/downloads/ 2.下载Qt并默认安装 http://down

基于 Eclipse 的 MapReduce 开发环境搭建

文 / vincentzh 原文连接:http://www.cnblogs.com/vincentzh/p/6055850.html 上周末本来要写这篇的,结果没想到上周末自己环境都没有搭起来,运行起来有问题的呢,拖到周一才将问题解决掉.刚好这周也将之前看的内容复习了下,边复习边码代码理解,印象倒是很深刻,对看过的东西理解也更深入了. 目录 1.概述 2.环境准备 3.插件配置 4.配置文件系统连接 5.测试连接 6.代码编写与执行 7.问题梳理 7.1 console 无日志输出问题 7.2

ICE分布式文件管理系统——ICE环境搭建(其二)

上一博文,我们讲述了ICE这个中间件的基本认识. 接下来我们讲述开发环境搭建. 其过程主要分为三步: 安装GCC-4.4.6.安装ICE-3.4.2.安装QT-4.7.3. (本文是基于LINUX下的ICE-3.4.2的安装,如果已安装了GCC(版本高于GCC-4.4.6亦可),请直接安装ICE) 一.安装GCC: (gcc各版本浏览地址:http://ftp.gnu.org/gnu/gcc/) 一般来说基于linux的操作系统都是默认安装了GCC的.假如说你的电脑没有的话 请百度一哈,可以解决

[Step-By-Step Angular2](1)Hello World与自动化环境搭建

随着rc(release candidate,候选版本)版本的推出,万众瞩目的angular2终于离正式发布不远啦!五月初举办的ng-conf大会已经过去了整整一个月,大多数api都如愿保持在了相对稳定的状态——当然也有router这样的例外,在rc阶段还在大面积返工,让人颇为不解——不过总得说来,现在学习angular2不失为一个恰当的时机. Google为angular2准备了完善的文档和教程,按理说,官网(https://angular.io)自然是学习新框架的最好教材.略显遗憾的是,在B

Linux交叉开发环境搭建 —— 效率之源

楼主今天终于把所有Linux开发环境需要的软件下载完毕了.虽然以前也是搭建过的,时间久了又折腾了一晚上. 交叉环境: Windows.Linux文件共享 SecureCRT 连接虚拟机终端 工具: VirtualBox ubuntu-16.04-desktop-amd64.iso(ubuntu官网下载) SecureCRT Source Insight 虚拟机搭建: 检查bios虚拟技术功能开启 新建虚拟机,选择创建虚拟硬盘,其余均默认 点击新建虚拟机设置->存储->选中没有光盘->点击

Intellij IDEA 14.1.4 Scala开发环境搭建

主要内容 Intellij IDEA开发环境简介 Intellij IDEA Scala开发环境搭建 Intellij IDEA常见问题及解决方案 Intellij IDEA常用快捷键 1. Intellij IDEA开发环境简介 具体介绍请参见:http://baike.baidu.com/link?url=SBY93H3SPkmcmIOmZ8H60O1k4iVLgOmdqoKdGp9xHtU-Pbdsq2cpn75ZPZPWAJxeUlwr0ravraQzOckh777beq Intelli