Hadoop集群搭建(虚拟机集群搭建)


前言

CentOS虚拟机集群搭建


一、虚拟机集群搭建

下载VirtualBox并创建三台虚拟机
创建后如下图所示
在这里插入图片描述

二、虚拟机网络配置

1.将虚拟机的网络连接方式设置为桥接网卡

在这里插入图片描述

2.找到当前网络的网关然后设置一个静态IP

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

先动态分配一个ip地址来查看当前ip的网络地址
ONBOOT=yes
Esc+: wq 保存文件退出,退出不保存q!

service network restart

重启网络服务

ip addr

网卡:enp0s3

Ip:192.168.0.103/24

网关:192.168.0.255

子网掩码:255.255.255.0
在这里插入图片描述

然后将ip设置为静态

BOOTPROTO=static

IPADDR=(刚刚看的ip地址)

NETMASK=(子网掩码,如果是小型网络一般是255.255.255.0)

GATEWAY=(刚刚看的网关)

各项参数设置说明

TYPE=Ethernet                # 网卡类型:为以太网
PROXY_METHOD=none            # 代理方式:关闭状态
BROWSER_ONLY=no                # 只是浏览器:否
BOOTPROTO=dhcp                # 网卡的引导协议:DHCP[中文名称: 动态主机配置协议]
DEFROUTE=yes                # 默认路由:是, 不明白的可以百度关键词 `默认路由
IPV4_FAILURE_FATAL=no        # 是不开启IPV4致命错误检测:否
IPV6INIT=yes                # IPV6是否自动初始化:[不会有任何影响, 现在还没用到IPV6]
IPV6_AUTOCONF=yes            # IPV6是否自动配置:是[不会有任何影响, 现在还没用到IPV6]
IPV6_DEFROUTE=yes            # IPV6是否可以为默认路由:是[不会有任何影响, 现在还没用到IPV6]
IPV6_FAILURE_FATAL=no        # 是不开启IPV6致命错误检测:否
IPV6_ADDR_GEN_MODE=stable-privacy            # IPV6地址生成模型:stable-privacy [这只一种生成IPV6的策略]
NAME=ens33                    # 网卡物理设备名称
UUID=f47bde51-fa78-4f79-b68f-d5dd90cfc698    # 通用唯一识别码, 每一个网卡都会有, 不能重复, 否两台linux只有一台网卡可用
DEVICE=ens33                    # 网卡设备名称, 必须和 `NAME` 值一样
ONBOOT=no  
IPADDR=192.168.0.101” #192.168.59.x, x为3~255. 
NETMASK=255.255.255.0” #子网掩码 
GATEWAY=192.168.66.2” #网关IP

重启网络服务

service network restart

3.配置DNS

vi /etc/resolv.conf

在这里插入图片描述

4. 配置ip地址映射

修改主机名的命令

sudo gedit /etc/hostname

编辑hosts,将节点名称与ip地址映射起来(所有节点)

vim /etc/hosts

192.168.44.3 presto
192.168.44.4 presto1
192.168.44.5 presto2

5.关闭防火墙

关闭服务

systemctl stop firewalld

关闭开机自启动

systemctl disable firewalld

6.配置ssh免密登录

每台主机authorized_keys文件里面包含的主机(ssh密钥),该主机都能无密码登录,所以只要每台主机的authorized_keys文件里面都放入其他主机(需要无密码登录的主机)的ssh密钥就行了。

1.每个节点生成ssh密钥

ssh-keygen -t rsa

2.在主节点上将公钥拷到一个特定文件authorized_keys中

[root@presto ~] cd .ssh
[root@presto .ssh] ls
id_rsa id_rsa.pub
[root@presto .ssh] cp id_rsa.pub authorized_keys
[root@presto .ssh] ls
authorized_keys id_rsa id_rsa.pub

3.在主节点上将公钥拷到一个特定文件authorized_keys中。

[root@presto ~] cd .ssh
[root@presto .ssh] ls
id_rsa id_rsa.pub
[root@presto .ssh] cp id_rsa.pub authorized_keys
[root@presto .ssh] ls
authorized_keys id_rsa id_rsa.pub

4.将authorized_keys文件拷到下一个节点,并将该节点的ssh密钥id_rsa.pub加入该文件中。

在主节点上使用scp命令实现远程文件拷贝

[root@hadoop01 .ssh] scp authorized_keys root@presto1:/root/.ssh/
The authenticity of host ‘hadoop02 (192.168.44.11)’ can’t be established.
ECDSA key fingerprint is SHA256:MyB1zs0E3J/fm8pC0AN8ycsgEIBNHtUqd9xS0WAyv3s.
ECDSA key fingerprint is MD5:88:48:3a:ba:3e:14:a7:d7:86:f6:51:74:00:10:f9:00.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘hadoop02,192.168.44.11’ (ECDSA) to the list of known hosts.
root@hadoop02’s password:
authorized_keys 100% 395 306.2KB/s 00:00

登录presto1主机

[root@presto1 ~] cd .ssh/
[root@presto1 .ssh] ls
authorized_keys id_rsa id_rsa.pub
[root@presto1 .ssh] cat id_rsa.pub >> authorized_keys

cat命令

把 textfile1 和 textfile2 的文档内容加上行号(空白行不加)之后将内容附加到 textfile3 文档里

cat -b textfile1 textfile2 >> textfile3

5.重复上述操作

登录hadoop03主机,将ssh密钥加入authorized_keys文件中

[root@presto2 .ssh] cat id_rsa.pub >> authorized_keys

将最后生成的authorized_keys文件分别拷贝到presto、presto1

[root@presto2 .ssh]# scp authorized_keys root@presto:/root/.ssh/
[root@presto2 .ssh]# scp authorized_keys root@presto1:/root/.ssh/

6.验证

使用ssh 用户名@节点名或ssh ip地址命令验证免密码登录。

[root@presto .ssh]# ssh root@presto1
Last login: Tue Feb 12 03:59:46 2019 from 192.168.44.1

参考博客 https://blog.csdn.net/qq_40615403/article/details/109910764
https://www.jianshu.com/p/181794ea28ba
https://www.cnblogs.com/shireenlee4testing/p/10472018.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值