静默安装服务器搭建

来源:互联网 发布:直方图绘制软件 编辑:程序博客网 时间:2024/06/07 01:49

1、首先要关闭firwalld和selinux

systemctl stop firwalld

setenforce 0

2、安装dhcp

yum -y install dhcp

cat /etc/dhcp/dhcpd.conf

#

# DHCP Server Configuration file.

#   see /usr/share/doc/dhcp*/dhcpd.conf.example

#   see dhcpd.conf(5) man page

#


#option domain_name "tianrang-inc.com";

option domain-name-servers 172.18.192.253;

default-lease-time 600;

max-lease-time 7200;

log-facility local7;

subnet 172.18.192.0 netmask 255.255.255.0 {

  range dynamic-bootp 172.18.192.1 172.18.192.100;

  option routers 172.18.192.254;

  filename "/pxelinux.0";

  next-server 172.18.192.253;

  server-name "172.18.192.253";

}

指定监听网卡

vim /etc/sysconfig/dhcpd


# WARNING: This file is NOT used anymore.


# If you are here to restrict what interfaces should dhcpd listen on,

# be aware that dhcpd listens *only* on interfaces for which it finds subnet

# declaration in dhcpd.conf. It means that explicitly enumerating interfaces

# also on command line should not be required in most cases.


# If you still insist on adding some command line options,

# copy dhcpd.service from /lib/systemd/system to /etc/systemd/system and modify

# it there.

# https://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F


# example:

# $ cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/

# $ vi /etc/systemd/system/dhcpd.service

# $ ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid <your_interface_name(s)>

# $ systemctl --system daemon-reload

# $ systemctl restart dhcpd.service


DHCPDARGS=eno1


systemctl start dhcp

3、安装tftp

yum -y install tftp-server

yum -y installxinetd

systemctl starttftp-server

vim /etc/xinetd.d/tftp

# default: off

# description: The tftp server serves files using the trivial file transfer \

# protocol.  The tftp protocol is often used to boot diskless \

# workstations, download configuration files to network-aware printers, \

# and to start the installation process for some operating systems.

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /var/lib/tftpboot

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}


systemctl startxinetd

检查是否tftp监听正常

netstat -tunlp|grep 69

4、安装http

yum -y install httpd

sed -i "277i ServerName 127.0.0.1:80" /etc/httpd/conf/httpd.conf

systemctl start httpd

mkdir /var/www/html/Ubuntu

mount -o loop ~/Ubuntu-16.04-server-amd64.iso /mnt

cp /mnt/preseed/Ubuntu-server.seed /var/www/html/Ubuntu

cp -a /mnt/* /var/www/html/Ubuntu

cp -r /mnt/install/netboot/* /var/lib/tftpboot

5、配置pxe

vi /var/lib/tftpboot/pxelinux.cfg/default

# D-I config version 2.0

# search path for the c32 support libraries (libcom32, libutil etc.)

#path ubuntu-installer/amd64/boot-screens/

#include ubuntu-installer/amd64/boot-screens/menu.cfg

#default ubuntu-installer/amd64/boot-screens/vesamenu.c32

#prompt 0

#timeout 0


default linux


label linux


   kernel ubuntu-installer/amd64/linux


   append ks=http://172.18.192.253/Ubuntu/ks.cfg ksdevice=eno1 preseed/url=http://172.18.192.253/Ubuntu/ubuntu-server.seed vga=normal initrd=ubuntu-installer/amd64/initrd.gz –


6、配置ks.cfg

vi /var/www/html/Ubuntu/ks.cfg

#

#Generic Kickstart template for Ubuntu

#Platform: x86 and x86-64

#


#System language

lang en_US


#Language modules to install

#langsupport en_US


#System keyboard

keyboard us


#System mouse

#mouse


#System timezone

timezone America/New_York


#Root password

#rootpw --disabled


#Initial user (user with sudo capabilities) 

#user ubuntu --fullname "Ubuntu User" --password root4me2

user --name "benjen" --password TRzjy123

#Reboot after installation

reboot


#Use text mode install

text


#Install OS instead of upgrade

install


#Installation media

url --url http://172.18.192.253/Ubuntu/


#nfs --server=server.com --dir=/path/to/ubuntu/


#System bootloader configuration

bootloader --location=mbr 


#Clear the Master Boot Record

#zerombr yes


#Partition clearing information

clearpart --all --initlabel 


#Basic disk partition

part / --fstype ext4 --size 1 --grow --asprimary 

part swap --size 1024 

part /boot --fstype ext4 --size 256 --asprimary 


#Advanced partition

#part /boot --fstype=ext4 --size=500 --asprimary

#part pv.aQcByA-UM0N-siuB-Y96L-rmd3-n6vz-NMo8Vr --grow --size=1

#volgroup vg_mygroup --pesize=4096 pv.aQcByA-UM0N-siuB-Y96L-rmd3-n6vz-NMo8Vr

#logvol / --fstype=ext4 --name=lv_root --vgname=vg_mygroup --grow --size=10240 --maxsize=20480

#logvol swap --name=lv_swap --vgname=vg_mygroup --grow --size=1024 --maxsize=8192


#System authorization infomation

auth  --useshadow  --enablemd5 


#Network information

network --bootproto=dhcp --device=eno1


#Firewall configuration

firewall --disabled --trust=eno1 --ssh 


#Do not configure the X Window System

skipx


检查ks.cfg文件ok

ksvalidator ks.cfg 


0 0
原创粉丝点击