首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

操作系统批量安装

学习过程都在本地电脑上搭建环境进行,将会大量使用到虚拟机,Virtualbox和VMware workstation都用过很长时间,我选择使用workstation,因为workstation的网络配置更为专业,可以应付很多复杂的实验环境。

几乎所有的生产环境后端的存储集群都不会开放访问互联网,为了更接近真实环境,在环境中桥接loopback网卡来进行网络模拟,在本地windows下设备管理器中添加过时硬件,选择Microsoft KMS-TEST 环回适配器,如图(只需要配置VMnet0网卡):

workstation中网络配置如下图:

生产环境集群往往都有大量服务器,小则十多台,多则几百台,我采用了常用的PXE方式批量安装操作系统,先搭建一台PXE-svr,安装任一版本的linux(我选择CentOS6.5),配置如下:

1、pxe-svr配置

2、完成最小化安装CentOS6.5:

手工配置网络如图(CentOS7需更改对应命令):

sed -i 's#ONBOOT=no#ONBOOT=yes#g' /etc/sysconfig/network-scripts/ifcfg-eth0

sed -i 's#BOOTPROTO=dhcp#BOOTPROTO=static#g' /etc/sysconfig/network-scripts/ifcfg-eth0

cat >/etc/sysconfig/network-scripts/ifcfg-eth0

>IPADDR=10.10.1.253

>NETMASK=255.255.255.0

>GATEWAY=10.10.1.254

chkconfig iptables off

service iptables stop

之前添加的环回口网卡IP配置如下:

可以使用ssh工具远程登陆pxe-svr了:

下面开始配置pxe-svr:

1、挂载安装光盘后,配置光盘本地源

mount /dev/cdrom /media

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

cat >/etc/yum.repos.d/CentOS-Base.repo

>name=local

>baseurl=file:///media/

>gpgcheck=0

yum clean all

yum repolist

2、安装服务

yum -y install vim

yum -y install httpd

yum -y install tftp-server

yum -y install dhcp

yum -y install syslinux

3、配置服务

tftp服务:

sed -i '14s/yes/no/g' /etc/xinetd.d/tftp

/etc/init.d/xinetd start

chkconfig xinetd on

dhcp服务

cp -f /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

subnet 10.10.1.0 netmask 255.255.255.0 {

range dynamic-bootp 10.10.1.1 10.10.1.200; ////ip地址池

option broadcast-address 10.10.1.255;

option routers 10.10.1.253; ///网关ip

next-server 10.10.1.252; ///pxe-svr的ip

filename "pxelinux.0"; ///pxe启动参数

}

chkconfig dhcpd on

http服务:(需要将客户机待安装的OS镜像copy到/var/www/html/目录)

mount /dev/cdrom /media

mkdir -pv /var/www/html/rhel6.5/

cp -rf /media/* /var/www/html/rhel6.5/ //拷贝rhel6.5光盘的所有内容

PXE配置:

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

cp /var/www/html/rhel6.5/images/pxeboot/initrd.img /var/lib/tftpboot/

cp /var/www/html/rhel6.5/images/pxeboot/vmlinuz /var/lib/tftpboot/

cp /var/www/html/rhel6.5/isolinux/*.msg /var/lib/tftpboot/

mkdir -pv /var/lib/tftpboot/pxelinux.cfg

cp /var/www/html/rhel6.5/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

修改default文件如下图:

编辑ks配置文件(以rhel6-5.cfg命名):

vim rhel6-5.cfg

#platform=x86, AMD64, 或 Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url --url="http://10.10.1.252/rhel6.5" //pxe地址

# Root password

rootpw --iscrypted $1$4ng921wA$KOPFTOgiDB5nc1Ntb8zyX0

# System authorization information

auth --useshadow --passalgo=sha512

# Use text mode install

text

firstboot --disable

# System keyboard

keyboard us

# System language

lang zh_CN

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone Asia/Shanghai

# Network information

network --bootproto=dhcp --device=eth0 --onboot=on

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information 分区信息,可自行更改

part / --fstype="ext4" --size=15000

part /boot --fstype="ext4" --size=200

%packages ////需要安装的软件包,这里选择安装基本系统

@base

%end

4、启动服务

service httpd start

service dhcpd start ////排错日志/var/log/message

service xinetd start

5、测试服务

curl http://10.10.1.252/rhel6.5/

至此PXE-svr安装配置完成,新建虚拟机作为hadoop节点,配置如下,数量7台:

1、虚拟机配置:内存至少4G,网卡配置与pxe服务器一致,其余参数随意。

启动虚拟机,将会启动pxe安装界面:

7台节点服务器同时开始安装:

安装完成

节点操作系统安装完成:

由于hadoop集群安装需要大量的环境配置工作,生产环境中如果节点数量庞大,几十台乃至上百台服务器,使用手工配置势必很蛋疼……,这个时候可以采用自动化运维工具,下一节将分别采用:shell脚本、ansible、saltstack来完成以下工作:静态IP配置、yum本地配置、hosts文件、selinux、iptables、ssh互信、THP、环境变量配置等工作。

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180610G0Z5MA00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券
http://www.vxiaotou.com