linux72autoinstall.docx

上传人:b****8 文档编号:28517412 上传时间:2023-07-18 格式:DOCX 页数:10 大小:61.49KB
下载 相关 举报
linux72autoinstall.docx_第1页
第1页 / 共10页
linux72autoinstall.docx_第2页
第2页 / 共10页
linux72autoinstall.docx_第3页
第3页 / 共10页
linux72autoinstall.docx_第4页
第4页 / 共10页
linux72autoinstall.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

linux72autoinstall.docx

《linux72autoinstall.docx》由会员分享,可在线阅读,更多相关《linux72autoinstall.docx(10页珍藏版)》请在冰豆网上搜索。

linux72autoinstall.docx

linux72autoinstall

CentOS7.2下PXE+kickstart自动化安装系统

注意:

我只是一篇笔记,不是教程!

不求甚解的可以一步步跟着做出来,想搞清楚原理的自己研究

温故而知新,虽然工作中用到的系统都是 CentOS6.X,但我们不能一直沉浸在过去的经验中,要跟上时代的节奏

一、实验环境

∙操作系统:

CentOSLinuxrelease7.2.1511(Core)

∙网卡地址:

192.168.100.147/24

∙光盘镜像:

CentOS-7-x86_64-Minimal-1511.iso

∙安装工具:

kickstart+dhcp+tftp+ftp

二、准备工作

2.1关闭防火墙

[root@localhost~]#systemctlstopiptables

[root@localhost~]#systemctlstopfirewalld

2.2关闭selinux

[root@localhost~]#setenforce0

[root@localhost~]#getenforce

Permissive

三、原理和流程图

四、DHCP服务安装及配置

4.1安装dhcp

[root@localhost~]#yuminstalldhcp-y

4.2配置dhcpd

[root@localhost~]#vi/etc/dhcp/dhcpd.conf

default-lease-time600;

max-lease-time7200;

log-facilitylocal7;

subnet192.168.100.0netmask255.255.255.0{

optionrouters192.168.100.2;

optionsubnet-mask255.255.255.0;

optiondomain-name-servers192.168.100.2;

optiontime-offset-18000;#EasternStandardTime

rangedynamic-bootp192.168.100.60192.168.100.100;

default-lease-time21600;

max-lease-time43200;

next-server192.168.100.147;

filename"pxelinux.0";

}

4.3启动dhcpd

[root@localhost~]#systemctlstartdhcpd

4.4dhcp服务测试

[root@localhost~]#ss-nulp|grepdhcpd

UNCONN00*:

67*:

*users:

(("dhcpd",pid=8769,fd=7))

UNCONN00*:

7773*:

*users:

(("dhcpd",pid=8769,fd=20))

UNCONN00:

:

:

55406:

:

:

*users:

(("dhcpd",pid=8769,fd=21))

也可以启动新服务器,看看能否获取到IP地址

4.5设置开机自启动(可选)

[root@localhost~]#systemctlenabledhcpd

Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/dhcpd.serviceto/usr/lib/systemd/system/dhcpd.service.

五、ftp服务安装及配置

5.1安装vsftpd

[root@localhost~]#yuminstall-yvsftpd

5.2配置vsftpd

使用默认配置即可

5.3挂载系统盘

系统安装盘挂载到 /var/ftp/pub 目录下,不要挂载到其它地方,因为 /var/ftp 是 anonymous 匿名用户的家目录

如果是光驱,可以这样挂

[root@localhost~]#mount/dev/cdrom/var/ftp/pub

mount:

/dev/sr0iswrite-protected,mountingread-only

如果是光盘镜像,可以这样挂

[root@localhost~]#mount/opt/CentOS-7-x86_64-Minimal-1511.iso/var/ftp/pub-oloop

mount:

/dev/loop0iswrite-protected,mountingread-only

查看光盘内容

[root@localhost~]#ls/var/ftp/pub

CentOS_BuildTagEULAimagesLiveOSrepodataRPM-GPG-KEY-CentOS-Testing-7

EFIGPLisolinuxPackagesRPM-GPG-KEY-CentOS-7TRANS.TBL

5.4启动vsftpd服务

[root@localhost~]#systemctlstartvsftpd

5.5ftp服务器测试

[root@localhost~]#ftp192.168.100.147

Connectedto192.168.100.147(192.168.100.147).

220(vsFTPd3.0.2)

Name(192.168.100.147:

root):

anonymous

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>ls

227EnteringPassiveMode(192,168,100,147,113,88).

150Herecomesthedirectorylisting.

-rw-r--r--1001068Aug0908:

56ks.cfg

dr-xr-xr-x8002048Dec092015pub

226DirectorysendOK.

ftp>getks.cfg

local:

ks.cfgremote:

ks.cfg

227EnteringPassiveMode(192,168,100,147,126,155).

150OpeningBINARYmodedataconnectionforks.cfg(1068bytes).

226Transfercomplete.

1068bytesreceivedin6.8e-05secs(15705.88Kbytes/sec)

ftp>quit

221Goodbye.

[root@localhost~]#ls

anaconda-ks.cfgks.cfg

成功拿到 ks.cfg 则表示 ftp 服务正常

5.6设置开机自启动(可选)

[root@localhost~]#systemctlenablevsftpd

Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/vsftpd.serviceto/usr/lib/systemd/system/vsftpd.service.

六、tftp服务安装及配置

6.1安装tftp和xinetd服务

[root@localhost~]#yuminstall-yxinetd

[root@localhost~]#yuminstall-ytftp-servertftpsyslinux-tftpboot

6.2配置xinetd

[root@localhost~]#vi/etc/xinetd.d/tftp

servicetftp

{

socket_type=dgram

protocol=udp

wait=yes

user=root

server=/usr/sbin/in.tftpd

server_args=-s/var/lib/tftpboot

#默认disable是yes的,把它改为no即可

disable=no

per_source=11

cps=1002

flags=IPv4

}

6.3配置tftp-server

[root@localhost~]#cp/var/ftp/pub/images/pxeboot/initrd.img/var/lib/tftpboot/

[root@localhost~]#cp/var/ftp/pub/images/pxeboot/vmlinuz/var/lib/tftpboot/

[root@localhost~]#mkdir/var/lib/tftpboot/pxelinux.cfg

[root@localhost~]#vi/var/lib/tftpboot/pxelinux.cfg/default

defaultlinux

prompt1

timeout60

displayboot.msg

labellinux

kernelvmlinuz

appendinitrd=initrd.imgtextks=ftp:

//192.168.100.147/ks.cfg

6.4配置kickstart

以 ~/anaconda-ks.cfg 为模板,再做一些适当的修改

[root@localhost~]#cp~/anaconda-ks.cfg/var/ftp/ks.cfg

[root@localhost~]#vi/var/ftp/ks.cfg

#version=DEVEL

#Systemauthorizationinformation

auth--enableshadow--passalgo=sha512

#InstallOSinsteadofupgrade

install

#Usenetworkinstallation

url--url=ftp:

//192.168.100.147/pub

#Usegraphicalinstall

graphical

#RuntheSetupAgentonfirstboot

firstboot--enable

#Keyboardlayouts

keyboard--vckeymap=us--xlayouts='us'

#Systemlanguage

langen_US.UTF-8--addsupport=zh_CN.UTF-8

#Networkinformation

network--bootproto=dhcp--device=eno16777736--onboot=yes--ipv6=auto

network--hostname=localhost.localdomain

#Rootpassword

#root密码是:

rootroot

rootpw--iscrypted$6$7gdZF8XhDef10LyT$2uRiP4qFYaBBTgpggKU/BXKgMDJLWN/BriXXgBwyzkjaz9G9YP/xD08I1OJfgBcPMoURsE5inVIoX.J6aERmR0

#Systemservices

services--disabled="chronyd"

#Systemtimezone

timezoneAsia/Shanghai--isUtc--nontp

#Systembootloaderconfiguration

bootloader--location=mbr--boot-drive=sda

autopart--type=lvm

#Partitionclearinginformation

clearpart--none--initlabel

%packages

@^minimal

@core

%end

%addoncom_redhat_kdump--disable--reserve-mb='auto'

%end

修改访问权限

[root@localhost~]#ll/var/ftp/ks.cfg

-rw-------.1rootroot1083Aug816:

39/var/ftp/ks.cfg

[root@localhost~]#chmod+r/var/ftp/ks.cfg

[root@localhost~]#ll/var/ftp/ks.cfg

-rw-r--r--.1rootroot1083Aug816:

39/var/ftp/ks.cfg

6.5启动tftp服务

[root@localhost~]#systemctlstartxinetd

6.6测试tftp服务

[root@localhost~]#ls

anaconda-ks.cfgks.cfg

[root@localhost~]#tftp192.168.100.147

tftp>getvmlinuz

tftp>quit

[root@localhost~]#ls

anaconda-ks.cfgks.cfgvmlinuz

如果能成功拿到 vmlinuz 文件,则表示 tftp 服务器状态正常

6.7设置开机自启动(可选)

[root@localhost~]#systemctlenablexinetd

Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/xinetd.serviceto/usr/lib/systemd/system/xinetd.service.

七、启动安装

到这里已经配置完成了。

系统安装前,需要设置BIOS从网卡启动,安装完后马上改回去

八、注意事项

∙注意dhcp冲突

∙注意权限

∙注意防火墙

∙注意selinux

九、进阶参考

∙XX关键词:

 Cobbler

∙Kickstart自动化攻略:

如何制作KS文件—— 

∙kickstart配置文件详解和system-config-kickstart—— 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1