Cobbler自动部署主机系统-扩展

本文介绍如何使用Cobbler进行自动化Linux系统安装与配置,包括系统配置定义、Kickstart文件生成及客户端重装流程。
  1. 指定服务器的装机配置

  2. 指定服务器就是绑定它的mac地址,并设置好ipdnshostname 定义系统

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
64
65
66
67
68
69
70
71
[root@master ~] # cobbler system add --name=Test_Mail_1 --hostname=Test_Mail_o --mac=00:19:B9:E5:34:FE --interface=eth0 --ip-address=192.168.10.222 --subnet=255.255.255.0 --gateway=192.168.10.2 --static=1 --profile=centos6.5-x86_64
[root@master ~] # cobbler system list   #查看列表
    Test_Mail_1
[root@master ~] # cobbler system report Test_Mail_1   # 查看详情
Name                           : Test_Mail_1
TFTP Boot Files                : {}
Comment                        : 
Enable gPXE?                   : 0
Fetchable Files                : {}
Gateway                        : 192.168.10.2
Hostname                       : Test_Mail_o
Image                          : 
IPv6 Autoconfiguration         : False
IPv6 Default Device            : 
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : <<inherit>>
Kickstart Metadata             : {}
LDAP Enabled                   : False
LDAP Management Type           : authconfig
Management Classes             : <<inherit>>
Management Parameters          : <<inherit>>
Monit Enabled                  : False
Name Servers                   : []
Name Servers Search Path       : []
Netboot Enabled                : True
Owners                         : [ 'admin' ]
Power Management Address       : 
Power Management ID            : 
Power Management Password      : 
Power Management Type          : ipmitool
Power Management Username      : 
Profile                        : centos6.5-x86_64
Proxy                          : <<inherit>>
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos Enabled                  : False
Server Override                : <<inherit>>
Status                         : production
Template Files                 : {}
Virt Auto Boot                 : <<inherit>>
Virt CPUs                      : <<inherit>>
Virt Disk Driver Type          : <<inherit>>
Virt File Size(GB)             : <<inherit>>
Virt Path                      : <<inherit>>
Virt PXE Boot                  : 0
Virt RAM (MB)                  : <<inherit>>
Virt Type                      : <<inherit>>
Interface =====                : eth0
Bonding Opts                   : 
Bridge Opts                    : 
CNAMES                         : []
DHCP Tag                       : 
DNS Name                       : 
Per-Interface Gateway          : 
Master Interface               : 
Interface Type                 : 
IP Address                     : 192.168.10.222
IPv6 Address                   : 
IPv6 Default Gateway           : 
IPv6 MTU                       : 
IPv6 Prefix                    : 
IPv6 Secondaries               : []
IPv6 Static Routes             : []
MAC Address                    : 00:19:B9:E5:34:FE
Management Interface           : False
MTU                            : 
Subnet Mask                    : 255.255.255.0
Static                         : True
Static Routes                  : []
Virt Bridge                    :

命令列表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@master ~] # cobbler system --help
usage
=====
cobbler system add
cobbler system copy
cobbler system dumpvars
cobbler system edit
cobbler system  find
cobbler system getks
cobbler system list
cobbler system poweroff
cobbler system poweron
cobbler system powerstatus
cobbler system reboot
cobbler system remove
cobbler system rename
cobbler system report

2.Cobbler Web管理

Cobbler web界面是一个很好的前端,非常容易管理Cobbler

可以添加和删除 system distro profile 

可以查看、编辑distros, profiles, subprofiles, systems, repos  kickstart文件

1
[root@master ~] # yum install cobbler-web -y

2.1.设置用户名密码

为已存在的用户cobbler重置密码

1
2
3
4
[root@master ~] # htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password  for  user cobbler  in  realm Cobbler
New password: 
Re- type  new password:

2.2.添加新用户

1
2
3
4
[root@master ~] # htdigest /etc/cobbler/users.digest "Cobbler" Test_user1
Adding user Test_user1  in  realm Cobbler
New password: 
Re- type  new password:

重启cobbler、http

2.3 访问,登录

http://192.168.10.128/cobbler_web/do_login

wKioL1QUbNnDJlwHAACYtxp3o8o145.jpg

3. 用system-config-kickstart工具生成Kickstart文件

1
2
yum  install  system-config-kickstart -y
终端执行 system-config-kickstart

wKioL1QUcVfACs_hAALwySn_Hog276.jpg

wKiom1QUcUSR2ym9AAHZMT3_G-c521.jpg

wKioL1QUcVfA3qT7AAH2c9mT1zA259.jpg

wKioL1QUcVfhyWODAAH-Nko8hmA509.jpg

wKiom1QUcUWz2ln5AAFC2xB7wKE143.jpg

wKioL1QUcViR15SBAAG9-Kd6SLQ938.jpg

wKiom1QUcUaDTGonAAGQHkRBYos933.jpg

wKioL1QUcViDf1YFAAEjReasZBY124.jpg

wKiom1QUcUbATIvwAALDt1eGqMY857.jpg


wKiom1QUcX-ACJnkAAHpAxKuIUY852.jpg

wKioL1QUccKRAZKfAACtLUUm98s622.jpg

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
[root@master 桌面] # cat Test.cfg 
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url= "http://192.168.10.128/cobbler/ks_mirror/centos6.5-x86_64"
# Root password
rootpw --iscrypted $1$4pvQUK /B $IBC/.aDmomR /gOQdgFy2V/
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
 
# System timezone
timezone  Asia /Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all  
# Disk partitioning information
part / --fstype= "ext4"  --size=200
part  /opt  --fstype= "ext4"  --size=10240
part  /MyData  --fstype= "ext4"  --size=1024
 
%packages
@chinese-support
@graphics
-ibus-table-cangjie
-ibus-table-erbi
-ibus-table-wubi
 
%end

4.使用Koan重装系统

koancobbler的一个辅助工具,koankickstart-over-a-network的缩写安装在客户端的使用,koan配合cobbler实现快速重装linux

koan的相关脚本在此目录内/usr/lib/python2.4/site-packages/koan/

4.1在客户端安装koan

1
[root@bogon ~] # yum install koan -y

4.2列出远程cobbler上的系统版本对象

1
2
3
4
[root@bogon ~] # koan --server=192.168.10.128 --list=profiles
- looking  for  Cobbler at http: //192 .168.10.128:80 /cobbler_api
centos6.2-x86_64
centos6.5-x86_64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
4.3 更多关于远程Cobbler对象信息
[root@bogon ~] # koan --server=192.168.10.128 --display --profile=centos6.5-x86_64
- looking  for  Cobbler at http: //192 .168.10.128:80 /cobbler_api
- reading URL: http: //192 .168.10.128 /cblr/svc/op/ks/profile/centos6 .5-x86_64
install_tree: http: //192 .168.10.128 /cblr/links/centos6 .5-x86_64
                 name  : centos6.5-x86_64
               distro  : centos6.5-x86_64
            kickstart  : http: //192 .168.10.128 /cblr/svc/op/ks/profile/centos6 .5-x86_64
              ks_meta  : tree=http: // @@http_server@@ /cblr/links/centos6 .5-x86_64 
         install_tree  : http: //192 .168.10.128 /cblr/links/centos6 .5-x86_64
               kernel  :  /var/www/cobbler/ks_mirror/centos6 .5-x86_64 /images/pxeboot/vmlinuz
               initrd  :  /var/www/cobbler/ks_mirror/centos6 .5-x86_64 /images/pxeboot/initrd .img
       kernel_options  : ks=http: //192 .168.10.128 /cblr/svc/op/ks/profile/centos6 .5-x86_64 ksdevice=link kssendmac lang= text 
                repos  : 
             virt_ram  : 512
     virt_disk_driver  : raw
            virt_type  : kvm
            virt_path  : 
       virt_auto_boot  : 1

4.4重新安装客户端系统   # 把原本6.5的系统换6.2

1
2
[root@bogon ~] # koan -r --server=192.168.10.128 --profile=centos6.2-x86_64
[root@bogon ~] #reboot

reboot 后 ;就会自动重装;

安装指定客户机系统
1
2
koan
-r  --server=172.17.10.14  --system=Test_Mail_1

wKioL1QUeVzh1w_7AABrHxB5-aE578.jpg

成功


本文转自 西索oO 51CTO博客,原文链接:http://blog.51cto.com/lansgg/1553153


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值