centos7系列Cobbler+kickstart全自动装机实战
配置yum源,以及epel源
[root@crobbler-90111 ~]# cat /etc/yum.repos.d/aliyun.repo
[epel]
name=ailiyun
baseurl=http://mirrors.aliyun.com/epel/7/x86_64/
enabled=
gpgcheck=
[centos]
name=cobbler
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
enabled=
gpgcheck=
#yum install epel-release #安装epel扩展源
[root@cobbler-90111 ~]# systemctl enable cobblerd httpd xinetd #设置开机自启cobblerd,httpd以及xinetd服务
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@crobbler-90111 ~]# cobbler check #检测cobbler
#修改主配置文件
[root@cobbler-90111 ~]# cp /etc/cobbler/settings /etc/cobbler/settings.back
[root@cobbler- ~]# sed -i '/^\<server/s/127.0.0.1/10.15.90.111/' /etc/cobbler/settings [root@cobbler- ~]# sed -i '/next_server/s/127.0.0.1/10.15.90.111/' /etc/cobbler/settings [root@cobbler- ~]# egrep "^\<server|next_server" /etc/cobbler/settings
next_server: 10.15.90.111
server: 10.15.90.111
#设置tftp服务
[root@cobbler- ~]# sed -i "/disable/s/yes/no/" /etc/xinetd.d/tftp [root@cobbler- ~]# egrep "disable" /etc/xinetd.d/tftp
disable = no
[root@cobbler-90111 ~]# systemctl restart rsyncd
[root@cobbler-90111 ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
#下载网络引导文件
[root@crobbler-90111 ~]# cobbler get-loaders
#启动rsyncd服务
[root@crobbler-90111 ~]# systemctl start rsyncd
[root@cobbler-90111 ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@crobbler-90111 ~]# ps -ef | grep rsync
root 14747 1 0 20:09 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 15030 10105 0 20:45 pts/0 00:00:00 grep --color=auto rsync
#修改 etc/cobbler/settings 中'default_password_crypted'的值
[root@crobbler- ~]#xiaoyu=`openssl passwd - -salt 'xiaoyu' 'root'` #定义变量
[root@crobbler- ~]# echo $xiaoyu [root@cobbler- ~]# sed -i "/default_password_crypted/c\/default_password_crypted: \"$xiaoyu"\" /etc/cobbler/settings #赋值即可
[root@cobbler- ~]# sed -n "/default_password_crypted/p " /etc/cobbler/settings
/default_password_crypted: "$1$xiaoyu$cZpdAZwX0o.3cAfeBTRoJ/"
#安装电源管理工具fence-agents
[root@crobbler-90111 ~]# yum install -y fence-agents
#重启cobbler服务,再次检测cobbler服务
[root@crobbler-90111 ~]# systemctl restart cobblerd
[root@cobbler-90111 ~]# cobbler check
【配置DHCP】
[root@crobbler-90111 ~]# vim /etc/cobbler/dhcp.template
[root@cobbler-90111 ~]#sed -i '/^subnet/s/192.168.1.0/10.15.90.0/' /etc/cobbler/dhcp.template
[root@cobbler-90111 ~]# sed -i '/routers/s/192.168.1.5/10.15.90.254/' /etc/cobbler/dhcp.template
[root@cobbler-90111 ~]# sed -i '/domain-name-servers/s/192.168.1.1/144.144.144.144/' /etc/cobbler/dhcp.template
[root@cobbler-90111 ~]# sed -i '/dynamic-bootp/s/192.168.1.100 192.168.1.254/10.15.90.100 10.15.90.150/' /etc/cobbler/dhcp.template
#绑定dhcp,tftp以及rsyncd服务托管
[root@cobbler-90111 ~]# sed -i '/manage_dhcp:/s/0/1/' /etc/cobbler/settings
[root@cobbler-90111 ~]# sed -i '/manage_rsync:/s/0/1/' /etc/cobbler/settings
[root@cobbler-90111 ~] sed -i '/manage_tftpd:/s/0/1/' /etc/cobbler/settings
#检查三个服务时候托管
[root@cobbler-90111 ~]# sed -n -e '/manage_tftpd:/p' -e '/manage_dhcp:/p' -e '/manage_rsync:/p' /etc/cobbler/settings
manage_dhcp: 1
manage_tftpd: 1
manage_rsync: 1
root@cobbler-90111 ~]# systemctl restart cobblerd #重启cobbler服务
[root@cobbler-90111 ~]# cobbler sync #设置sync同步
[root@cobbler-90111 ~]# cat /etc/dhcp/dhcpd.conf #重启cobbler服务之后,检查dhcp配置文件中的配置是否生成!
[配置系统安装镜像]
[root@cobbler-90111 ~]# mkdir /mnt/centos7.6
[root@cobbler-90111 ~]# mount -o loop CentOS-7-x86_64-DVD-1810.iso /mnt/centos7.6/ #挂载cnetos7.6镜像
mount: /dev/loop0 is write-protected, mounting read-only
[root@cobbler-90111 ~]# cobbler import --path=/mnt/centos7.6 --name=Centos7.6-x86_64 --arch=x86_64 #导入centos镜像到cobbler服务中
[root@cobbler-90111 ~]# cobbler profile list
Centos7.6-x86_64
[root@crobbler-90111 ~]# cobbler distro report #查看distro
[root@cobbler- ~]# cobbler distro report
Name : centos7.-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/centos7./images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/centos7./images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/centos7.6-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
[root@cobbler-90111 ~]# cobbler profile report #查看导入系统之后的过程中,cobbler生成的配置文件,关联dhcp,pxe安装菜单
Name : Centos7.6-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Cebtos7.6-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文件,
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
[root@cobbler-90111 kickstarts]# cobbler profile list
centos7.6-x86_64
[root@cobbler-90111 ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler-90111 ~]#mv sample_end.ks sample_end.ks.back #将原生成的ks文件备份重命名备份一下,我们使用自定义的ks文件
[root@cobbler-90111 kickstarts]# vim centos7u6-x64.ks #自定义配置文件
#version=RHEL7
# System authorization information
url --url=$tree
#url --url http://10.15.90.111/cobbler/ks_mirror/Cebtos7.6-x86_64/
# Run the Setup Agent on first boot
firewall --disabled
selinux --disabled
reboot ignoredisk --only-use=sda # Keyboard
keyboard us
# System language
lang en_US.UTF- # Network information
network --onboot=yes --bootproto=dhcp --device=eth0 --ipv6=no # Installation logging level
logging --level=debug # Root password
rootpw --iscrypted $$MfJqPNgPVd8b4aoL$VOHUZHT22qqOLp3e4uXEB.kcdRtW4s8mcqRKAnoL5L9CmHPDaZj/p17jsSvdif98VR0g0cW8wLgoxlooDcwfh.
# System timezone
timezone Asia/Shanghai --isUtc # System bootloader configuration
#bootloader --location=mbr
bootloader --location=mbr --driveorder=sda
# Partition clearing information
zerombr
clearpart --all --initlabel
#clearpart --none --initlabel # Disk partitioning information
# Disk partitioning information
#part / --fstype="xfs" --ondisk=sda --size=
#part /home --fstype="xfs" --ondisk=sda --size=
part /boot --fstype="xfs" --ondisk=sda --size=
part swap --fstype="swap" --ondisk=sda --size=
#part /opt --fstype="xfs" --ondisk=sda --size= --grow
part / --fstype="xfs" --ondisk=sda --size= --grow %packages
@base
@core
@development
@compat-libraries
@scientific
kexec-tools
tree
net-snmp
nmap
sysstat
lrzsz
dos2unix
telnet
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
chrony
wget
net-tools
ntp
ntpdate
%end %post
cat << EOF > /etc/cron.hourly/ntp
#!/bin/sh
/usr/sbin/ntpdate itime.hexun.com;/usr/sbin/hwclock -w > /dev/null >&
EOF
/bin/chmod /etc/cron.hourly/ntp
# Set default language
[ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n /etc/syconfig/i18n.ksbak
cat << EOF > /etc/sysconfig/i18n
LANG="en_US"
SUPPORTED="en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"
EOF cat << EOF >> /etc/rc.d/rc.tune
echo > /proc/sys/kernel/panic
echo "" > /proc/sys/net/ipv4/ip_conntrack_max
echo "" >/proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established
EOF if [ -f /etc/rc.d/rc.tune ]; then
chmod +x /etc/rc.d/rc.tune
echo ". /etc/rc.d/rc.tune" >> /etc/rc.d/rc.local
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nproc 65535" >> /etc/security/limits.conf
echo "* hard nproc 65535" >> /etc/security/limits.conf
else
echo Error! rc.tune can not be found!
fi
#confirm network-device eth0
/bin/mv /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/network-scripts/ifcfg-eth0
/bin/sed -i 's#NAME="ens160"#NAME="eth0"#g' /etc/sysconfig/network-scripts/ifcfg-eth0
/bin/sed -i 's#DEVICE="ens160"#DEVICE="eth0"#g' /etc/sysconfig/network-scripts/ifcfg-eth0
cat << EOF > /etc/sysconfig/grub
GRUB_TIMEOUT=
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet"
EOF
/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
#Set key
/bin/wget http://10.0.251.154/scripts/hxyw_admin-key-centos7.sh
/bin/chmod u+x /hxyw_admin-key-centos7.sh
/bin/sh /hxyw_admin-key-centos7.sh # Set nameserver
#cat << EOF > /etc/resolv.conf
#nameserver 10.0.250.46
#nameserver 10.0.250.40
#EOF
echo "nameserver 10.0.250.40" >> /etc/resolv.conf
echo "nameserver 10.0.250.46" >> /etc/resolv.conf
# Set default run level to
echo "id:3:initdefault:" >> /etc/inittab
#Disable IPV6
echo "net.ipv6.conf.all.disable_ipv6 =1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 =1" >> /etc/sysctl.conf
systemctl disable postfix.service
systemctl disable ntpd.service
%end
[root@cobbler-90111 kickstarts]# cobbler profile list
Centos7.6-x86_64
[root@cobbler-90111 ~]# cobbler profile getks --name "centos7.6-x86_64" #自检
[root@cobbler-90111 kickstarts]# cobbler profile edit --name=Centos7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7u6-x64.ks
[root@cobbler-90111 kickstarts]# cobbler profile edit --name=syscentos7.6-x86_64 --kopts='net.ifnames=0 biosdevname=0' #修改centos配置文件中的kickstart值
[root@cobbler-90111 kickstarts]# cobbler sync #执行rsync同步
task started: 2019-04-18_174012_sync
task started (id=Sync, time=Thu Apr 18 17:40:12 2019)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos7.6-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/centos7.6-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: centos7.6-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.6/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7.6-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.6/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7.6-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos7.6-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.6/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7.6-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.6/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7.6-x86_64/initrd.img
Writing template files for centos7.6-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos7.6-x86_64
cleaning link caches
rendering Rsync files
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 ***
#检查服务是否启动
#systemctl restart dhcp xinetd conler tftp
#最终确保下面这些服务在运行,其中 25151 是 xmlrpc_port 端口 netstat -anutlp|egrep "httpd|rsync|xinetd|dhcpd|25151"
centos7系列Cobbler+kickstart全自动装机实战的更多相关文章
- 自动化安装操作系统(Centos7+PXE+Cobbler+kickstart)
一.简介 PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提 ...
- Service系统服务(五):PXE基础装机环境、配置并验证DHCP服务、配置PXE引导、验证PXE网络装机、PXE+kickstart自动装机
一.PXE基础装机环境 目标: 本例要求为后续的PXE服务器构建提供RHEL7软件仓库,完成下列任务: 1> 在CentOS真机部署Web目录/var/www/html/rh7dvd 2&g ...
- cobbler部署centos6与centos7系列
cobbler部署centos6与centos7系列 转载自:http://www.jianshu.com/p/a4bed77bf40d 版权声明:完全抄自 http://www.jianshu.co ...
- Cobbler自动部署装机 轻松解决装机烦恼
Cobbler自动部署装机一.实验准备二.搭建步骤1.导入epel源2.安装Cobbler以及其相关服务软件包3.修改Cobbler 主配置文件4.启动相关服务并关闭防火墙和selinux5.使用co ...
- centos7使用cobbler(2.8)批量部署操作系统之二
1. Cobbler常用命令 1.1 查看cobbler帮助 # cobbler --help usage ===== cobbler <distro|profile|system|repo|i ...
- centos7使用cobbler(2.8)批量部署操作系统之一
一. 批量部署操作系统的前提 要想批量部署操作系统,得具备以下条件: 客户机支持pxe网络引导 服务器端和客户端建立网络通信(DHCP) 服务器端要有可供客户机开机引导的引导文件 服务器端的可引 ...
- cobbler+kickstart安装笔记
cobbler+kickstart安装笔记 本文参考老男孩配置:https://blog.oldboyedu.com/autoinstall-cobbler/ centos7:开机如果不启动网卡,需要 ...
- Centos7 下cobbler安装及配置
1.背景介绍 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1小时也完成了,但是如果有成百台的服务器还要用光盘.U盘去安装,就显 ...
- CentOS7系列--安装Chrome浏览器
CentOS7系列--安装Chrome浏览器 1. 创建yum源文件 [root@server20 ~]# cd /etc/yum.repos.d/ [root@server20 yum.repos. ...
随机推荐
- PTA编译总结求最大值及其下标
代码: #include<stdio.h> int main(void) { int i,index=0,n; int a[10]; scanf(" ...
- LA4080/UVa1416 Warfare And Logistics 最短路树
题目大意: 求图中两两点对最短距离之和 允许你删除一条边,让你最大化删除这个边之后的图中两两点对最短距离之和. 暴力:每次枚举删除哪条边,以每个点为源点做一次最短路,复杂度\(O(NM^2logN)\ ...
- mysql 严格模式 Strict Mode说明(text 字段不能加默认或者 不能加null值得修改方法)
mysql 严格模式 Strict Mode说明 1.开启与关闭Strict Mode方法找到mysql安装目录下的my.cnf(windows系统则是my.ini)文件 在sql_mode中加入ST ...
- Hadoop 生产配置文件V2
Hadoop 生产配置文件V2 生产环境的配置文件调优 !!! Apache Hadoop 2.7.3 && NN HA && RM HA且仅针对于HDFS & ...
- Tomcat系列(8)——Tomcat运行模式连接数和线程池
Connector的主要功能,是接收连接请求,创建Request和Response对象用于和请求端交换数据:然后分配线程让Engine(也就是Servlet容器)来处理这个请求,并把产生的Reques ...
- idea 错误: 找不到或无法加载主类
1.cmd进入项目目录 2.输入maven命令重构项目 mvn clean mvn idea:idea install
- Arrays和String单元测试 20175301
要求 在IDEA中以TDD的方式对String类和Arrays类进行学习 一.String类相关方法的单元测试 1.ChatAt的测试 代码: import org.junit.Test; impor ...
- Aras简单报表
1.编辑Report对象类的窗体Report_Tab_Report,将xsl_stylesheet放到窗体上 2.新建报表 3.将编辑好的XSLT复制到xsl_stylesheet中. <xsl ...
- java常见题目总结
编写多线程程序的几种方法:java5以前可以通过继承Thread类或者实现Runnable接口,重写run方法来定义线程行为:java5以后出现了另一种方式,实现Callable接口,该接口的call ...
- 解决系统中大量的TIME_WAIT连接
今天发现网站特别卡!! 查看网络连接数: netstat -an |wc -l netstat -an |grep xx |wc -l 查看某个/特定ip的连接数 netstat -an ...