1、配置chrony服务,实现服务器时间自动同步
-->下载chrony服务器:
更改下时间:
-->配置并启动:
重新启动服务:
cilent端:
-->下载chrony服务:
更改配置并重启服务:
地址指向时钟服务器:
重启服务后时间:
2、实现cobbler+pxe自动化装机:
-->pxe自动化安装centos7:
1-安装httpd tftp-server dhcp syslinu system-config-kickstart tree
2-搭建本地yum源,并启动各项服务;
mkdir -p /var/www/html/centos/7/os/x86_64
mount /dev/sr0 /var/www/html/centos/7/os/x86_64
mkdir -p /var/www/html/ksdir/
3-配置DHCP服务器;
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf --复制配置文件
更改DHCP相对应的文件:
subnet 192.168.10.0 netmask 255.255.255.0 {
28 range 192.168.10.100 192.168.10.254;
29 option routers 192.168.10.1;
30 filename "pxelinux.0"; --启动的bootloader,rpm包syslinux
31 next-server 192.168.10.12; --本地安装源系统的地址
32 }
重启DHCPD
4-配置tftp-server文件 :进行pxe安装 ;
mkdir -p /var/lib/tftpboot/pxelinux.cfg
cp /var/www/html/centos/7/os/x86_64/isolinux/vmlinuz /var/lib/tftpboot/
cp /var/www/html/centos/7/os/x86_64/isolinux/initrd.img .
cp /var/www/html/centos/7/os/x86_64/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default --启动菜单文件
cp /usr/share/syslinux/menu.c32 . --菜单引导文件
cp /usr/share/syslinux/pxelinux.0 . --引导的bootloader
5-配置系统应答文件,kickstart
6-配置系统引导菜单:
default menu.c32
timeout 600
menu title CentOS 7
label linux
menu label ^PXE Install CentOS 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.10.12/ksdir/test.cfg
label yumbase
menu label Test this ^media & install CentOS 7
kernel vmlinuz
append initrd=initrd.img inst.repo=http://192.168.10.12/centos/7/os/x86_64/
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
6-开机去掉相对应的挂载CD,保证在同一局域网,开始自动安装;
-->实现cobbler自动安装centos7;
1-yum install cobbler dhcp tree--安装相关的软件
2-mount /dev/sr0 /mnt/ --挂载光盘
3-systemctl start httpd tftp.socket cobblerd --启动相关的服务
4-cobbler check --检查配置项
5-更改:/etc/cobbler/settings 文件:
vim /etc/cobbler/settings
default_password_crypted: "$1$RFO.hOYF$g79MJdrxFJMgpggQlhjev/" #openssl passwd -1 --生成md5登录密码;
![](https://s4.51cto.com/images/blog/202004/17/2d88b0066e6b50a85a21815c5a49d27c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
next_server: 192.168.37.17 --tftp服务器地址
manage_dhcp: 1 --dhcp服务器
server: 192.168.37.17 --cobbler服务器地址
6-更改DHCP服务器配置:vim /etc/cobbler/dhcp.template
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.2;
option domain-name-servers 180.76.76.76;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.10.100 192.168.10.254;}
![](https://s4.51cto.com/images/blog/202004/17/5f14e355e91b363a499bf9e02f514ac8.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
下载boorloader:cobbler get-loaders
7-重启服务:mkdir -p /usr/share/cobbler/web/cobbler.wsgi --创建该文件
systemctl restart cobblerd
cobbler sync
systemctl start dhcpd
![](https://s4.51cto.com/images/blog/202004/17/f76739cbb3e544857dbe64889d3b67f7.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
8-导入cobbler的yum源;
cobbler import distro --path=/mnt --name=centos-7-x86_64 --arch=x86_64
导入文件会在:/var/www/cobbler下
cobbler distro list --查看是否导入
![](https://s4.51cto.com/images/blog/202004/17/23605579ea8fecddd06072cbc58a827a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
9-生成ks文件:
cp ks7_mini.cfg /var/lib/cobbler/kickstarts/ --复制文件到配置目录
cobbler profile add --name=centos-7-x86_64_mini --distro=centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7_mini.cfg --生成相关的ks文件
![](https://s4.51cto.com/images/blog/202004/17/1e3536577e1b07af2e0ae4e59d200175.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
cobbler profile list --查看生成的KS目录
cobbler profile remove --name=centos-7-x86_64 --删除多余的KS目录
10-更改开机默认属性:vim /etc/cobbler/pxe/pxedefault.template
1 DEFAULT menu
2 PROMPT 0
3 MENU TITLE Cobbler | http://cobbler.github.io/
4 TIMEOUT 200
5 TOTALTIMEOUT 1000 --等待时间为十秒
6 ONTIMEOUT $pxe_timeout_profile
7
8 LABEL local
9 MENU LABEL (local)
10 LOCALBOOT
12 $pxe_menu_items
13 MENU DEFAULT --更改默认安装系统为自定系统
14
15 MENU end
![] (https://s4.51cto.com/images/blog/202004/17/b66ea6bbb413c1f775b59835bc195a09.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
重启所有服务,并同步数据:cobbler sync
systemctl restart httpd tftp.socket cobblerd dhcpd
cobbler sync
11-开机安装:
来源:oschina
链接:https://my.oschina.net/u/4324861/blog/3274289