1. 安装时需要调整的配置
-
语言选中文
-
自定义分区
/boot 1G 启动时所需要的资源
swap 4G
/45G
-
配置网络(ip:192.168.10.100/24 网关、DNS:192.168.10.2)、主机名(hadoop100),ntp服务器(ntp.aliyun.com)选配
-
配置新的root密码和自定义用户和密码
2. 安装结束后,Linux需要的基本配置
-
配置/etc/hosts
for ((i=100;i<110;i++)) do echo 192.168.10.$i hadoop$i >> /etc/hosts done
-
关闭防火墙和自启动
systemctl stop firewalld systemctl disable firewalld
-
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
-
免密
ssh-keygen ssh-copy-id hadoop100 # 编辑ssh配置 vi /etc/ssh/ssh_config # 在host *下面添加一行 StrictHostKeyChecking no
-
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
-
安装必要依赖
可选:配置镜像源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
-
搞个数据目录
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