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

[经验分享] cobbler 无人值守安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-2-20 08:43:44 | 显示全部楼层 |阅读模式
1.阿里云源
1
2
3
[iyunv@linux-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[iyunv@linux-node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[iyunv@linux-node1 ~]# yum clean all



2.操作系统(centos7.3 会有问题选择centos7.2或者7.1)
1
2
3
[iyunv@linux-node1 ~]# cat  /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[iyunv@linux-node1 ~]#



3.安装需要的软件
1
[iyunv@linux-node1 ~]#  yum  install   -y httpd   dhcp   tftp   cobbler



4.启动httpd和cobblerd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@linux-node1 ~]# systemctl start  httpd
[iyunv@linux-node1 ~]# systemctl enable  httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[iyunv@linux-node1 ~]# systemctl start   cobblerd
[iyunv@linux-node1 ~]# systemctl enable   cobblerd
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
[iyunv@linux-node1 ~]#

检查是否启动
[iyunv@linux-node1 ~]# netstat  -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      922/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1580/master         
tcp        0      0 127.0.0.1:25151         0.0.0.0:*               LISTEN      2820/python2        
tcp6       0      0 :::80                   :::*                    LISTEN      2792/httpd         
tcp6       0      0 :::22                   :::*                    LISTEN      922/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1580/master         
[iyunv@linux-node1 ~]#



5.执行cobbler check检查需要配置的cobbler模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@linux-node1 ~]# cobbler check
The following are potential configuration items that you may want to fix:

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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : 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.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : 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
9 : 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.
[iyunv@linux-node1 ~]#



5.1 修改1和2
1
2
3
4
[iyunv@linux-node1 ~]# grep "192.168.56.13" /etc/cobbler/settings
next_server: 192.168.56.13
server: 192.168.56.13
[iyunv@linux-node1 ~]#



5.2修改3
1
2
3
[iyunv@linux-node1 ~]# grep "disable"  /etc/xinetd.d/tftp
    disable         = no
[iyunv@linux-node1 ~]#



5.3修改4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@linux-node1 ~]# cobbler get-loaders
task started: 2017-02-20_033851_get_loaders
task started (id=Download Bootloader Content, time=Mon Feb 20 03:38:51 2017)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***



5.4修改5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@linux-node1 ~]# systemctl start  rsyncd
[iyunv@linux-node1 ~]# systemctl enable  rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[iyunv@linux-node1 ~]# netstat   -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      2874/rsync         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      922/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1580/master         
tcp        0      0 127.0.0.1:25151         0.0.0.0:*               LISTEN      2820/python2        
tcp6       0      0 :::873                  :::*                    LISTEN      2874/rsync         
tcp6       0      0 :::80                   :::*                    LISTEN      2792/httpd         
tcp6       0      0 :::22                   :::*                    LISTEN      922/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1580/master         
[iyunv@linux-node1 ~]#



5.5 修改7 ,6不用管
1
[iyunv@linux-node1 ~]# yum  -y install  install pykickstart



5.6 修改客户机的密码
1
2
3
4
5
6
[iyunv@linux-node1 ~]# openssl passwd -1 -salt '123123' '123123'
$1$123123$MAV.kVI/b3swmFLErPD2b0
[iyunv@linux-node1 ~]# vim  /etc/cobbler/settings
[iyunv@linux-node1 ~]# grep "default_password_crypted"  /etc/cobbler/settings
default_password_crypted: "$1$123123$MAV.kVI/b3swmFLErPD2b0"
[iyunv@linux-node1 ~]#



5.7 修改9
[iyunv@linux-node1 ~]# yum  -y install  cman  fence-agents
5.8校验
1
2
3
4
5
6
7
8
9
出现如下状况就可以了
[iyunv@linux-node1 ~]# systemctl restart cobblerd
[iyunv@linux-node1 ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories

Restart cobblerd and then run 'cobbler sync' to apply changes.
[iyunv@linux-node1 ~]#



6 让cobbler管理dhcp
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
[iyunv@linux-node1 ~]# grep "manage_dhcp" /etc/cobbler/settings
manage_dhcp: 1
# if using cobbler with manage_dhcp, put the IP address
# Note that if manage_dhcp and manage_dns are disabled, the respective
[iyunv@linux-node1 ~]#
[iyunv@linux-node1 ~]# vim  /etc/cobbler/dhcp.template

subnet 192.168.56.0 netmask 255.255.255.0 {
     option routers             192.168.56.2;
     option domain-name-servers 192.168.56.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.56.100 192.168.56.254;
     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";
          }
     }

}

[iyunv@linux-node1 ~]# systemctl restart  cobblerd



7.让配置文件生效
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
[iyunv@linux-node1 ~]# cobbler sync
task started: 2017-02-20_041326_sync
task started (id=Sync, time=Mon Feb 20 04:13:26 2017)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
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 trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart  dhcpd.service

running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
[iyunv@linux-node1 ~]#



8.上传镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[iyunv@linux-node1 opt]# ll
total 4228096
-rw-r--r-- 1 root root 4329570304 Feb 20 04:20 CentOS-7-x86_64-DVD-1511.iso
[iyunv@linux-node1 opt]# mount -o  loop   /opt/CentOS-7-x86_64-DVD-1511.iso   /mnt
mount: /dev/loop0 is write-protected, mounting read-only
[iyunv@linux-node1 opt]#
导入镜像
[iyunv@linux-node1 opt]# cobbler  import --path=/mnt --name=CentOS-7.2-x86_64   --arch=x86_64
task started: 2017-02-20_042242_import
task started (id=Media import, time=Mon Feb 20 04:22:42 2017)
。。。。。 此处比较慢

镜像导入这一步其实是,复制镜像的过程
[iyunv@linux-node1 mnt]# cd  /var/www/cobbler/ks_mirror
[iyunv@linux-node1 ks_mirror]# ls
CentOS-7.2-x86_64  config
[iyunv@linux-node1 ks_mirror]#



9检查校验

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@linux-node1 ks_mirror]# cobbler  list
distros:
   CentOS-7.2-x86_64

profiles:
   CentOS-7.2-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
[iyunv@linux-node1 ks_mirror]#



10上传配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[iyunv@linux-node1 kickstarts]# ll
total 56
-rw-r--r-- 1 root root 1355 Feb 18 15:39 CentOS-7-x86_64.cfg #这个配置文件
-rw-r--r-- 1 root root  115 Nov 17 03:09 default.ks
-rw-r--r-- 1 root root   22 Nov 17 03:09 esxi4-ks.cfg
-rw-r--r-- 1 root root   22 Nov 17 03:09 esxi5-ks.cfg
drwxr-xr-x 2 root root   54 Feb 20 03:29 install_profiles
-rw-r--r-- 1 root root 1424 Nov 17 03:09 legacy.ks
-rw-r--r-- 1 root root  292 Nov 17 03:09 pxerescue.ks
-rw-r--r-- 1 root root 2916 Nov 17 03:09 sample_autoyast.xml
-rw-r--r-- 1 root root 1825 Nov 17 03:09 sample_end.ks
-rw-r--r-- 1 root root    0 Nov 17 03:09 sample_esx4.ks
-rw-r--r-- 1 root root  324 Nov 17 03:09 sample_esxi4.ks
-rw-r--r-- 1 root root  386 Nov 17 03:09 sample_esxi5.ks
-rw-r--r-- 1 root root 1784 Nov 17 03:09 sample.ks
-rw-r--r-- 1 root root 3419 Nov 17 03:09 sample_old.seed
-rw-r--r-- 1 root root 5879 Nov 17 03:09 sample.seed
[iyunv@linux-node1 kickstarts]# pwd
/var/lib/cobbler/kickstarts #目录
[iyunv@linux-node1 kickstarts]#



11.查看profile
1
2
3
[iyunv@linux-node1 kickstarts]# cobbler  profile  list
   CentOS-7.2-x86_64
[iyunv@linux-node1 kickstarts]#



12. 查看参数
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
[iyunv@linux-node1 kickstarts]# cobbler  profile report
Name                           : CentOS-7.2-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7.2-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : kvm

[iyunv@linux-node1 kickstarts]#



13.修改内核参数
1
2
3
4
[iyunv@linux-node1 kickstarts]# cobbler profile edit --name=CentOS-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
[iyunv@linux-node1 kickstarts]# cobbler profile edit --name=CentOS-7.2-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[iyunv@linux-node1 kickstarts]# cobbler  profile report
Name                           : CentOS-7.2-x86_64



1
2
3
4
5
6
7
8
9
10
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7.2-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :



1
2
3
Virt RAM (MB)                  : 512
Virt Type                      : kvm
[iyunv@linux-node1 kickstarts]#



14 启动xinetd
1
2
3
[iyunv@linux-node1 kickstarts]# yum  -y install  xinetd
[iyunv@linux-node1 kickstarts]# systemctl  start xinetd
[iyunv@linux-node1 kickstarts]# systemctl  enable  xinetd



15.配置文件接着生成
1
[iyunv@linux-node1 kickstarts]# cobbler sync



16.新建一台虚拟机(非克隆机) 关掉本地的dhcp服务
可以看出自动安装了
QQ截图20170220084056.png QQ截图20170220084103.png
QQ截图20170220084109.png

完毕安装
17.cobbler的web界面管理

1
2
3
yum  -y  install  cobbler-web
htdigest /etc/cobbler/users.digest "Cobbler" cobbler   #让输入密码 给cobbler密码
systemctl  restart  httpd



QQ截图20170220084115.png
QQ截图20170220084122.png
QQ截图20170220084126.png
18.对特定服务器的mac地址分配特定的IP

QQ截图20170220084132.png
1
2
3
[iyunv@linux-node1 kickstarts]# cobbler system add --name=linux-node2 --mac=00:50:56:39:A9:37 --profile=CentOS-7.2-x86_64 --ip-address=192.168.56.112 --subnet=255.255.255.0 --gateway=192.168.56.2 --interface=eth0 --static=1 --hostname=linux-node2.com --name-servers="192.168.56.2" --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
[iyunv@linux-node1 kickstarts]# cobbler system  list
   linux-node2



再次启动刚所对应mac的服务器

QQ截图20170220084137.png


运维网声明 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.yunweiku.com/thread-344480-1-1.html 上篇帖子: tcpdump抓取oracle报文以及使用Wireshark分析 下篇帖子: 使用samba建立共享存储示例
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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