Hadoop2.7.6搭建伪分布式集群详细过程--2.配置ip映射和免密登录

配置IP映射

1.  ifconfig 命令查看要配置的网卡

ens33: flags=4163  mtu 1500
        inet 192.168.80.128  netmask 255.255.255.0  broadcast 192.168.80.255
        inet6 fe80::b281:5928:db22:b890  prefixlen 64  scopeid 0x20
        ether 00:0c:29:97:01:7d  txqueuelen 1000  (Ethernet)
        RX packets 38  bytes 7619 (7.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 49  bytes 6283 (6.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 这是我这台虚拟机上的要配置的网卡信息

2.设置静态IP地址

sudo gedit /etc/sysconfig/network-scripts/ifcfg-ens33  命令编辑网卡配置,最后的 ens33 是我这里的网卡名称,自己根据需要选择正确的要修改的文件 (如果是在root用户下操作不需要在前面加 sudo ;因为我安装了桌面所以默认会有 gedit ,没有的话可以用 vi 进行编辑)

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no

BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=0915f229-8d68-4e6c-a35c-22d7d3db12c7
DEVICE=ens33

ONBOOT=yes
IPADDR=192.168.80.129
GATEWAY=192.168.80.2
NETMASK=255.255.255.0
DNS1=192.168.80.2

蓝色标出的是需要修改的地方,IPADDR设置的是ip地址,GATEWAYDNS1设置的是网关;

保存退出gedit后重启网卡,命令: systemctl restart network  (好像也可以最后重启,保险起见我这里操作一次重启一次)

3.修改主机ip映射

命令: sudo gedit /etc/hosts 

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.80.129 master

在文件中另起一行输入要设置的内容,如上面的蓝色字体标出的,格式为ip 主机名 

然后执行命令 sudo gedit /etc/hostname 修改主机名

打开文件后删除原有的内容输入你要更改的主机名

master

然后重启网卡  systemctl restart network

ping master    如果可以ping通证明成功

此时进入root可以发现用户和主机名已经变成了 root@master  ,普通用户那里大概会在新的终端或者重启后显示,或者重启某服务,忘记了,欢迎补充;

4.修改Windows主机映射实现跨平台“访问”

作为一个初学者不知道这里有没有意义,姑且先写出来

找到 C:\Windows\System32\drivers\etc 下的 hosts文件,复制到桌面然后修改替换原本目录中的文件,格式同Linux中一样

...

...

...
# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
192.168.80.128 bigdata

只需要在最后一行添加即可,其余不需要更改

5.设置免密登录

可以参考文章 https://blog.csdn.net/wang704987562/article/details/78904350

这里只说需要执行的命令

ssh-keygen -t rsa         然后一路回车

[fofe@master ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/fofe/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/fofe/.ssh/id_rsa.
Your public key has been saved in /home/fofe/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:HnECEr5MyXjJCcd7vn/grU4e7Xh5cpLRQ/fqsKeJj/w fofe@master
The key's randomart image is:
+---[RSA 2048]----+
|  ..+..          |
|   B.= .         |
|  . X.  o .      |
|   +...  +  . .  |
|    oo  S  o . . |
|      ...o. o   .|
|       o+o.+.. . |
|      .o.=Ooo+o  |
|       o*+=BE+.  |
+----[SHA256]-----+

 

ssh-copy-id -i master    (这里的master是我设置的主机名,根据自己的需要更改命令)

[fofe@master ~]$ ssh-copy-id -i master
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/fofe/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
fofe@master's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'master'"
and check to make sure that only the key(s) you wanted were added.

然后执行 ssh master 测试一下 

[fofe@master ~]$ ssh master
Last failed login: Mon Jul 30 17:50:54 CST 2018 from master on ssh:notty
There were 3 failed login attempts since the last successful login.
Last login: Mon Jul 30 17:21:25 2018
[fofe@master ~]$ exit
登出
Connection to master closed.
[fofe@master ~]$ 
 

成功,本篇结束。 

感觉写的可能还是有点过于细节了吗?

你可能感兴趣的:(我的学习)