【采集项目-(1)模板虚拟机准备】

1. 安装时需要调整的配置

  1. 语言选中文

  2. 自定义分区

    /boot 1G 启动时所需要的资源

    swap 4G

    /45G

  3. 配置网络(ip:192.168.10.100/24 网关、DNS:192.168.10.2)、主机名(hadoop100),ntp服务器(ntp.aliyun.com)选配

  4. 配置新的root密码和自定义用户和密码

2. 安装结束后,Linux需要的基本配置

  1. 配置/etc/hosts

    for ((i=100;i<110;i++))
    do
      echo 192.168.10.$i hadoop$i >> /etc/hosts
    done
    
  2. 关闭防火墙和自启动

    systemctl stop firewalld
    systemctl disable firewalld
    
  3. sudo

    visudo
    ## Allows people in group wheel to run all commands
    #%wheel ALL=(ALL)       ALL
    
    ## Same thing without a password
     %wheel ALL=(ALL)       NOPASSWD: ALL
    
    usermod -aG wheel atguigu
    
  4. 免密

    ssh-keygen
    ssh-copy-id hadoop100
    
    # 编辑ssh配置
    vi /etc/ssh/ssh_config
    # 在host *下面添加一行
    StrictHostKeyChecking no
    
  5. xcall,xsync , new7

    xcall
    
    #!/bin/bash
    while getopts "w:" arg; do
        case $arg in
        w)
            CLUSTER_TMP=$OPTARG
            ;;
        ?)
            echo "unkonw argument $arg"
            exit 1
            ;;
        esac
    done
    if [ "$CLUSTER_TMP" ]; then
      CLUSTER=$CLUSTER_TMP
      shift
      shift
    fi
    [ -z "$CLUSTER" ] && CLUSTER="hadoop102,hadoop103,hadoop104"
    #pdsh -w "$CLUSTER" "$*" | sort -k1 -t" " | awk -F ": " '{if (host!=$1) {host=$1;print ">>>>>>>>>>>>  "host"  <<<<<<<<<<<<"};$1=null;print $0  }'
    pdsh -w "$CLUSTER" "$*" | awk -F ": " '{key=$1;$1=null;out[key]=out[key]"\n"$0} END{ for (i in out) {print ">>>>>>>>>>>>  "i"  <<<<<<<<<<<<"out[i]} }'
    
    
    xsync
    
    #!/bin/bash
    #1. 判断参数个数
    if [ $# -lt 1 ]
    then 
     echo "分发内容不能为空"
     exit;
    fi
    #2.遍历集群中的每一台机器 挨个发送
    for host in hadoop103 hadoop104
    do
     for file in $@
     do
      #3.判断文件是否存在
      if [ -e $file ]
      then
       #4.获取父级目录
       pdir=$(cd -P $(dirname $file);pwd)
       #5.文件名
       filename=$(basename $file)
       #6.避免分发的服务器没有这个父目录
       ssh $host "mkdir -p pdir"
       #5.分发
       rsync -av $pdir/$filename $host:$pdir
      else
       echo "$file文件不存在"
      fi
     done
    done
    
    #new7 重置IP脚本
    
    
    #!/bin/bash
    
    if (($#==0)); then
       echo No args!;
       exit;
    fi
    
    if (($1<2 || $1>255)); then
       echo Invalid args!;
       exit
    fi
    
    hostnamectl --static set-hostname hadoop$1
    
    cat >/etc/sysconfig/network-scripts/ifcfg-ens33 <<EOF
    TYPE="Ethernet"
    BOOTPROTO="static"
    NAME="ens33"
    DEVICE="ens33"
    ONBOOT="yes"
    IPADDR="192.168.10.$1"
    PREFIX="24"
    GATEWAY="192.168.10.2"
    DNS1="192.168.10.2"
    EOF
    
    reboot
    
    
  6. 安装必要依赖

    可选:配置镜像源https://developer.aliyun.com/mirror/

    配置centos和epel两个源

    yum install -y epel-release \
    net-tools vim \
    psmisc  nc  rsync  lrzsz  ntp libzstd openssl-static iotop git pdsh libaio wget
    
  7. 搞个数据目录

    mkdir /opt/module /opt/software /opt/data
    chown -R atguigu:atguigu /opt/module /opt/software /opt/data
    

8.克隆虚拟机
hadoop102 hadoop103 hadoop104
修改IP :

cd /home/atguigu/bin
./new7 103/104/105
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值