使用cobbler 安装工具批量安装服务器

服务器 0

Cobbler官网

===================================================================

  • http://cobbler.github.io/

cobbler集成的服务

======================================================================

  • PXE服务支持

  • DHCP服务管理

  • DNS服务管理(可选bind,dnsmasq)

  • 电源管理

  • Kickstart服务支持

  • YUM仓库管理

  • TFTP(PXE启动时需要)

  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

cobbler配置文件详解

=======================================================================

cobbler配置文件目录在/etc/cobbler

| 配置文件 | 作用 |

| — | — |

| /etc/cobbler/settings | cobbler 主配置文件 |

| /etc/cobbler/iso/ | iso模板配置文件 |

| /etc/cobbler/pxe | pxe模板配置文件 |

| /etc/cobbler/power | 电源配置文件 |

| /etc/cobbler/user.conf | web服务授权配置文件 |

| /etc/cobbler/users.digest | web访问的用户名密码配置文件 |

| /etc/cobbler/dhcp.template | dhcp服务器的的配置模板 |

| /etc/cobbler/dnsmasq.template | dns服务器的配置模板 |

| /etc/cobbler/tftpd.template | tftp服务的配置模板 |

| /etc/cobbler/modules.conf | 模块的配置文件 |

cobbler数据目录

=====================================================================

| | 作用 |

| :-: | :-: |

| /var/lib/cobbler/config/ | 用于存放distros,system,profiles等信息配置文件 |

| /var/lib/cobbler/triggers/ | 用于存放用户定义的cobbler命令 |

| /var/lib/cobbler/kickstart/ | 默认存放kickstart文件 |

| /var/lib/cobbler/loaders/ | 存放各种引导程序以及镜像目录 |

| /var/www/cobbler/ks_mirror/ | 导入的发行版系统的所有数据 |

| /var/www/cobbler/images/ | 导入发行版的kernel和initrd镜像用于远程网络启动 |

| /var/www/cobbler/repo_mirror/ | yum仓库存储目录 |

cobbler日志文件

=====================================================================

| 日志文件路径 | 说明 |

| :-: | :-: |

| /var/log/cobbler/installing | 客户端安装日志 |

| /var/log/cobbler/cobbler.log | cobbler日志 |

  • cobbler命令详解

cobbler check //核对当前设置是否有问题

cobbler list //列出所有的cobbler元素

cobbler report //列出元素的详细信息

cobbler sync //同步配置到数据目录,更改配置最好都要执行下

cobbler reposync //同步yum仓库

cobbler distro //查看导入的发行版系统信息

cobbler system //查看添加的系统信息

cobbler profile //查看配置信息

cobbler服务端部署

======================================================================

  • 配置yum源(网络源)

[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 1572 100 1572 0 0 2687 0 --:–:-- --:–:-- --:–:-- 2691

[root@localhost ~]# ls /etc/yum.repos.d/

CentOS7-Base-163.repo redhat.repo xx.repo

[root@localhost ~]# sed -i ‘s/$releasever/7/g’ /etc/yum.repos.d/CentOS7-Base

[root@localhost ~]# sed -i ‘s/^enabled=.*/enabled=1/g’ /etc/yum.repos.d/CentOS7-Base-163.repo

  • 安装epel-release源

[root@localhost ~]# yum -y install epel-release

已加载插件:product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

base | 3.6 kB 00:00

centosplus | 3.4 kB 00:00

extras | 3.4 kB 00:00

……

安装过程省略

  • 安装cobbler以及相关的软件

[root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart

已加载插件:product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

安装过程省略

……

  • 启动服务并设置开机自启

[root@localhost ~]# systemctl start httpd

[root@localhost ~]# systemctl start cobblerd

[root@localhost ~]# systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@localhost ~]# systemctl enable cobblerd

Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

  • 修改server的ip、tfftp地址为本机ip

[root@localhost ~]# vim /etc/cobbler/settings

[root@localhost ~]#

[root@localhost ~]# sed -i ‘s/^server: 127.0.0.1/server: 192.168.170.14/’ /etc/cobbler/settings

[root@localhost ~]# sed -i ‘s/^next_server: 127.0.0.1/next_server: 192.168.170.14/’ /etc/cobbler/settings

  • 开启tftp

[root@localhost ~]# sed -i ‘/disable/s/yes/no/g’ /etc/xinetd.d/tftp

[root@localhost ~]#

  • 下载缺失文件

[root@localhost ~]# cobbler sync

task started: 2019-08-29_172318_sync

task started (id=Sync, time=Thu Aug 29 17:23:18 2019)

running pre-sync triggers

cleaning trees

removing: /var/www/cobbler/images/rhel-7-x86_64

removing: /var/lib/tftpboot/pxelinux.cfg/default

removing: /var/lib/tftpboot/grub/images

removing: /var/lib/tftpboot/grub/grub-x86.efi

removing: /var/lib/tftpboot/grub/grub-x86_64.efi

removing: /var/lib/tftpboot/grub/efidefault

removing: /var/lib/tftpboot/images/rhel-7-x86_64

removing: /var/lib/tftpboot/s390x/profile_list

copying bootloaders

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 files for distro: rhel-7-x86_64

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-7-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-7-x86_64/initrd.img

copying images

generating PXE configuration files

generating PXE menu structure

copying files for distro: rhel-7-x86_64

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-7-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-7-x86_64/initrd.img

Writing template files for rhel-7-x86_64

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

rendering TFTPD files

generating /etc/xinetd.d/tftp

processing boot_files for distro: rhel-7-x86_64

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.manage_genders

running python trigger cobbler.modules.scm_track

running shell triggers from /var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

  • 启动rsync并设置开机自启

[root@localhost ~]# systemctl restart xinetd

[root@localhost ~]# systemctl restart cobblerd

[root@localhost ~]# systemctl restart httpd

[root@localhost ~]# ss -antl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 *:22 :

LISTEN 0 100 127.0.0.1:25 :

LISTEN 0 5 127.0.0.1:25151 :

LISTEN 0 5 *:873 :

LISTEN 0 128 :::80 ::😗

LISTEN 0 128 :::22 ::😗

LISTEN 0 100 ::1:25 ::😗

LISTEN 0 128 :::443 ::😗

LISTEN 0 5 :::873 ::😗

  • 生成加密的密码

[root@localhost ~]# openssl passwd -1 -salt “$RANDOM” ‘123456’

$1$4083$9jFt/kdeFNmOe4QlSuV4D.

  • 将新生成的加密密码加入到配置文件

[root@localhost ~]# vim /etc/cobbler/settings

… //此处为省略内容

default_password_crypted: “$1 28958 28958 28958sq1sJFDX0bZo.H8Q.8NLg0”

… //此处为省略内容

  • 重启cobbler

[root@localhost ~]# systemctl restart cobblerd

[root@localhost ~]# ss -antl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 *:22 :

LISTEN 0 100 127.0.0.1:25 :

LISTEN 0 5 127.0.0.1:25151 :

LISTEN 0 5 *:873 :

LISTEN 0 128 :::80 ::😗

LISTEN 0 128 :::22 ::😗

LISTEN 0 100 ::1:25 ::😗

LISTEN 0 128 :::443 ::😗

LISTEN 0 5 :::873 ::😗

  • 通过cobbler check 核对当前设置是否有问题

[root@localhost ~]# 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

2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

以上两个是关于debian系统的错误,请忽略

  • 配置cobbler dhcp

  • 修改cobbler配置文件,让cobbler控制dhcp

[root@localhost ~]# vim /etc/cobbler/dhcp.template

… //此处为省略内容

subnet 192.168.170.0 netmask 255.255.255.0 {

option routers 192.168.170.2; //服务器端的网关

option domain-name-servers 8.8.8.8; //此处为系统安装好后指定的dns地址

option subnet-mask 255.255.255.0;

range dynamic-bootp 192.168.170.100 192.168.170.200; 分配的地址池

default-lease-time 21600;

max-lease-time 43200;

next-server $next_server;

… //此处为省略内容

  • 重启服务并同步配置,改完dhcp必须要sync同步配置

[root@localhost ~]# cobbler sync

task started: 2019-08-29_184616_sync

task started (id=Sync, time=Thu Aug 29 18:46:16 2019)

running pre-sync triggers

cleaning trees

removing: /var/www/cobbler/images/rhel-7-x86_64

removing: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-27-5d-16

removing: /var/lib/tftpboot/pxelinux.cfg/default

removing: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-3a-17-d2

removing: /var/lib/tftpboot/grub/images

removing: /var/lib/tftpboot/grub/grub-x86.efi

removing: /var/lib/tftpboot/grub/grub-x86_64.efi

removing: /var/lib/tftpboot/grub/01-00-50-56-27-5D-16

removing: /var/lib/tftpboot/grub/efidefault

removing: /var/lib/tftpboot/grub/01-00-50-56-3A-17-D2

removing: /var/lib/tftpboot/images/rhel-7-x86_64

removing: /var/lib/tftpboot/s390x/profile_list

copying bootloaders

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 files for distro: rhel-7-x86_64

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-7-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-7-x86_64/initrd.img

copying images

generating PXE configuration files

generating: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-3a-17-d2

generating: /var/lib/tftpboot/grub/01-00-50-56-3A-17-D2

generating PXE menu structure

copying files for distro: rhel-7-x86_64

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-7-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/rhel-7/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-7-x86_64/initrd.img

Writing template files for rhel-7-x86_64

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

rendering TFTPD files

generating /etc/xinetd.d/tftp

processing boot_files for distro: rhel-7-x86_64

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.manage_genders

running python trigger cobbler.modules.scm_track

running shell triggers from /var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

  • 检查dhcp是否正常

[root@localhost ~]# netstat -anulp|grep dhcp

udp 0 0 0.0.0.0:67 0.0.0.0:* 12692/dhcpd

  • 导入redhat7镜像

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/

mount: /dev/sr0 写保护,将以只读方式挂载

[root@localhost ~]# cobbler import --path=/mnt/cdrom --name=rhel-7 arch=x86_64

task started: 2019-08-29_171616_import

task started (id=Media import, time=Thu Aug 29 17:16:16 2019)

Found a candidate signature: breed=redhat, version=rhel6

Found a candidate signature: breed=redhat, version=rhel7

Found a matching signature: breed=redhat, version=rhel7

Adding distros from path /var/www/cobbler/ks_mirror/rhel-7:

creating new distro: rhel-7-x86_64

trying symlink: /var/www/cobbler/ks_mirror/rhel-7 -> /var/www/cobbler/links/rhel-7-x86_64

creating new profile: rhel-7-x86_64

associating repos

checking for rsync repo(s)

checking for rhn repo(s)

checking for yum repo(s)

starting descent into /var/www/cobbler/ks_mirror/rhel-7 for rhel-7-x86_64

processing repo at : /var/www/cobbler/ks_mirror/rhel-7

need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-7

looking for /var/www/cobbler/ks_mirror/rhel-7/repodata/comps.xml

Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-7/repodata

processing repo at : /var/www/cobbler/ks_mirror/rhel-7/addons/HighAvailability

need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-7/addons/HighAvailability

looking for /var/www/cobbler/ks_mirror/rhel-7/addons/HighAvailability/repodata/comps.xml

Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-7/addons/HighAvailability/repodata

processing repo at : /var/www/cobbler/ks_mirror/rhel-7/addons/ResilientStorage

need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-7/addons/ResilientStorage

looking for /var/www/cobbler/ks_mirror/rhel-7/addons/ResilientStorage/repodata/comps.xml

先自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《Java开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

img

img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频

如果你觉得这些内容对你有帮助,可以扫码领取!

img

我的面试宝典:一线互联网大厂Java核心面试题库

以下是我个人的一些做法,希望可以给各位提供一些帮助:

整理了很长一段时间,拿来复习面试刷题非常合适,其中包括了Java基础、异常、集合、并发编程、JVM、Spring全家桶、MyBatis、Redis、数据库、中间件MQ、Dubbo、Linux、Tomcat、ZooKeeper、Netty等等,且还会持续的更新…可star一下!

img

我的面试宝典:一线互联网大厂Java核心面试题库

以下是我个人的一些做法,希望可以给各位提供一些帮助:

整理了很长一段时间,拿来复习面试刷题非常合适,其中包括了Java基础、异常、集合、并发编程、JVM、Spring全家桶、MyBatis、Redis、数据库、中间件MQ、Dubbo、Linux、Tomcat、ZooKeeper、Netty等等,且还会持续的更新…可star一下!

[外链图片转存中…(img-o9rxwiwj-1711490951249)]

283页的Java进阶核心pdf文档

Java部分:Java基础,集合,并发,多线程,JVM,设计模式

数据结构算法:Java算法,数据结构

开源框架部分:Spring,MyBatis,MVC,netty,tomcat

分布式部分:架构设计,Redis缓存,Zookeeper,kafka,RabbitMQ,负载均衡等

微服务部分:SpringBoot,SpringCloud,Dubbo,Docker

[外链图片转存中…(img-Wb4qihYL-1711490951249)]

还有源码相关的阅读学习

[外链图片转存中…(img-JdC1Qis2-1711490951249)]

需要更多Java资料的小伙伴可以帮忙点赞+关注,点击传送门,即可免费领取!

也许您对下面的内容还感兴趣: