5.4 配置java环境
[hd@localhost apps]$ su root
Password:
[root@localhost apps]# cd java/
[root@localhost java]# pwd
/home/hd/apps/java
[root@localhost java]#
[root@localhost java]# vi /etc/profile
使用vi编辑器,在/etc/profile增加java环境变量
export JAVA_HOME=/home/hd/apps/java
export PATH=$PATH:$JAVA_HOME/bin
重加载一下系统环境
[root@localhost java]# source /etc/profile
[root@localhost java]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
5.5 配置第二台,第三台机器的Java环境
使用scp远程拷贝命令
scp file2 [[user@]host2:]file2
1.把每一台机的java目录,拷贝到第二台机器
[root@localhost apps]# su hd
[hd@localhost apps]$
[hd@localhost apps]$ scp -r java hd@192.168.126.129:/home/hd/apps/
2.把每一台机的profile文件,拷贝到第二台机器
[hd@localhost apps]$ su root
Password:
[root@localhost apps]# scp /etc/profile root@192.168.126.129:/etc/
The authenticity of host '192.168.126.129 (192.168.126.129)' can't be established.
ECDSA key fingerprint is fb:0a:7a:9f:9a:bc:4f:ff:66:29:1d:1d:b9:a0:35:d1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.126.129' (ECDSA) to the list of known hosts.
root@192.168.126.129's password:
profile 100% 1820 1.8KB/s 00:00
[root@localhost apps]#
3.第二台机器加载profile
[hd@localhost apps]$ source /etc/profile
[hd@localhost apps]$
[hd@localhost apps]$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[hd@localhost apps]$
第三台机,执行以上的步骤
6. 安装hadoop之前准备
6.1 修改主机名
第一台机器master
第二台机器slave01
第三台机器slave02
[hd@localhost ~]$ hostnamectl set-hostname master
==== AUTHENTICATING FOR org.freedesktop.hostname1.set-static-hostname ===
Authentication is required to set the statically configured local host name, as well as the pretty host name.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
[hd@localhost ~]$ hostnamectl set-hostname slave01
[hd@localhost ~]$ hostnamectl set-hostname slave02
6.2 修改/etc/hosts 文件
[hd@master ~]$ su root
Password:
[root@master hd]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.126.128 master
192.168.126.129 slave01
192.168.126.130 slave02
同步到第二,三台机器
#第二台机器
[root@master hd]# scp /etc/hosts root@slave01:/etc/
#第三台机器
[root@master hd]# scp /etc/hosts root@slave02:/etc/
6.3 关闭防火墙
启动:systemctl start firewalld.service
查看状态: systemctl status firewalld.service
停止: systemctl stop firewalld.service
禁用: systemctl disable firewalld.service
重启: systemctl restart firewalld.service
6.4 免密登录
需要做的免密的机器
机器---->机器(免密登录)
master ----> slave01
master ----> slave02
master ----> master
6.4.1 生成密钥
[hd@master ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hd/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/hd/.ssh/id_rsa.
Your public key has been saved in /home/hd/.ssh/id_rsa.pub.
The key fingerprint is:
ef:ff:98:6c:a4:66:ca:66:a0:cd:a4:da:75:9c:c0:9f hd@slave02
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . |
| o S |
| o+ + . |
| *..E .o |
| .o.ooo.+..o |
| ... oo+.o=.. |
+-----------------+
6.4.2 拷贝密钥到你需要免密登录的机器
[hd@master ~]$ ssh-copy-id slave02
The authenticity of host 'slave02 (192.168.126.130)' can't be established.
ECDSA key fingerprint is 09:57:a3:56:3b:5f:f0:01:55:0e:42:f3:4c:43:3d:d5.
Are you sure you want to continue connecting (yes/no)? yes
/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
hd@slave02's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'slave02'"
and check to make sure that only the key(s) you wanted were added.
6.4.3 测试免密登录
[hd@master ~]$ ssh slave01
Last login: Sun Jul 12 23:54:32 2020 from 192.168.22.130
7. Hadoop安装
7.1 上传hadoop安装包
[hd@master hadoop]$ rz
rz waiting to receive.
zmodem trl+C ȡ
7.2 解压安装包
[hd@master apps]$ su hd
Password:
[hd@master apps]$ pwd
/home/hd/apps
[hd@master apps]$ tar -zxvf hadoop-3.0.0.tar.gz