设为首页 收藏本站
查看: 717|回复: 0

[经验分享] Cobbler自动化集群Linux系统安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-10-8 15:10:51 | 显示全部楼层 |阅读模式
Cobbler:是一个快速网络安装Linux的工具,使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。Cobbler支持命令行管理,web界面管理
主要由Repository,Distribution,Profile:各部分组成分别是
Repository:mirror url
Distribution:kernek ,initrd
Profile:distribution,kickstart file ,repositories
实验内容:
1.1安装实验所需要的程序
[root@node1 ~]# yum install cobbler  pykickstart debmirror
在安装cobbler时会自动安装httpd程序
1.2安装完成后启动
[root@node1 ~]# service httpd start   
Starting httpd:   
[
root@node1 ~]# service cobblerd start   
Starting cobbler daemon:                                       [ OK ]   
1.3检测cobbler存在哪些错误

[root@node1 ~]# cobbler check
1
2
3
4
5
6
7
8
9
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.
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.
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.



下来一个个排错
1,修改/etc/cobbler/settings文件中的server参数值为提供cobbler服务的主机相应的IP地址或主机名和next_server参数的值为PXE服务的主机相应的IP地址            
    server=172.16.18.1
    next_server=172.16.18.1
2,生成密码,替换默认密码
    [root@node1 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)”  
    Password:  
    $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/

    default_password_crypted: " $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/"
3,复制/usr/share/syslinux/*所有文件去/var/lib/cobbler/loaders/目录中
[root@node1 ~]# cp -r  /usr/share/syslinux/* /var/lib/cobbler/loaders/
4,注释/etc/debmirror.conf中的两个参数
    #@dists="sid";
    #@arches="i386";
5,安装相应的程序包
    yum install cman fence-agents
6,chkconfig rsync on
7,[root@node1 ~]# service cobblerd start
[root@node1 ~]# cobbler sync
8,cobbler check 检测是否还有错误
The following are potential configuration items that you may want to fix:
1 : 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.
Restart cobblerd and then run 'cobbler sync' to apply changes.
此错误可以忽略了,我们已经将所需要的文件都复制过去了。
此时环境就算配置好了
2.1下来需要配置pxe所需要的服务。DHCP TFTP RSYNC DNS,其中dhcp tftp rsync为必须
[root@node1 ~]# yum install dhcp
[root@node1 ~]# service dhcpd start  
Starting dhcpd:                         [ OK ]

复制/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample到/etc/dhcp/dhcpd.conf覆盖原有文件,编辑
[root@node1 ~]# vim /etc/dhcp/dhcpd.conf
option domain-name "aolens.com";
option domain-name-servers 172.16.18.1 ;
default-lease-time 10000;
max-lease-time 20000;
log-facility local7;
subnet 172.16.0.0 netmask 255.255.0.0 {
  range 172.16.18.100 172.16.18.110;
  option routers 172.16.18.1;
}
next-server 172.16.18.1;
filename="pxelinux.0";
其他的全注释掉
[root@node1 ~]# service dhcpd restart  
Shutting down dhcpd:                                      [ OK ]  
Starting dhcpd:                                                [ OK ]

2.2启动tftp服务器
[root@node1 ~]#  chkconfig tftp on
[root@node1 ~]#  service xinetd restart
3.1首先添加distro    ,这一步是定义ramdisk和内核文件。我们直接导入完整的光盘镜像。
我们先将光盘镜像装载上,挂载于/mnt下
[root@node1 ~]# mount /dev/cdrom /mnt/
对光盘镜像进行导入
cobbler import --name=centos-6.5-x86_64 --path=/mnt
导入成功后查看
[root@node1 ~]# cobbler distro list  
centos-6.5-x86_64

发现一个distro
3.2 提供一个kickstart文件
启动kickstart工具需要安装
yum  install system-config-kickstart
然后运行system-config-kickstart
wKiom1QxcSzC66dcAAKfLanV7Ik756.jpg
具体的操作过程去不做演示,将生成的kickstart文件放在/var/lib/cobbler/kickstarts/下
要确保url --url="http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/"指向正确的yum源,也就是导入的光盘文件
也可以直接复制系统中的/root/anaconda-ks.cfg 做修改使用。
下边提供一个kickstart文件供大家参考
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#platform=x86, AMD64, or Intel EM64T
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/"
# Root password
rootpw --iscrypted $1$iRHppr42$VMesh73wBqhUTjKp6OYOD.
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# SELinux configuration
selinux --disabled
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
part /boot --fstype="ext4" --size=200
part pv.008 --size=61440
logvol swap --name=swap --vgname=vg0 --size=2048
logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=10240
logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=20480
%post
sed -i '1,$s@id:[0-9]:initdefault:@id:3:initdefault:@g' /etc/inittab
[ ! -d /root/.ssh ] && mkdir /root/.ssh && chmod og=--- /root/.ssh
cat >> /root/.ssh/authorized_keys << EOF
EOF
# Enable funcd
/sbin/chkconfig funcd off
# Set the hostname
# set puppet agent
sed -i '/[main]/a server=server.magelinux.com' /etc/puppet/puppet.conf
/sbin/chkconfig puppet off
# set hosts
echo '172.16.0.1 server.magelinux.com server' >> /etc/hosts
%end
%packages
@base
@basic-desktop
@chinese-support
@client-mgmt-tools
@core
@desktop-platform
@fonts
@general-desktop
@graphical-admin-tools
@legacy-x
@network-file-system-client
@perl-runtime
@remote-desktop-clients
@x11
func
lftp
ibus-table-cangjie
ibus-table-erbi
ibus-table-wubi
puppet
%end



3.2创建profile
profile来为cobbler提供所需要安装配置,即在distro的基础上通过提供kickstart文件来生成一个特定的系统安装配置。distro的profile可以出现在PXE的引导菜单中作为安装的选择之一。
[root@node1 ~]# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.x86_64.cfg
查看profile文件是否创建成功,每一个kickstart都可以创建一个profile来安装不同配置的程序
[root@node1 ~]# cobbler profile list  
centos-6.5-x86-basic  
centos-6.5-x86_64

[root@node1 ~]# cobbler sync    同步一下
4.1创建一个新的虚拟机
将接口都调为相同的定制端口
打开新建的虚拟机,就可以发现有两个选项,其中basic就是我们提供kickstart文件的,选定,就可以安装下去了。

5.1配置cobbler_web界面配置方式
首先需要安装cobbler_web
配置认证方式;
[root@node1 ~]# vim /etc/cobbler/modules.conf
[authentication]
module = authn_pam                        #修改此一项即可
[root@node1 ~]# useradd cblradmin        #创建用户
[root@node1 ~]# passwd cblradmin         #创建密码
编辑用户配置文件,配置下边的项
[root@node1 ~]# vim /etc/cobbler/users.conf
[admins]
admin = "cblradmin"
重启cobbler和httpd服务
[root@node1 ~]# service cobblerd restart  
Stopping cobbler daemon:     [ OK ]  
Starting cobbler daemon:      [ OK ]  
[
root@node1 ~]# service httpd restart  
Stopping httpd:                   [ OK ]  
Starting httpd:                    [ OK ]

访问cobbler_web页面,并登陆




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-25678-1-1.html 上篇帖子: 运维自动化工具cobbler实现系统自动化安装 下篇帖子: 解决 yum Error: database disk image is malformed Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表