目录 官网导读 基础设施 设置IP及主机名 关闭防火墙selinux 设置hosts映射 时间同步 安装jdk 设置SSH免秘钥 结论 官网导读 hadoop.apache.org/docs/r2.6.5 支持最好的平台:GNU/Linux 依赖的软件:
目录
- 官网导读
- 基础设施
- 设置IP及主机名
- 关闭防火墙&selinux
- 设置hosts映射
- 时间同步
- 安装jdk
- 设置SSH免秘钥
- 结论
官网导读
hadoop.apache.org/docs/r2.6.5…
支持最好的平台:GNU/Linux
依赖的软件:
- Java™ must be installed. Recommended Java versions are described at HadoopJavaVersions.Hadoop基于Java开发,Java的移动性好
- ssh must be installed and sshd must be running to use the Hadoop scripts that manage remote Hadoop daemons.
部署模式:
- Local (Standalone) Mode 单机模式,主要用于debug
- Pseudo-Distributed Mode 伪分布式,单节点多角色
- Fully-Distributed Mode 完全分布式,多节点多角色
基础设施
操作系统、环境、网络、必须软件
- 设置IP及主机名
- 关闭防火墙&selinux
- 设置hosts映射
- 时间同步
- 安装jdk
- 设置SSH免秘钥
设置IP及主机名
可以正常联网查看IP
[root@localhost ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.118 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::3db1:f589:4820:5457 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:18:10:17 txqueuelen 1000 (Ethernet) RX packets 462062 bytes 670399544 (639.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 166351 bytes 11096211 (10.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 84 bytes 13940 (13.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 84 bytes 13940 (13.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:5a:69:e1 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 // 配置 DEVICE=eth0 #HWADDR=00:0C:29:42:15:C2 TYPE=Ethernet ONBOOT=yes NM_TROLLED=yes BOOTPROTO=static IPADDR=192.168.150.11 NETMASK=255.255.255.0 GATEWAY=192.168.150.2 DNS1=223.5.5.5 DNS2=114.114.114.114
修改配置文件设置主机名
[root@localhost ~]# vi /etc/sysconfig/network // 设置主机名并保存退出 HOSTNAME=node01
关闭防火墙&selinux
//关闭防火墙 [root@localhost ~]# systemctl stop firewalld //关闭开机启动防火墙 [root@localhost ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@localhost ~]# [root@localhost ~]# vi /etc/selinux/config //将配置文件中的SELINUX设置为disabled SELINUX=disabled
设置hosts映射
增加映射关系,因为在现在搭建环境的时候,一般会做解耦,不会再软件配置文件中写ip地址,主要使用主机名,就和dns解析一样,避免ip改变时要修改很多配置文件
[root@localhost ~]# vi /etc/hosts // 增加映射关系 192.168.0.118 node01 192.168.0.119 node02
时间同步
所有节点时间需同步一致,不然未来做心跳的时候会有问题
[root@localhost ~]# date Fri Dec 30 22:23:45 CST 2022 // 安装ntp [root@localhost ~]# yum install ntp -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Package ntp-4.2.6p5-29.el7.centos.2.x86_64 already installed and latest version Nothing to do [root@localhost ~]# vi /etc/ntp.conf // 增加配置 server ntp1.aliyun.com // 启动ntpd [root@localhost ~]# systemctl start ntpd.service // 配置开机启动ntpd [root@localhost ~]# systemctl enable ntpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service. [root@localhost ~]#
安装jdk
设置环境变量的时候要记得设置两次,一次在安装jdk的时候设置,一次在搭建Hadoop的时候设置
去官网下载jdk,最好是rpm包,然后上传到服务器节点中(使用jdk压缩包解压安装需要做很多其他的配置)
这里使用过windows下载,通过scp命令上传到118节点中
F:\workspace\demo>scp C:\Users\43866\Downloads\jdk-8u351-linux-x64.rpm root@192.168.0.118:/usr/jdk root@192.168.0.118's password: jdk-8u351-linux-aarch64.rpm 100% 59MB 70.1MB/s 00:00 F:\workspace\demo>
在118节点中使用命令安装jdk
[root@node01 jdk]# rpm -i jdk-8u351-linux-x64.rpm warning: jdk-8u351-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY Unpacking JAR files... tools.jar... plugin.jar... javaws.jar... deploy.jar... rt.jar... jsse.jar... charsets.jar... localedata.jar... [root@node01 jdk]#
设置JAVA_HOME环境变量
[root@node01 default]# vi /etc/profile // 追加环境变量并保存文件 export JAVA_HOME=/usr/java/default export PATH=$PATH:$JAVA_HOME/bin
设置SSH免秘钥
想要使用Hadoop脚本就必须设置ssh免密
1、检查是否已设置ssh免密
[root@node01 default]# ssh localhost The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is SHA256:rDsunaro1f5LyKkEeNohXfDD9oEglNXtviD/JZtA1dw. ECDSA key fingerprint is MD5:51:38:8d:fc:e4:d2:c7:ce:66:09:c8:f2:e6:9e:a7:f2. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. root@localhost's password:
通过ssh localhost命令检查发现需要输入密码,说明还未设置ssh免密,而且还可以自动生成.ssh文件,这个文件要创建的话比较麻烦
2、生成秘钥和公钥
如果118节点想免密登录到118节点(自己):
118节点就要生成公钥和秘钥,且将公钥放到 ~/.ssh/authorized_keys中
[root@node01 .ssh]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa Generating public/private dsa key pair. Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: SHA256:GHhKB7GeoYYlNPWJpCZ+VoABUyIgDbdYrjjyAdgui1k root@node01 The key's randomart image is: +---[DSA 1024]----+ |@BB+o. | |=X=.++. | |*o=.=++ | |=B +.* o | |B.Eo+ . S | |oOo. | |+ . | | | | | +----[SHA256]-----+ [root@node01 .ssh]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys [root@node01 .ssh]# [root@node01 .ssh]# ssh 192.168.0.118 Last login: Sat Dec 31 13:52:49 2022 from 192.168.0.117 [root@node01 ~]#
结论
119节点包含了118节点的公钥,118就可以免密登录
以上就是Hadoop部署的基础设施操作详解的详细内容,更多关于Hadoop部署基础操作的资料请关注自由互联其它相关文章!